changeset 3552:e840c5086a15 trunk

Automated merge with ssh://hg.atheme.org//hg/audacious
author William Pitcock <nenolod@atheme.org>
date Tue, 18 Sep 2007 12:58:03 -0500
parents d4f9e45c1e27 (current diff) 6b0be1d088e6 (diff)
children a140fadd741d
files
diffstat 3 files changed, 75 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/playlist.c	Tue Sep 18 12:57:50 2007 -0500
+++ b/src/audacious/playlist.c	Tue Sep 18 12:58:03 2007 -0500
@@ -668,48 +668,81 @@
 			       InputPlugin * dec)
 {
     PlaylistEntry *entry;
+    gint subtunes_num = 0, i = 0;
 
     g_return_if_fail(playlist != NULL);
     g_return_if_fail(filename != NULL);
 
-    entry = playlist_entry_new(filename,
-        tuple ? tuple_get_string(tuple, FIELD_TITLE, NULL) : NULL,
-        tuple ? tuple_get_int(tuple, FIELD_LENGTH, NULL) : -1, dec);
-    
-    if(!playlist->tail)
-        playlist->tail = g_list_last(playlist->entries);
-
-    PLAYLIST_LOCK(playlist);
-    
-    if(pos == -1) { // the common case
-        GList *element;
-        element = g_list_alloc();
-        element->data = entry;
-        element->prev = playlist->tail; // NULL is allowed here.
-        element->next = NULL;
-
-        if(!playlist->entries) { // this is the first element
-            playlist->entries = element;
-            playlist->tail = element;
-        }
-        else { // the rests
-            g_return_if_fail(playlist->tail != NULL);
-            playlist->tail->next = element;
-            playlist->tail = element;
+    if (tuple != NULL)
+    {
+        subtunes_num = tuple_get_int(tuple, FIELD_SUBSONG_NUM, NULL);
+        if ( subtunes_num > 0 )
+        {
+            i = 1;
+            tuple_free(tuple); /* will be replaced by subtune tuples */
         }
     }
-    else {
-        playlist->entries = g_list_insert(playlist->entries, entry, pos);
-    }
-
-    PLAYLIST_UNLOCK(playlist);
-    
-    if (tuple != NULL) {
-        const gchar *formatter = tuple_get_string(tuple, FIELD_FORMATTER, NULL);
-        entry->title = tuple_formatter_make_title_string(tuple, formatter ?
-                                                      formatter : get_gentitle_format());
-        entry->length = tuple_get_int(tuple, FIELD_LENGTH, NULL);
-        entry->tuple = tuple;
+
+    for ( ; i <= subtunes_num ; i++ )
+    {
+        gchar *filename_entry;
+        if ( subtunes_num > 0 )
+        {
+            GString *tmpstr = g_string_new(filename);
+            g_string_append_printf(tmpstr, "?%i", i);
+            filename_entry = tmpstr->str;
+            g_string_free(tmpstr, FALSE);
+
+            /* we're dealing with subtune, let's ask again tuple information
+               to plugin, by passing the ?subsong suffix; this way we may get
+               specific subtune information in the tuple, if available */
+            tuple = dec->get_song_tuple(filename_entry);
+        }
+        else
+        {
+            filename_entry = g_strdup(filename);
+        }
+
+        entry = playlist_entry_new(filename_entry,
+            tuple ? tuple_get_string(tuple, FIELD_TITLE, NULL) : NULL,
+            tuple ? tuple_get_int(tuple, FIELD_LENGTH, NULL) : -1, dec);
+        g_free(filename_entry);
+
+        if(!playlist->tail)
+            playlist->tail = g_list_last(playlist->entries);
+
+        PLAYLIST_LOCK(playlist);
+
+        if ((pos == -1) && (i < 2)) { // the common case
+            GList *element;
+            element = g_list_alloc();
+            element->data = entry;
+            element->prev = playlist->tail; // NULL is allowed here.
+            element->next = NULL;
+
+            if(!playlist->entries) { // this is the first element
+                playlist->entries = element;
+                playlist->tail = element;
+            }
+            else { // the rests
+                g_return_if_fail(playlist->tail != NULL);
+                playlist->tail->next = element;
+                playlist->tail = element;
+            }
+        }
+        else {
+            playlist->entries = g_list_insert(playlist->entries, entry, pos);
+        }
+
+        PLAYLIST_UNLOCK(playlist);
+
+        if (tuple != NULL) {
+            const gchar *formatter = tuple_get_string(tuple, FIELD_FORMATTER, NULL);
+            entry->title = tuple_formatter_make_title_string(tuple, formatter ?
+                                                          formatter : get_gentitle_format());
+            entry->length = tuple_get_int(tuple, FIELD_LENGTH, NULL);
+            entry->tuple = tuple;
+        }
     }
 
     if(tuple != NULL && tuple_get_int(tuple, FIELD_MTIME, NULL) == -1) { // kick the scanner thread only if mtime = -1 (uninitialized).
--- a/src/audacious/tuple.c	Tue Sep 18 12:57:50 2007 -0500
+++ b/src/audacious/tuple.c	Tue Sep 18 12:58:03 2007 -0500
@@ -47,6 +47,9 @@
     { "performer",      TUPLE_STRING },
     { "copyright",      TUPLE_STRING },
     { "date",           TUPLE_STRING },
+
+    { "subsong-id",     TUPLE_INT },
+    { "subsong-num",    TUPLE_INT },
 };
 
 static mowgli_heap_t *tuple_heap = NULL;
--- a/src/audacious/tuple.h	Tue Sep 18 12:57:50 2007 -0500
+++ b/src/audacious/tuple.h	Tue Sep 18 12:58:03 2007 -0500
@@ -50,6 +50,9 @@
     FIELD_COPYRIGHT,
     FIELD_DATE,
 
+    FIELD_SUBSONG_ID,
+    FIELD_SUBSONG_NUM,
+
     /* special field, must always be last */
     FIELD_LAST
 };