changeset 326:1b33baef9bf9

Added seek method.
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 20 May 2002 06:40:10 +0000
parents ed466b90dbcb
children aa7f6a110971
files decoders/smpeg.c
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/decoders/smpeg.c	Mon May 20 06:06:02 2002 +0000
+++ b/decoders/smpeg.c	Mon May 20 06:40:10 2002 +0000
@@ -214,7 +214,7 @@
     sample->actual.format = spec.format;
     sample->actual.rate = spec.freq;
     sample->actual.channels = spec.channels;
-    sample->flags = SOUND_SAMPLEFLAG_NONE;
+    sample->flags = SOUND_SAMPLEFLAG_CANSEEK;
     internal->decoder_private = smpeg;
 
     SMPEG_play(smpeg);
@@ -277,7 +277,20 @@
 
 static int _SMPEG_seek(Sound_Sample *sample, Uint32 ms)
 {
-    BAIL_MACRO("!!! FIXME: Not implemented", 0);
+    Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
+    SMPEG *smpeg = (SMPEG *) internal->decoder_private;
+    SMPEGstatus status;
+
+        /*
+         * SMPEG_rewind() really means "stop and rewind", so we may have to
+         * restart it afterwards.
+         */
+    status = SMPEG_status(smpeg);
+    SMPEG_rewind(smpeg);
+    SMPEG_skip(smpeg, ((float) ms) / 1000.0);
+    if (status == SMPEG_PLAYING)
+        SMPEG_play(smpeg);
+    return(1);
 } /* _SMPEG_seek */
 
 #endif /* SOUND_SUPPORTS_SMPEG */