changeset 2753:be414d015fec

Implement seeking (you can seek forward), it crashes when you seek backwards though :(.
author William Pitcock <nenolod@atheme.org>
date Tue, 01 Jul 2008 00:22:25 -0500
parents cd2d2118fdee
children 83a36251dcd1
files src/psf2/eng_protos.h src/psf2/peops2/spu.c src/psf2/peops2/spu.h src/psf2/plugin.c
diffstat 4 files changed, 49 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/psf2/eng_protos.h	Mon Jun 30 23:52:43 2008 -0500
+++ b/src/psf2/eng_protos.h	Tue Jul 01 00:22:25 2008 -0500
@@ -16,4 +16,4 @@
 int32 psf2_stop(void);
 int32 psf2_command(int32, int32);
 int32 psf2_fill_info(Tuple *);
-
+int   psf2_seek(uint32);
--- a/src/psf2/peops2/spu.c	Mon Jun 30 23:52:43 2008 -0500
+++ b/src/psf2/peops2/spu.c	Tue Jul 01 00:22:25 2008 -0500
@@ -332,9 +332,18 @@
 static u32 decaybegin;
 static u32 decayend;
 
+static u32 seektime;
+int psf2_seek(u32 t)
+{
+ seektime=t*441/10;
+ if(seektime>sampcount) return(1);
+ return(0);
+}
+
 // Counting to 65536 results in full volume offage.
 void setlength2(s32 stop, s32 fade)
 {
+ seektime = 0;
  if(stop==~0)
  {
   decaybegin=~0;
@@ -739,7 +748,7 @@
 	if(decaybegin!=~0) // Is anyone REALLY going to be playing a song
 		      // for 13 hours?
     	{
-		if(sampcount>=decayend) 
+		if(sampcount>=decayend)
 		{
 			psf2_update(NULL, 0, data);
 		        return(0);
@@ -760,7 +769,11 @@
   //////////////////////////////////////////////////////                   
   // feed the sound
   // wanna have around 1/60 sec (16.666 ms) updates
-	if ((((unsigned char *)pS)-((unsigned char *)pSpuBuffer)) == (735*4))
+	if (seektime != 0 && sampcount < seektime)
+	{
+		pS=(short *)pSpuBuffer;
+	}
+	else if ((((unsigned char *)pS)-((unsigned char *)pSpuBuffer)) == (735*4))
 	{
 	    	psf2_update((u8*)pSpuBuffer,(u8*)pS-(u8*)pSpuBuffer, data);
 	        pS=(short *)pSpuBuffer;					  
--- a/src/psf2/peops2/spu.h	Mon Jun 30 23:52:43 2008 -0500
+++ b/src/psf2/peops2/spu.h	Tue Jul 01 00:22:25 2008 -0500
@@ -36,4 +36,4 @@
 EXPORT_GCC long CALLBACK SPU2open(void *pDsp);
 EXPORT_GCC void CALLBACK SPU2async(unsigned long cycle, void *);
 EXPORT_GCC void CALLBACK SPU2close(void);
-
+EXPORT_GCC int  CALLBACK psf2_seek(u32 t);
--- a/src/psf2/plugin.c	Mon Jun 30 23:52:43 2008 -0500
+++ b/src/psf2/plugin.c	Tue Jul 01 00:22:25 2008 -0500
@@ -178,6 +178,12 @@
 
 		if (seek)
 		{
+			data->eof = FALSE;
+			data->output->flush(seek);
+
+			psf2_command(COMMAND_RESTART, 0);
+			psf2_seek(seek);
+
 			seek = 0;
 			continue;
 		}
@@ -230,23 +236,19 @@
 		buffer += t;
 	}
 
-#if 0
-    if (seek)
-    {
-        if(sexypsf_seek(seek))
-        {
-            playback->output->flush(seek);
-            seek = 0;
-        }
-        else  // negative time - must make a C time machine
-        {
-            sexypsf_stop();
-            return;
-        }
-    }
-    if (stop)
-        sexypsf_stop();
-#endif
+	if (seek)
+	{
+		if (psf2_seek(seek))
+		{
+			playback->output->flush(seek);
+			seek = 0;
+		}
+		else
+		{
+			playback->eof = TRUE;
+			return;
+		}
+	}
 }
 
 void psf2_Stop(InputPlayback *playback)
@@ -270,21 +272,23 @@
 	return 0;
 }
 
+void psf2_Seek(InputPlayback *playback, int time)
+{
+	seek = time * 1000;
+}
+
 gchar *psf2_fmts[] = { "psf2", "minipsf2", NULL };
 
 InputPlugin psf2_ip =
 {
-    .description = "PSF2 Audio Plugin",
-    .play_file = psf2_play,
-    .stop = psf2_Stop,
-    .pause = psf2_pause,
-#if 0
-    .seek = sexypsf_xmms_seek,
-    .get_song_info = sexypsf_xmms_getsonginfo,
-#endif
-    .get_song_tuple = psf2_tuple,
-    .is_our_file_from_vfs = psf2_is_our_fd,
-    .vfs_extensions = psf2_fmts,
+	.description = "PSF2 Audio Plugin",
+	.play_file = psf2_play,
+	.stop = psf2_Stop,
+	.pause = psf2_pause,
+	.seek = psf2_Seek,
+	.get_song_tuple = psf2_tuple,
+	.is_our_file_from_vfs = psf2_is_our_fd,
+	.vfs_extensions = psf2_fmts,
 };
 
 InputPlugin *psf2_iplist[] = { &psf2_ip, NULL };