[sdlsound] Sound_seek()?

Ryan C. Gordon icculus at clutteredmind.org
Sun Apr 21 13:29:27 EDT 2002

> I've looked through - briefly - the decoders I feel responsible for, and
> this is what I found:

I think adding a Sound_Seek() call is reasonable, then.

I'll probably specify the new position in milliseconds (since it's easy
enough to convert to an absolute byte position from there if need be). I
don't want to mess with SEEK_SET, SEEK_CUR and SEEK_END; I'd say just
specify in milliseconds from start of audio stream.

My decoder list:
  - WAV (and AIFF): I think ADPCM actually compresses to an exact
    ratio, so we can just skip X bytes in the stream and continue
    decoding without trouble. Other compression schemes may be more
    problematic, but I'm willing to flag them as unseekable. Regular WAV
    and AIFF is just a direct seek to byte position.
  - OGG: ov_raw_seek(). No problem.
  - SMPEG: This can be done with a mixture of SMPEG_rewind() and SMPEG_skip().
  - VOC: VOCs are always uncompressed, so it wouldn't be hard to do this one.
  - RAW: Well, duh.
  - MPGLIB: I'll see what exactly SMPEG does internally, but mpglib
    doesn't have this functionality. It might be a matter of manually
    locating the correct MP3 frame, and continuing to feed MPGLIB from
    there, since it shouldn't really care. For now, I'll flag this one as
  - SHN: Some SHNs keep a seek table at the end of the file, some don't.
    Some SHNs will be seekable, then.

Other thoughts:
  - FLAC: if the library version in use doesn't have
    FLAC__seekable_stream_decoder_set_absolute, which we can determine
    with autoconf, flag the Sample as unseekable.
  - AU: Same deal as WAV. 8-bit muLaw compresses in a 1-to-2 ratio, so we
    can seek to an exact byte position and keep decoding as if nothing

Generally I don't see any of these as show-stoppers. Sound_Seek() is most
useful for either looping audio with an arbitrary start point (almost
certainly for a game, in which case, the developer can dictate the file
format), or something like a XMMS plugin, where disabling seek control
and/or reporting an error to the user is acceptable.

I'll add the API and fill in stubs for the decoders later on.


More information about the sdlsound mailing list