Enlightenment CVS committal
Author : tsauerbeck
Project : misc
Module : eplayer
Dir : misc/eplayer/src
Modified Files:
playlist.c vorbis.c
Log Message:
Fixed a potential segfault in the playlist code, fixed another one when play_loop()
wanted to automatically move over the end of the playlist
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/playlist.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- playlist.c 16 Oct 2003 14:54:33 -0000 1.2
+++ playlist.c 16 Oct 2003 18:06:28 -0000 1.3
@@ -14,7 +14,7 @@
static int is_dir (const char *dir) {
struct stat st;
- if (stat(dir, &st) != 0)
+ if (stat(dir, &st))
return 0;
return (S_ISDIR(st.st_mode));
@@ -162,6 +162,25 @@
}
/**
+ * Appends a list with PlayListItems to a PlayList.
+ *
+ * @param pl
+ * @param list
+ */
+static void playlist_append_list(PlayList *pl, Evas_List *list) {
+ if (!pl || !list)
+ return;
+
+ if (!pl->items)
+ pl->items = list;
+ else {
+ pl->items->last->next = list;
+ list->prev = pl->items->last;
+ pl->items->last = list->last;
+ }
+}
+
+/**
* Frees a PlayList object.
*
* @param pl The PlayList to free.
@@ -214,9 +233,6 @@
if (!pl || !(dir = opendir(path)))
return 0;
- if (!append)
- playlist_remove_all(pl);
-
/* ignore "." and ".." */
while ((entry = readdir(dir))
&& (!strcmp(entry->d_name, ".")
@@ -232,18 +248,16 @@
closedir(dir);
- if (!append) {
- pl->items = evas_list_reverse(tmp);
+ tmp = evas_list_reverse(tmp);
+
+ if (append)
+ playlist_append_list(pl, tmp);
+ else {
+ playlist_remove_all(pl);
+ pl->items = tmp;
pl->cur_item = pl->items;
- return 1;
}
- /* append the temporary list */
- tmp = evas_list_reverse(tmp);
- pl->items->last->next = tmp;
- tmp->prev = pl->items->last;
- pl->items->last = tmp->last;
-
return 1;
}
@@ -268,9 +282,6 @@
ptr = strrchr(dir, '/');
*ptr = 0;
- if (!append)
- playlist_remove_all(pl);
-
while (fgets (buf, sizeof (buf), fp)) {
if (!(ptr = strstrip(buf)) || !*ptr || *ptr == '#')
continue;
@@ -288,19 +299,14 @@
fclose(fp);
free(dir);
- if (!append) {
- pl->items = evas_list_reverse(tmp);
+ tmp = evas_list_reverse(tmp);
+
+ if (append)
+ playlist_append_list(pl, tmp);
+ else {
+ playlist_remove_all(pl);
+ pl->items = tmp;
pl->cur_item = pl->items;
- return 1;
- }
-
- if (!pl->items)
- pl->items = evas_list_reverse(tmp);
- else { /* append the temporary list */
- tmp = evas_list_reverse(tmp);
- pl->items->last->next = tmp;
- tmp->prev = pl->items->last;
- pl->items->last = tmp->last;
}
return 1;
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/vorbis.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- vorbis.c 16 Oct 2003 14:54:33 -0000 1.3
+++ vorbis.c 16 Oct 2003 18:06:28 -0000 1.4
@@ -3,6 +3,7 @@
#include <vorbis/vorbisfile.h>
#include <ao/ao.h>
#include <sys/ioctl.h>
+#include <assert.h>
#include "eplayer.h"
#include "vorbis.h"
@@ -28,13 +29,12 @@
ao_play (device, pcmout, buff_len);
update_time(player);
return 1;
+ } else { /* move to the next track */
+ edje_object_signal_emit(player->gui.edje,
+ "PLAY_NEXT", "next_button");
}
- /* This sucks ass, but look for another file here....... THIS IS A BAD THING!
*/
- player->playlist->cur_item = player->playlist->cur_item->next;
- open_track(player);
-
- return 1;
+ return 0;
}
int update_time(ePlayer *player) {
@@ -98,9 +98,17 @@
return 1;
}
+/**
+ * Opens the current track and prepares libao for playing.
+ *
+ * @param player
+ */
void open_track(ePlayer *player) {
- PlayListItem *pli = player->playlist->cur_item->data;
+ PlayListItem *pli;;
FILE *fp;
+
+ assert(player->playlist->cur_item);
+ pli = player->playlist->cur_item->data;
ov_clear(¤t_track);
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs