changeset 114:9bb02321f986 trunk

[svn] - tuple support
author nenolod
date Tue, 24 Oct 2006 19:43:30 -0700
parents daba9f15ca01
children 2e77e3fdd3c1
files ChangeLog src/wavpack/libwavpack.cxx
diffstat 2 files changed, 63 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Oct 24 19:34:36 2006 -0700
+++ b/ChangeLog	Tue Oct 24 19:43:30 2006 -0700
@@ -1,3 +1,11 @@
+2006-10-25 02:34:36 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [226]
+  - fix a pango warning
+  
+  trunk/src/wavpack/ui.cxx |    2 +-
+  1 file changed, 1 insertion(+), 1 deletion(-)
+
+
 2006-10-25 02:29:07 +0000  William Pitcock <nenolod@nenolod.net>
   revision [224]
   - make debugging notices optional
--- a/src/wavpack/libwavpack.cxx	Tue Oct 24 19:34:36 2006 -0700
+++ b/src/wavpack/libwavpack.cxx	Tue Oct 24 19:43:30 2006 -0700
@@ -43,7 +43,7 @@
 static bool killDecodeThread;
 static bool AudioError;
 static GThread *thread_handle;
-static gboolean EQ_on;
+static TitleInput *wv_get_song_tuple(char *);
 
 // in ui.cpp
 void wv_configure();
@@ -80,6 +80,7 @@
     wv_get_song_info,
     wv_file_info_box,          //info box
     NULL,                       //output
+    wv_get_song_tuple,
 };
 
 class WavpackDecoder
@@ -292,6 +293,37 @@
     return;
 }
 
+static TitleInput *
+tuple_from_WavpackContext(const char *fn, WavpackContext *ctx)
+{
+    ape_tag tag;
+    TitleInput *ti;
+    int sample_rate = WavpackGetSampleRate(ctx);
+
+    ti = bmp_title_input_new();
+
+    ti->file_name = g_strdup(g_basename(fn));
+    ti->file_ext = "wv";
+
+    load_tag(&tag, ctx);
+
+    ti->track_name = tag.title;
+    ti->performer = tag.artist;
+    ti->album_name = tag.album;
+    ti->date = tag.year;
+    ti->track_number = atoi(tag.track);
+    if (ti->track_number < 0)
+        ti->track_number = 0;
+    ti->year = atoi(tag.year);
+    if (ti->year < 0)
+        ti->year = 0;
+    ti->genre = tag.genre;
+    ti->comment = tag.comment;
+    ti->length = (int)(WavpackGetNumSamples(ctx) / sample_rate) * 1000;
+
+    return ti;
+}
+
 static char *
 generate_title(const char *fn, WavpackContext *ctx)
 {
@@ -299,43 +331,37 @@
     ape_tag tag;
     TitleInput *ti;
 
-    ti = (TitleInput *) g_malloc0(sizeof(TitleInput));
-    ti->__size = XMMS_TITLEINPUT_SIZE;
-    ti->__version = XMMS_TITLEINPUT_VERSION;
-
-    ti->file_name = g_strdup(g_basename(fn));
-    ti->file_ext = "wv";
-
-    load_tag(&tag, ctx);
-
-    // xmms doesn't support unicode...
-    ti->track_name = convertUTF8toLocale(tag.title);
-    ti->performer = convertUTF8toLocale(tag.artist);
-    ti->album_name = convertUTF8toLocale(tag.album);
-    ti->date = convertUTF8toLocale(tag.year);
-    ti->track_number = atoi(tag.track);
-    if (ti->track_number < 0)
-        ti->track_number = 0;
-    ti->year = atoi(tag.year);
-    if (ti->year < 0)
-        ti->year = 0;
-    ti->genre = convertUTF8toLocale(tag.genre);
-    ti->comment = convertUTF8toLocale(tag.comment);
+    ti = tuple_from_WavpackContext(fn, ctx);
 
     displaytitle = xmms_get_titlestring(xmms_get_gentitle_format(), ti);
     if (!displaytitle || *displaytitle == '\0'
         || (strlen(tag.title) == 0 && strlen(tag.artist) == 0))
         displaytitle = ti->file_name;
-    g_free(ti->track_name);
-    g_free(ti->performer);
-    g_free(ti->album_name);
-    g_free(ti->genre);
-    g_free(ti->comment);
-    g_free(ti);
+
+    bmp_title_input_free(ti);
 
     return displaytitle;
 }
 
+static TitleInput *
+wv_get_song_tuple(char *filename)
+{
+    TitleInput *ti;
+    char error_buff[4096]; // TODO: fixme!
+    WavpackContext *ctx = WavpackOpenFileInput(filename, error_buff, OPEN_TAGS | OPEN_WVC, 0);
+
+    if (ctx == NULL) {
+        printf("wavpack: Error opening file: \"%s: %s\"\n", filename, error_buff);
+        return NULL;
+    }
+
+    ti = tuple_from_WavpackContext(filename, ctx);
+
+    WavpackCloseFile(ctx);
+
+    return ti;
+}
+
 static void
 wv_get_song_info(char *filename, char **title, int *length)
 {