changeset 1438:dc3e28d3b92a

mpc: convert, wma: fixes
author William Pitcock <nenolod@atheme-project.org>
date Fri, 10 Aug 2007 09:19:44 -0500
parents 7373c4e2657c
children eda880d73d24 572db023e7a6
files src/musepack/libmpc.cxx src/musepack/libmpc.h src/wma/wma.c
diffstat 3 files changed, 41 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/src/musepack/libmpc.cxx	Fri Aug 10 09:06:16 2007 -0500
+++ b/src/musepack/libmpc.cxx	Fri Aug 10 09:19:44 2007 -0500
@@ -346,30 +346,28 @@
     return data->output->output_time();
 }
 
-static TitleInput *mpcGetSongTuple(char* p_Filename)
+static Tuple *mpcGetSongTuple(char* p_Filename)
 {
     VFSFile *input = vfs_fopen(p_Filename, "rb");
-    TitleInput *tuple = NULL;
+    Tuple *tuple = NULL;
 
     if(input)
     {
-        tuple = bmp_title_input_new();
-        gchar *filename_proxy = g_strdup(p_Filename);
-
-        tuple->file_name = g_path_get_basename(filename_proxy);
-        tuple->file_path = g_path_get_dirname(filename_proxy);
-        tuple->file_ext = "mpc";		// XXX: I can't be assed. -nenolod
+        tuple = tuple_new_from_filename(p_Filename);
 
         MpcInfo tags = getTags(p_Filename);
 
-        tuple->date         = g_strdup(tags.date);
-        tuple->track_name   = g_strdup(tags.title);
-        tuple->performer    = g_strdup(tags.artist);
-        tuple->album_name   = g_strdup(tags.album);
-        tuple->track_number = tags.track;
-        tuple->year         = tags.year;
-        tuple->genre        = g_strdup(tags.genre);
-        tuple->comment      = g_strdup(tags.comment);
+        tuple_associate_string(tuple, "date", tags.date);
+        tuple_associate_string(tuple, "title", tags.title);
+        tuple_associate_string(tuple, "artist", tags.artist);
+        tuple_associate_string(tuple, "album", tags.album);
+        tuple_associate_int(tuple, "track-number", tags.track);
+        tuple_associate_int(tuple, "year", tags.year);
+        tuple_associate_string(tuple, "genre", tags.genre);
+        tuple_associate_string(tuple, "comment", tags.comment);
+
+        tuple_associate_string(tuple, "codec", "Musepack");
+        tuple_associate_string(tuple, "quality", "lossy");
 
         freeTags(tags);
 
@@ -378,7 +376,7 @@
         mpc_reader_setup_file_vfs(&reader, input);
         mpc_streaminfo_read(&info, &reader.reader);
 
-        tuple->length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info));
+        tuple_associate_int(tuple, "length", static_cast<int> (1000 * mpc_streaminfo_get_length(&info)));
         vfs_fclose(input);
     }
     else
@@ -733,15 +731,14 @@
 
 static char* mpcGenerateTitle(const MpcInfo& p_Tags, char* p_Filename)
 {
-    TitleInput* tuple = mpcGetSongTuple(p_Filename);
+    Tuple* tuple = mpcGetSongTuple(p_Filename);
+
+    char* title = tuple_formatter_process_string(tuple, cfg.gentitle_format);
 
-    char* title = xmms_get_titlestring (xmms_get_gentitle_format(), tuple);
-    if(!title)
-        title = g_strdup(tuple->file_name);
-    else if (!*title)
-        title = g_strdup(tuple->file_name);
+    if (!*title)
+        title = g_strdup(tuple_get_string(tuple, "file-name"));
 
-    bmp_title_input_free(tuple);
+    mowgli_object_unref((void *) tuple);
     return title;
 }
 
--- a/src/musepack/libmpc.h	Fri Aug 10 09:06:16 2007 -0500
+++ b/src/musepack/libmpc.h	Fri Aug 10 09:19:44 2007 -0500
@@ -8,7 +8,7 @@
 #include "audacious/output.h"
 #include "audacious/util.h"
 #include "audacious/configdb.h"
-#include "audacious/titlestring.h"
+#include "audacious/main.h"
 #include "audacious/vfs.h"
 #include <audacious/i18n.h>
 #include "../../config.h"
@@ -134,7 +134,7 @@
 static void       setOffset(double);
 static bool       isPause();
 static void       setReplaygain(mpc_streaminfo&, mpc_decoder&);
-static TitleInput* mpcGetSongTuple(char *);
+static Tuple *    mpcGetSongTuple(char *);
 
 #ifdef MPC_FIXED_POINT
 inline static int shiftSigned(MPC_SAMPLE_FORMAT val, int shift)
--- a/src/wma/wma.c	Fri Aug 10 09:06:16 2007 -0500
+++ b/src/wma/wma.c	Fri Aug 10 09:19:44 2007 -0500
@@ -281,37 +281,30 @@
 static gchar *get_song_title(AVFormatContext *in, gchar * filename)
 {
     gchar *ret = NULL;
-    TitleInput *input;
+    Tuple *ti = tuple_new_from_filename(filename);
 
-    input = bmp_title_input_new();
-    
+    tuple_associate_string(ti, "codec", "Windows Media Audio (WMA)");
+    tuple_associate_string(ti, "quality", "lossy");
+
     if(strlen(in->title))
-        input->track_name = strdup(in->title);
+        tuple_associate_string(ti, "title", in->title);
     if(strlen(in->author))
-        input->performer = strdup(in->author);
+        tuple_associate_string(ti, "artist", in->author);
     if(strlen(in->album))
-        input->album_name = strdup(in->album);
+        tuple_associate_string(ti, "album", in->album);
     if(strlen(in->comment))
-        input->comment = strdup(in->comment);
+        tuple_associate_string(ti, "comment", in->comment);
     if(strlen(in->genre))
-        input->genre = strdup(in->genre);
+        tuple_associate_string(ti, "genre", in->genre);
     if(in->year > 0)
-       input->year = in->year;
+        tuple_associate_int(ti, "year", in->year);
     if(in->track > 0)
-        input->track_number = in->track;
+        tuple_associate_int(ti, "track", in->track);
+    if (in->duration)
+        tuple_associate_int(ti, "length", in->duration / 1000);
+    
+    ret = tuple_formatter_process_string(ti, cfg.gentitle_format);
 
-    input->file_name = g_path_get_basename(filename);
-    input->file_path = g_path_get_dirname(filename);
-    input->file_ext = extname(filename);
-    ret = xmms_get_titlestring(xmms_get_gentitle_format(), input);
-    if(input) g_free(input);
-
-    if(!ret)
-    {
-	    ret = g_strdup(input->file_name);
-            if (extname(ret) != NULL)
-                    *(extname(ret) - 1) = '\0';
-    }
     return ret;
 }
 
@@ -325,13 +318,13 @@
 
 static void wma_get_song_info(char *filename, char **title_real, int *len_real)
 {
-    TitleInput *tuple = wma_get_song_tuple(filename);
+    Tuple *tuple = wma_get_song_tuple(filename);
 
     if (tuple == NULL)
         return;
 
-    (*len_real) = tuple->length;
-    (*title_real) = xmms_get_titlestring(xmms_get_gentitle_format(), tuple);
+    (*len_real) = tuple_get_int(tuple, "length");
+    (*title_real) = tuple_formatter_process_string(tuple, cfg.gentitle_format);
 }
 
 static void wma_playbuff(InputPlayback *playback, int out_size)