# HG changeset patch # User Ryan C. Gordon # Date 1011470575 0 # Node ID 15a3b1a1291c06b54035ac6d0980eb2708dac23a # Parent 34000a50353b66be6c8b08e5e1c71992cda35794 Kludged implementation of the rewind method. diff -r 34000a50353b -r 15a3b1a1291c decoders/shn.c --- a/decoders/shn.c Sat Jan 19 19:04:55 2002 +0000 +++ b/decoders/shn.c Sat Jan 19 20:02:55 2002 +0000 @@ -111,6 +111,7 @@ Uint8 *backBuffer; Uint32 backBufferSize; Uint32 backBufLeft; + Uint32 start_pos; } shn_t; @@ -663,6 +664,8 @@ return(0); } /* if */ + shn->start_pos = SDL_RWtell(rw); + shn = (shn_t *) malloc(sizeof (shn_t)); if (shn == NULL) { @@ -691,7 +694,7 @@ } /* SHN_open */ -void fix_bitshift(Sint32 *buffer, int nitem, int bitshift, int ftype) +static void fix_bitshift(Sint32 *buffer, int nitem, int bitshift, int ftype) { int i; @@ -1301,10 +1304,25 @@ static int SHN_rewind(Sound_Sample *sample) { - /* !!! FIXME. */ - SNDDBG(("SHN_rewind(): Write me!\n")); - assert(0); - return(0); + Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; + shn_t *shn = (shn_t *) internal->decoder_private; + +#if 0 + int rc = SDL_RWseek(internal->rw, shn->start_pos, SEEK_SET); + BAIL_IF_MACRO(rc != shn->start_pos, ERR_IO_ERROR, 0); + /* !!! FIXME: set state. */ + return(1); +#else + /* + * !!! FIXME: This is really unacceptable; state should be reset and + * !!! FIXME: the RWops should be pointed to the start of the data + * !!! FIXME: to decode. The below kludge adds unneeded overhead and + * !!! FIXME: risk of failure. + */ + BAIL_IF_MACRO(SDL_RWseek(internal->rw, 0, SEEK_SET) != 0, ERR_IO_ERROR, 0); + SHN_close(sample); + return(SHN_open(sample, "SHN")); +#endif } /* SHN_rewind */ #endif /* defined SOUND_SUPPORTS_SHN */