diff decoders/voc.c @ 224:1bafef18dabf

Implemented rewind method.
author Ryan C. Gordon <icculus@icculus.org>
date Fri, 18 Jan 2002 02:12:03 +0000
parents c9772a9f5271
children ca43129df299
line wrap: on
line diff
--- a/decoders/voc.c	Thu Jan 17 20:55:46 2002 +0000
+++ b/decoders/voc.c	Fri Jan 18 02:12:03 2002 +0000
@@ -91,6 +91,7 @@
     Uint8 	channels;       /* number of sound channels */
     int     extended;       /* Has an extended block been read? */
     Uint32  bufpos;         /* byte position in internal->buffer. */
+    Uint32  start_pos;      /* offset to seek to in stream when rewinding. */
 } vs_t;
 
 /* Size field */ 
@@ -435,6 +436,7 @@
     memset(v, '\0', sizeof (vs_t));
     internal->decoder_private = v;
 
+    v->start_pos = SDL_RWtell(internal->rw);
     v->rate = -1;
     if (!voc_get_block(sample))
     {
@@ -492,10 +494,12 @@
 
 static int VOC_rewind(Sound_Sample *sample)
 {
-    /* !!! FIXME. */
-    SNDDBG(("VOC_rewind(): Write me!\n"));
-    assert(0);
-    return(0);
+    Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
+    vs_t *v = (vs_t *) internal->decoder_private;
+    int rc = SDL_RWseek(internal->rw, v->start_pos, SEEK_SET);
+    BAIL_IF_MACRO(rc != v->start_pos, ERR_IO_ERROR, 0);
+    v->rest = 0;
+    return(1);
 } /* VOC_rewind */
 
 #endif /* SOUND_SUPPORTS_VOC */