changeset 1583:2b5768cdca7a

Use set_info(), blah and actually add at least the default sub-tune to playlist (wasn't added at all, if length wasn't known, fixed).
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 03 Sep 2007 17:46:16 +0300
parents 89fb1700313a
children a6115d004ec3
files src/sid/xmms-sid.c src/sid/xmms-sid.glade src/sid/xs_interface.c
diffstat 3 files changed, 41 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/sid/xmms-sid.c	Mon Sep 03 10:59:32 2007 +0300
+++ b/src/sid/xmms-sid.c	Mon Sep 03 17:46:16 2007 +0300
@@ -89,6 +89,7 @@
 XS_MUTEX(xs_status);
 static XS_THREAD_T xs_decode_thread;
 
+Tuple * xs_get_song_tuple_info(gchar *songFilename, gint subTune);
 
 /*
  * Error messages
@@ -321,7 +322,8 @@
 					gboolean doAdd = FALSE;
 					
 					if (xs_cfg.subAutoMinOnly) {
-						if (pInfo->subTunes[i - 1].tuneLength >= xs_cfg.subAutoMinTime)
+						if (i == pInfo->startTune ||
+							pInfo->subTunes[i - 1].tuneLength >= xs_cfg.subAutoMinTime)
 							doAdd = TRUE;
 					} else
 						doAdd = TRUE;
@@ -341,7 +343,7 @@
 		
 		g_free(tmpFilename);
 	}
-
+	
 	return tmpResult;
 }
 
@@ -353,10 +355,10 @@
 {
 	t_xs_status myStatus;
 	t_xs_tuneinfo *myTune;
-	gboolean audioOpen = FALSE, doPlay = FALSE, isFound = FALSE;
+	gboolean audioOpen = FALSE;
 	gint audioGot, songLength, i, subTune;
-	gchar *tmpFilename, *audioBuffer = NULL, *oversampleBuffer = NULL;
-	Tuple *tmpTitle;
+	gchar *tmpFilename, *audioBuffer = NULL, *oversampleBuffer = NULL, *tmpTitle;
+	Tuple *tmpTuple;
 
 	assert(pb);
 	assert(xs_status.sidPlayer);
@@ -382,6 +384,7 @@
 	}
 	
 	g_free(tmpFilename);
+	tmpFilename = NULL;
 
 	XSDEBUG("load ok\n");
 
@@ -412,7 +415,7 @@
 		goto xs_err_exit;
 	}
 
-	if (xs_status.oversampleEnable) {
+	if (myStatus.oversampleEnable) {
 		oversampleBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE * myStatus.oversampleFactor);
 		if (oversampleBuffer == NULL) {
 			xs_error(_("Couldn't allocate memory for audio oversampling buffer!\n"));
@@ -456,18 +459,19 @@
 	/* Set song information for current subtune */
 	XSDEBUG("foobar\n");
 	myStatus.sidPlayer->plrUpdateSIDInfo(&myStatus);
-/*
-		tmpTitle = xs_make_titlestring(myTune, subTune);
+
+	tmpTuple = xs_get_song_tuple_info(myTune->sidFilename, myStatus.currSong);
+	tmpTitle = tuple_formatter_process_string(tmpTuple, get_gentitle_format());
+	
+	xs_plugin_ip.set_info(
+		tmpTitle,
+		(songLength > 0) ? (songLength * 1000) : 0,
+		-1,
+		myStatus.audioFrequency,
+		myStatus.audioChannels);
 		
-		xs_plugin_ip.set_info(
-			tmpTitle,
-			(songLength > 0) ? (songLength * 1000) : 0,
-			-1,
-			myStatus.audioFrequency,
-			myStatus.audioChannels);
-		
-		g_free(tmpTitle);
-*/		
+	g_free(tmpTitle);
+	
 
 	XSDEBUG("playing\n");
 	while (xs_status.isPlaying && myStatus.isPlaying) {
@@ -642,28 +646,23 @@
 
 /* Return song information Tuple
  */
-Tuple * xs_get_song_tuple(gchar *songFilename)
+Tuple * xs_get_song_tuple_info(gchar *songFilename, gint subTune)
 {
 	t_xs_tuneinfo *pInfo;
 	Tuple *pResult;
-	gchar *tmpStr, *tmpFilename;
-	gint subTune;
+	gchar *tmpStr;
 
-	XS_MUTEX_LOCK(xs_status);
-
-	xs_get_trackinfo(songFilename, &tmpFilename, &subTune);
-	
 	pResult = tuple_new_from_filename(songFilename);
 
 	/* Get tune information from emulation engine */
-	pInfo = xs_status.sidPlayer->plrGetSIDInfo(tmpFilename);
+	XS_MUTEX_LOCK(xs_status);
+	pInfo = xs_status.sidPlayer->plrGetSIDInfo(songFilename);
 	if (!pInfo) {
 		XS_MUTEX_UNLOCK(xs_status);
 		return pResult;
 	}
+	XS_MUTEX_UNLOCK(xs_status);
 	
-	g_free(tmpFilename);
-
 	tuple_associate_string(pResult, "title", pInfo->sidName);
 	tuple_associate_string(pResult, "artist", pInfo->sidComposer);
 	tuple_associate_string(pResult, "genre", "SID-tune");
@@ -694,6 +693,18 @@
 
 	/* Free tune information */
 	xs_tuneinfo_free(pInfo);
-	XS_MUTEX_UNLOCK(xs_status);
 	return pResult;
 }
+
+Tuple * xs_get_song_tuple(gchar *songFilename)
+{
+	Tuple *pResult;
+	gchar *tmpFilename;
+	gint subTune;
+
+	xs_get_trackinfo(songFilename, &tmpFilename, &subTune);
+	pResult = xs_get_song_tuple_info(tmpFilename, subTune);
+	g_free(tmpFilename);
+
+	return pResult;
+}
--- a/src/sid/xmms-sid.glade	Mon Sep 03 10:59:32 2007 +0300
+++ b/src/sid/xmms-sid.glade	Mon Sep 03 17:46:16 2007 +0300
@@ -2434,7 +2434,7 @@
 			<widget class="GtkCheckButton" id="cfg_subauto_enable">
 			  <property name="visible">True</property>
 			  <property name="can_focus">True</property>
-			  <property name="label" translatable="yes">Add all sub-tunes to playlist</property>
+			  <property name="label" translatable="yes">Add sub-tunes to playlist</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
 			  <property name="focus_on_click">True</property>
--- a/src/sid/xs_interface.c	Mon Sep 03 10:59:32 2007 +0300
+++ b/src/sid/xs_interface.c	Mon Sep 03 17:46:16 2007 +0300
@@ -899,7 +899,7 @@
   gtk_container_add (GTK_CONTAINER (w_frame31), w_vbox35);
   gtk_container_set_border_width (GTK_CONTAINER (w_vbox35), 2);
 
-  cfg_subauto_enable = gtk_check_button_new_with_mnemonic (_("Add all sub-tunes to playlist"));
+  cfg_subauto_enable = gtk_check_button_new_with_mnemonic (_("Add sub-tunes to playlist"));
   gtk_widget_show (cfg_subauto_enable);
   gtk_box_pack_start (GTK_BOX (w_vbox35), cfg_subauto_enable, FALSE, FALSE, 0);