changeset 1436:0ff7d08693f6

wavpack: update to new tuple API, use std::string more.
author William Pitcock <nenolod@atheme-project.org>
date Fri, 10 Aug 2007 08:57:47 -0500
parents 654aa79e43ef
children 7373c4e2657c
files src/wavpack/libwavpack.cxx src/wavpack/ui.cxx
diffstat 2 files changed, 38 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/wavpack/libwavpack.cxx	Fri Aug 10 08:42:59 2007 -0500
+++ b/src/wavpack/libwavpack.cxx	Fri Aug 10 08:57:47 2007 -0500
@@ -1,3 +1,5 @@
+#include <string>
+
 #include <assert.h>
 #include <string.h>
 #include <stdio.h>
@@ -8,7 +10,7 @@
 #include <audacious/plugin.h>
 #include <audacious/output.h>
 #include <audacious/configdb.h>
-#include <audacious/titlestring.h>
+#include <audacious/main.h>
 #include <audacious/util.h>
 #include <audacious/vfs.h>
 }
@@ -44,7 +46,7 @@
 static bool killDecodeThread;
 static bool AudioError;
 static GThread *thread_handle;
-static TitleInput *wv_get_song_tuple(char *);
+static Tuple *wv_get_song_tuple(char *);
 
 // in ui.cpp
 void wv_configure();
@@ -354,34 +356,43 @@
     return;
 }
 
-static TitleInput *
+static std::string
+WavpackPluginGetQualityString(WavpackContext *ctx)
+{
+    int mode = WavpackGetMode(ctx);
+
+    if (mode & MODE_LOSSLESS)
+        return "lossless";
+
+    if (mode & MODE_HYBRID)
+        return "lossy (hybrid)";
+
+    return "lossy";
+}
+
+static Tuple *
 tuple_from_WavpackContext(const char *fn, WavpackContext *ctx)
 {
     ape_tag tag;
-    TitleInput *ti;
+    Tuple *ti;
     int sample_rate = WavpackGetSampleRate(ctx);
 
-    ti = bmp_title_input_new();
-
-    ti->file_name = g_path_get_basename(fn);
-    ti->file_path = g_path_get_dirname(fn);
-    ti->file_ext = "wv";
+    ti = tuple_new_from_filename(fn);
 
     load_tag(&tag, ctx);
 
-    ti->track_name = g_strdup(tag.title);
-    ti->performer = g_strdup(tag.artist);
-    ti->album_name = g_strdup(tag.album);
-    ti->date = g_strdup(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 = g_strdup(tag.genre);
-    ti->comment = g_strdup(tag.comment);
-    ti->length = (int)(WavpackGetNumSamples(ctx) / sample_rate) * 1000;
+    tuple_associate_string(ti, "title", tag.title);
+    tuple_associate_string(ti, "artist", tag.artist);
+    tuple_associate_string(ti, "album", tag.album);
+    tuple_associate_string(ti, "genre", tag.genre);
+    tuple_associate_string(ti, "comment", tag.comment);
+    tuple_associate_string(ti, "date", tag.year);
+    tuple_associate_string(ti, "quality", WavpackPluginGetQualityString(ctx).c_str());
+    tuple_associate_string(ti, "codec", tag.year);
+
+    tuple_associate_int(ti, "track-number", atoi(tag.track));
+    tuple_associate_int(ti, "year", atoi(tag.year));
+    tuple_associate_int(ti, "length", (int)(WavpackGetNumSamples(ctx) / sample_rate) * 1000);
 
     return ti;
 }
@@ -390,23 +401,23 @@
 generate_title(const char *fn, WavpackContext *ctx)
 {
     static char *displaytitle = NULL;
-    TitleInput *ti;
+    Tuple *ti;
 
     ti = tuple_from_WavpackContext(fn, ctx);
 
-    displaytitle = xmms_get_titlestring(xmms_get_gentitle_format(), ti);
+    displaytitle = tuple_formatter_process_string(ti, cfg.gentitle_format);
     if (!displaytitle || *displaytitle == '\0')
         displaytitle = g_strdup(fn);
 
-    bmp_title_input_free(ti);
+    mowgli_object_unref((void *) ti);
 
     return displaytitle;
 }
 
-static TitleInput *
+static Tuple *
 wv_get_song_tuple(char *filename)
 {
-    TitleInput *ti;
+    Tuple *ti;
     WavpackDecoder d(&mod);
 
     if (!d.attach(filename)) {
--- a/src/wavpack/ui.cxx	Fri Aug 10 08:42:59 2007 -0500
+++ b/src/wavpack/ui.cxx	Fri Aug 10 08:57:47 2007 -0500
@@ -8,7 +8,6 @@
 #include <wavpack/wavpack.h>
 #include <audacious/plugin.h>
 #include <audacious/configdb.h>
-#include <audacious/titlestring.h>
 #include <audacious/util.h>
 #include <audacious/i18n.h>
 }