# HG changeset patch # User Ryan C. Gordon # Date 1021876810 0 # Node ID 1b33baef9bf96401a55f44a6bfd3d41f5cd4e045 # Parent ed466b90dbcb33322a4d84c358ed001dbe6276b9 Added seek method. diff -r ed466b90dbcb -r 1b33baef9bf9 decoders/smpeg.c --- 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 */