diff src/xmms-sid.c @ 132:4162a5370b9e

Added "seek"-subsong control option, in style of xmms-sidplay.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 16 Jan 2004 02:53:02 +0000
parents ddb513bd2610
children 92952aeccb77
line wrap: on
line diff
--- a/src/xmms-sid.c	Fri Jan 16 02:52:00 2004 +0000
+++ b/src/xmms-sid.c	Fri Jan 16 02:53:02 2004 +0000
@@ -466,19 +466,24 @@
  */
 void xs_seek(gint iTime)
 {
- gint n;
+ /* Check status */
  if (!xs_status.pTune || !xs_status.isPlaying) return;
- 
+
+ /* Act according to settings */ 
  switch (xs_cfg.subsongControl) {
- case XS_SSC_POPUP:
+ case XS_SSC_SEEK:
 	pthread_mutex_lock(&xs_mutex);
-	
-	n = xs_status.pTune->subTunes[xs_status.currSong].tuneLength;
-	if ((iTime > 0) && (iTime <= n))
+	if (iTime < xs_status.lastTime)
 		{
-		xs_status.currSong = 1 + ((iTime * xs_status.pTune->nsubTunes) / n);
+		if (xs_status.currSong > 1)
+			xs_status.currSong--;
+		} else
+	if (iTime > xs_status.lastTime)
+		{
+		if (xs_status.currSong < xs_status.pTune->nsubTunes)
+			xs_status.currSong++;
 		}
-	
+
 	pthread_mutex_unlock(&xs_mutex);
 	break;
 
@@ -518,15 +523,20 @@
 	return -1;
 
  /* Let's see what we do */
+ switch (xs_cfg.subsongControl) {
+ case XS_SSC_SEEK:
+ 	xs_status.lastTime = xs_plugin_ip.output->output_time() / 1000;
+ 	break;
+ 
 #ifdef HAVE_SONG_POSITION
- if (xs_cfg.subsongControl == XS_SSC_PATCH)
- 	{
+ case XS_SSC_PATCH:
 	pthread_mutex_lock(&xs_mutex);
 	set_song_position(xs_status.currSong, 1, xs_status.pTune->nsubTunes);
 	pthread_mutex_unlock(&xs_mutex);
-	}
+	break;
 #endif
-
+ }
+ 
  /* Else, return output time reported by audio output plugin */
  return xs_plugin_ip.output->output_time();
 }