changeset 2082:fbcea190a607 trunk

[svn] - update playlist_ins(), playlist_add().
author nenolod
date Mon, 11 Dec 2006 03:35:52 -0800
parents b98891c9e155
children 0d37e05dbad3
files ChangeLog audacious/playlist.c
diffstat 2 files changed, 29 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Dec 11 03:30:07 2006 -0800
+++ b/ChangeLog	Mon Dec 11 03:35:52 2006 -0800
@@ -1,3 +1,11 @@
+2006-12-11 11:30:07 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [3167]
+  - update playlist_delete_filenames() and friends
+  
+  trunk/audacious/playlist.c |   14 ++++++++------
+  1 file changed, 8 insertions(+), 6 deletions(-)
+
+
 2006-12-11 11:25:21 +0000  William Pitcock <nenolod@nenolod.net>
   revision [3165]
   - this commit breaks the API. I'm not done here, but hopefully the new API is
--- a/audacious/playlist.c	Mon Dec 11 03:30:07 2006 -0800
+++ b/audacious/playlist.c	Mon Dec 11 03:35:52 2006 -0800
@@ -408,7 +408,7 @@
     PLAYLIST_LOCK();
 
     for (fnode = filenames; fnode; fnode = g_list_next(fnode)) {
-        node = playlist;
+        node = playlist->entries;
 
         while (node) {
             GList *next = g_list_next(node);
@@ -486,7 +486,8 @@
 }
 
 static void
-__playlist_ins_with_info(const gchar * filename,
+__playlist_ins_with_info(Playlist * playlist,
+			 const gchar * filename,
                          gint pos,
                          const gchar * title,
                          gint len,
@@ -495,7 +496,7 @@
     g_return_if_fail(filename != NULL);
 
     PLAYLIST_LOCK();
-    playlist = g_list_insert(playlist,
+    playlist->entries = g_list_insert(playlist->entries,
                              playlist_entry_new(filename, title, len, dec),
                              pos);
     PLAYLIST_UNLOCK();
@@ -507,7 +508,8 @@
 }
 
 static void
-__playlist_ins_with_info_tuple(const gchar * filename,
+__playlist_ins_with_info_tuple(Playlist * playlist,
+			       const gchar * filename,
 			       gint pos,
 			       TitleInput *tuple,
 			       InputPlugin * dec)
@@ -515,18 +517,18 @@
     GList *node;
     PlaylistEntry *entry;
 
+    g_return_if_fail(playlist != NULL);
     g_return_if_fail(filename != NULL);
 
     PLAYLIST_LOCK();
-    playlist = g_list_insert(playlist,
+    playlist->entries = g_list_insert(playlist->entries,
                              playlist_entry_new(filename, tuple->track_name, tuple->length, dec),
                              pos);
 
-    if(pos < 0 ) {
-	    pos = g_list_length(playlist) - 1; /* last element. */
-    }
-
-    node = g_list_nth(playlist, pos);
+    if (pos < 0)
+	    pos = g_list_length(playlist->entries) - 1; /* last element. */
+
+    node = g_list_nth(playlist->entries, pos);
     entry = PLAYLIST_ENTRY(node->data);
 
     if (tuple != NULL) {
@@ -544,20 +546,23 @@
 }
 
 static void
-__playlist_ins(const gchar * filename, gint pos, InputPlugin *dec)
+__playlist_ins(Playlist * playlist, const gchar * filename, gint pos, InputPlugin *dec)
 {
-    __playlist_ins_with_info(filename, pos, NULL, -1, dec);
+    __playlist_ins_with_info(playlist, filename, pos, NULL, -1, dec);
     playlist_recalc_total_time();
 }
 
 gboolean
-playlist_ins(const gchar * filename, gint pos)
+playlist_ins(Playlist * playlist, const gchar * filename, gint pos)
 {
     gchar buf[64], *p;
     gint r;
     VFSFile *file;
     InputPlugin *dec;
 
+    g_return_val_if_fail(playlist != NULL, FALSE);
+    g_return_val_if_fail(filename != NULL, FALSE);
+
     if (is_playlist_name(filename)) {
         loading_playlist = TRUE;
         playlist_load_ins(filename, pos);
@@ -572,7 +577,7 @@
 
     if (cfg.playlist_detect == TRUE || loading_playlist == TRUE || (loading_playlist == FALSE && dec != NULL))
     {
-	__playlist_ins(filename, pos, dec);
+	__playlist_ins(playlist, filename, pos, dec);
 	playlist_generate_shuffle_list(playlist);
 	playlistwin_update_list();
         return TRUE;
@@ -733,9 +738,9 @@
 }
 
 gboolean
-playlist_add(const gchar * filename)
+playlist_add(Playlist * playlist, const gchar * filename)
 {
-    return playlist_ins(filename, -1);
+    return playlist_ins(playlist, filename, -1);
 }
 
 guint