Using the high level API. In the error callback if MAD_RECOVERABLE(stream->error) returns true how do I deal with the error? Do I just report the error and return MAD_FLOW_CONTINUE? Will madlib recover the error itself or do I have to fix the error before resuming?
On Tuesday, May 14, 2002, at 03:23 AM, Thomas Rathbone wrote:
Using the high level API. In the error callback if MAD_RECOVERABLE(stream->error) returns true how do I deal with the error? Do I just report the error and return MAD_FLOW_CONTINUE? Will madlib recover the error itself or do I have to fix the error before resuming?
When using the high-level API, the error callback is called when a decoding error occurs ONLY if MAD_RECOVERABLE(stream->error) is true. You need not perform any specific action; usually the only thing you may want to do is report the error. The value you return determines what the decoder does next:
MAD_FLOW_STOP: The decoder ends its decoding loop and returns normally.
MAD_FLOW_BREAK: The decoder ends its decoding loop and returns abnormally.
MAD_FLOW_IGNORE: As long as the frame's header was successfully decoded, the decoder ignores the error and proceeds with the filter callback and synthesis. In this case you should arrange to have the desired subband samples for synthesis in the frame structure, for example, by leaving the previous frame's samples, or by muting the samples by calling mad_frame_mute().
MAD_FLOW_CONTINUE: The decoder proceeds to the next frame, skipping the frame which caused the error.
If you don't specify an error callback (by passing a null pointer), the default action is as follows: If the error is MAD_ERROR_BADCRC, then either leave the previous frame's subband samples in the frame, or mute the frame if the previous frame had the same error, and then ignore the error (proceeding with the filter callback and synthesis). In the case of any other error, skip the frame and proceed with the next frame.
The errors which are not recoverable include:
MAD_ERROR_BUFLEN - stream buffer needs refilling MAD_ERROR_BUFPTR - invalid buffer pointer MAD_ERROR_NOMEM - required memory could not be allocated
In these cases the high-level decoder will either call your input callback to refill the stream buffer, or terminate with an error.
-- Rob Leslie rob@mars.org