On Thursday, July 10, 2003, at 11:07 AM, Patrick Cernko wrote:
Can you give me some hints where I can search for the error or do you think, this is a bug in the library perhaps?
Looking briefly at your CVS code, a few things come to mind.
I would guess most probably the error results from this:
if ( stream->error == MAD_ERROR_BUFLEN ) {
/* calculate the size of the data that could not be decoded */ rest_length = cur_buffer_end - stream->this_frame;
Since the decoding of the frame failed, there is in effect no "this_frame" -- the pointer you want is actually stream->next_frame.
Likewise you should use stream->next_frame here:
memcpy( tmpbuffer, stream->this_frame, rest_length );
and furthermore, technically, this should probably instead be memmove() since it's possible (although unlikely) the memory areas may overlap.
My guess is that on a few occasions this bitstream mismanipulation is causing some frames to be decoded incorrectly.
The only other thing that jumps out at me is that, while unlikely to be related to your problem, I noticed you are maintaining a struct mad_decoder when there is no reason to do so. That structure is only used in the high-level API. Since you are now using the low-level API, there is no need for it.
This will simplify some of your code. You don't need to allocate memory for, initialize, or deinitialize the decoder struct. The initMadDecoderSync.[ch] files are unnecessary. Allocate memory for the stream, frame, and synth structs directly (i.e. include the actual structs instead of pointers in your class.) And you don't need to bother with setting the stream options unless you actually want/need something specific.
Hope this helps.