My decoder uses an arbitrary buffer length and passes data blocks of this size, read from the MP3 file, to mad_stream_buffer. However, MAD throws a "lost synchronization" error immediately after returning from the input callback which feeds the data to mad_stream_buffer. The resulting decoded audio has artifacts at the equivelant locations.
Clearly mad expects the MP3 data to be aligned, perhaps on frame boundaries, but I can't find any mention of this in the source comments.
On Sat, 2003-11-15 at 09:18, Jedediah Smith wrote:
My decoder uses an arbitrary buffer length and passes data blocks of this size, read from the MP3 file, to mad_stream_buffer. However, MAD throws a "lost synchronization" error immediately after returning from the input callback which feeds the data to mad_stream_buffer. The resulting decoded audio has artifacts at the equivelant locations.
Clearly mad expects the MP3 data to be aligned, perhaps on frame boundaries, but I can't find any mention of this in the source comments.
I'll save Rob the trouble of repeating himself and quote what he wrote to me when I asked the same question:
"Each time you refill your buffer, you need to preserve the data in your existing buffer from stream.next_frame to the end.
"This usually amounts to calling memmove() on this unconsumed portion of the buffer and appending new data after it, before calling mad_stream_buffer()"
Josh