changeset 1476:c6947f95fd2a

converted sid plugin to new tuple system
author Giacomo Lozito <james@develia.org>
date Sat, 11 Aug 2007 23:56:22 +0200
parents 1c5688582a4e
children 04311d687e94
files src/sid/xmms-sid.c src/sid/xmms-sid.h src/sid/xs_support.h src/sid/xs_title.c src/sid/xs_title.h
diffstat 5 files changed, 45 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/sid/xmms-sid.c	Sat Aug 11 22:15:50 2007 +0200
+++ b/src/sid/xmms-sid.c	Sat Aug 11 23:56:22 2007 +0200
@@ -940,10 +940,10 @@
 }
 
 
-TitleInput * xs_get_song_tuple(gchar *songFilename)
+t_xs_tuple * xs_get_song_tuple(gchar *songFilename)
 {
 	t_xs_tuneinfo *pInfo;
-	TitleInput *pResult = NULL;
+	t_xs_tuple *pResult = NULL;
 
 	/* Get tune information from emulation engine */
 	pInfo = xs_status.sidPlayer->plrGetSIDInfo(songFilename);
@@ -957,10 +957,17 @@
 		pResult = xs_make_titletuple(pInfo, pInfo->startTune);
 
 		tmpInt = pInfo->subTunes[pInfo->startTune-1].tuneLength;
+#ifdef AUDACIOUS_PLUGIN
+		if (tmpInt < 0)
+			tuple_associate_int(pResult, "length", -1);
+		else
+		   tuple_associate_int(pResult, "length", tmpInt * 1000);
+#else
 		if (tmpInt < 0)
 			pResult->length = -1;
 		else
 			pResult->length = (tmpInt * 1000);
+#endif
 	}
 
 	/* Free tune information */
--- a/src/sid/xmms-sid.h	Sat Aug 11 22:15:50 2007 +0200
+++ b/src/sid/xmms-sid.h	Sat Aug 11 23:56:22 2007 +0200
@@ -189,7 +189,7 @@
 void	xs_seek(InputPlayback *, gint);
 gint	xs_get_time(InputPlayback *);
 void	xs_get_song_info(gchar *, gchar **, gint *);
-TitleInput *xs_get_song_tuple(gchar *);
+t_xs_tuple *xs_get_song_tuple(gchar *);
 void	xs_about(void);
 
 
--- a/src/sid/xs_support.h	Sat Aug 11 22:15:50 2007 +0200
+++ b/src/sid/xs_support.h	Sat Aug 11 23:56:22 2007 +0200
@@ -15,10 +15,12 @@
 #ifdef AUDACIOUS_PLUGIN
 #include <audacious/plugin.h>
 #include <audacious/output.h>
-#include <audacious/util.h>  
+#include <audacious/util.h>
+#include <audacious/tuple.h>
 #else
 #include <xmms/plugin.h>
 #include <xmms/util.h>
+#include <xmms/titlestring.h>
 #endif
 
 #ifdef HAVE_ASSERT_H
@@ -40,6 +42,13 @@
 #endif
 
 
+/* Metadata structures */
+#ifdef AUDACIOUS_PLUGIN
+#define t_xs_tuple Tuple
+#else
+#define t_xs_tuple TitleInput
+#endif
+
 /* VFS replacement functions
  */
 #ifdef __AUDACIOUS_NEWVFS__
--- a/src/sid/xs_title.c	Sat Aug 11 22:15:50 2007 +0200
+++ b/src/sid/xs_title.c	Sat Aug 11 23:56:22 2007 +0200
@@ -23,12 +23,6 @@
 #include "xs_title.h"
 #include "xs_support.h"
 #include "xs_config.h"
-#ifdef AUDACIOUS_PLUGIN
-#include <audacious/titlestring.h>
-#else
-#include <xmms/titlestring.h>
-#endif
-
 
 static void xs_path_split(gchar *path, gchar **tmpFilename, gchar **tmpFilePath, gchar **tmpFileExt)
 {
@@ -57,18 +51,24 @@
 #if defined(HAVE_XMMSEXTRA) || defined(AUDACIOUS_PLUGIN)
 /* Tuple support
  */
-static TitleInput * xs_get_titletuple(gchar *tmpFilename, gchar *tmpFilePath,
+static t_xs_tuple * xs_get_titletuple(gchar *tmpFilename, gchar *tmpFilePath,
 	gchar *tmpFileExt, t_xs_tuneinfo *p, gint subTune)
 {
-	TitleInput *pResult;
-	
+   t_xs_tuple *pResult;
 #ifdef AUDACIOUS_PLUGIN
-	pResult = bmp_title_input_new();
+	pResult = tuple_new();
+	tuple_associate_string(pResult, "title", p->sidName);
+	tuple_associate_string(pResult, "artist", p->sidComposer);
+	tuple_associate_string(pResult, "file-name", tmpFilename);
+	tuple_associate_string(pResult, "file-ext", tmpFileExt);
+	tuple_associate_string(pResult, "file-path", tmpFilePath);
+	tuple_associate_int(pResult, "track-number", subTune);
+	tuple_associate_string(pResult, "genre", "SID-tune");
+	tuple_associate_string(pResult, "comment", p->sidCopyright);
 #else
 	pResult = (TitleInput *) g_malloc0(sizeof(TitleInput));
 	pResult->__size = XMMS_TITLEINPUT_SIZE;
 	pResult->__version = XMMS_TITLEINPUT_VERSION;
-#endif
 
 	/* Create the input fields */
 	pResult->file_name = tmpFilename;
@@ -84,12 +84,12 @@
 	pResult->year = 0;
 	pResult->genre = g_strdup("SID-tune");
 	pResult->comment = g_strdup(p->sidCopyright);
-	
+#endif	
 	return pResult;
 }
 
 #ifdef AUDACIOUS_PLUGIN
-TitleInput * xs_make_titletuple(t_xs_tuneinfo *p, gint subTune)
+t_xs_tuple * xs_make_titletuple(t_xs_tuneinfo *p, gint subTune)
 {
 	gchar *tmpFilename, *tmpFilePath, *tmpFileExt;
 
@@ -137,9 +137,16 @@
 
 
 	/* Check if the titles are overridden or not */
-#if defined(HAVE_XMMSEXTRA) || defined(AUDACIOUS_PLUGIN)
-	if (!xs_cfg.titleOverride) {
-		TitleInput *pTuple = xs_get_titletuple(
+#if defined(AUDACIOUS_PLUGIN)
+   if (!xs_cfg.titleOverride) {
+		t_xs_tuple *pTuple = xs_get_titletuple(
+			tmpFilename, tmpFilePath, tmpFileExt, p, subTune);
+		pcResult = tuple_formatter_process_string(pTuple, get_gentitle_format());
+		tuple_free(pTuple);
+	} else
+#elif defined(HAVE_XMMSEXTRA)
+   if (!xs_cfg.titleOverride) {
+		t_xs_tuple *pTuple = xs_get_titletuple(
 			tmpFilename, tmpFilePath, tmpFileExt, p, subTune);
 		
 		pcResult = xmms_get_titlestring(xmms_get_gentitle_format(), pTuple);
@@ -151,7 +158,7 @@
 		g_free(pTuple->genre);
 		g_free(pTuple->comment);
 		g_free(pTuple);
-	} else 
+	} else
 #endif
 	{
 		/* Create the string */
--- a/src/sid/xs_title.h	Sat Aug 11 22:15:50 2007 +0200
+++ b/src/sid/xs_title.h	Sat Aug 11 23:56:22 2007 +0200
@@ -9,7 +9,7 @@
 
 gchar *xs_make_titlestring(t_xs_tuneinfo *, gint);
 #ifdef AUDACIOUS_PLUGIN
-TitleInput * xs_make_titletuple(t_xs_tuneinfo *p, gint subTune);
+t_xs_tuple *xs_make_titletuple(t_xs_tuneinfo *p, gint subTune);
 #endif
 
 #ifdef __cplusplus