comparison decoders/smpeg.c @ 326:1b33baef9bf9

Added seek method.
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 20 May 2002 06:40:10 +0000
parents c97be6e1bd27
children 069ce624d6cf
comparison
equal deleted inserted replaced
325:ed466b90dbcb 326:1b33baef9bf9
212 */ 212 */
213 SMPEG_actualSpec(smpeg, &spec); 213 SMPEG_actualSpec(smpeg, &spec);
214 sample->actual.format = spec.format; 214 sample->actual.format = spec.format;
215 sample->actual.rate = spec.freq; 215 sample->actual.rate = spec.freq;
216 sample->actual.channels = spec.channels; 216 sample->actual.channels = spec.channels;
217 sample->flags = SOUND_SAMPLEFLAG_NONE; 217 sample->flags = SOUND_SAMPLEFLAG_CANSEEK;
218 internal->decoder_private = smpeg; 218 internal->decoder_private = smpeg;
219 219
220 SMPEG_play(smpeg); 220 SMPEG_play(smpeg);
221 return(1); 221 return(1);
222 } /* _SMPEG_open */ 222 } /* _SMPEG_open */
275 } /* _SMPEG_rewind */ 275 } /* _SMPEG_rewind */
276 276
277 277
278 static int _SMPEG_seek(Sound_Sample *sample, Uint32 ms) 278 static int _SMPEG_seek(Sound_Sample *sample, Uint32 ms)
279 { 279 {
280 BAIL_MACRO("!!! FIXME: Not implemented", 0); 280 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
281 SMPEG *smpeg = (SMPEG *) internal->decoder_private;
282 SMPEGstatus status;
283
284 /*
285 * SMPEG_rewind() really means "stop and rewind", so we may have to
286 * restart it afterwards.
287 */
288 status = SMPEG_status(smpeg);
289 SMPEG_rewind(smpeg);
290 SMPEG_skip(smpeg, ((float) ms) / 1000.0);
291 if (status == SMPEG_PLAYING)
292 SMPEG_play(smpeg);
293 return(1);
281 } /* _SMPEG_seek */ 294 } /* _SMPEG_seek */
282 295
283 #endif /* SOUND_SUPPORTS_SMPEG */ 296 #endif /* SOUND_SUPPORTS_SMPEG */
284 297
285 /* end of smpeg.c ... */ 298 /* end of smpeg.c ... */