On Sep 21, 2004, at 1:33 PM, Francis Labonte wrote:
I have a question about mad_stream_skip.
If I call this function, would if be correct to call mad_stream_sync after?
Probably not.
The purpose of mad_stream_skip() is to tell the decoder to skip a number of bytes in the stream because they do not contain audio data. The most common use for this is to skip embedded ID3 tag information. Bytes skipped may cross stream buffer boundaries; MAD_ERROR_BUFLEN is returned as appropriate, so your stream refilling code need not be aware that bytes are being skipped. After the indicated number of bytes have been skipped, the decoder assumes the next byte begins a sync word. If not, MAD_ERROR_LOSTSYNC is returned as usual and the sync word will be located automatically on the next call.
Since the decoder does it automatically, it's almost never necessary to call mad_stream_sync() yourself.
Actually, mad_stream_skip does'nt care about the skip offset (well, I think...). I would expect that if I call sync after skip, It will try to sync starting from the new position (position + skip offset).
What actually happens is the skip is deferred until the next frame is decoded, but the sync happens immediately. The reason is that skips may cross stream buffer boundaries, but the sync search happens only within the current buffer.