diff decoders/mp3.c @ 231:d3dc34315ac7

Rewind method implemented by Torbj�rn.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 19 Jan 2002 16:58:34 +0000
parents c9772a9f5271
children
line wrap: on
line diff
--- a/decoders/mp3.c	Sat Jan 19 03:11:26 2002 +0000
+++ b/decoders/mp3.c	Sat Jan 19 16:58:34 2002 +0000
@@ -239,7 +239,7 @@
          * We have to clear the buffer because apparently SMPEG_playAudio()
          * will mix the decoded audio with whatever's already in it. Nasty.
          */
-    memset(internal->buffer, 0, internal->buffer_size);
+    memset(internal->buffer, '\0', internal->buffer_size);
     retval = SMPEG_playAudio(smpeg, internal->buffer, internal->buffer_size);
     if (retval < internal->buffer_size)
     {
@@ -259,10 +259,19 @@
 
 static int MP3_rewind(Sound_Sample *sample)
 {
-    /* !!! FIXME. */
-    SNDDBG(("MP3_rewind(): Write me!\n"));
-    assert(0);
-    return(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);
+    if (status == SMPEG_PLAYING)
+        SMPEG_play(smpeg);
+    return(1);
 } /* MP3_rewind */
 
 #endif /* SOUND_SUPPORTS_MP3 */