On Monday 21 of May 2007 03:04:46 Rob Leslie wrote:
You should not inspect this->int_stream.error (at line 35) unless mad_decode_frame() returns -1, because this field is not otherwise reset. I suspect you may be loading new data each time through the loop, until another decoding error occurs as a consequence.
If I understand your advise correctly, you are saying that I should move code reading new data (lines 35-73) right after MAD_ERROR_BUFLEN detections to line 97? I tried that but result is the same. Moreover reading code is executed first time due fullfilled condition this->int_stream.buffer == NULL and it resets this->int_stream.error to MAD_ERROR_NONE at line 72 each time so next evocation of this code would be due previous MAD_ERROR_BUFLEN and it should be called only once for each MAD_ERROR_BUFLEN error.
The only thing I know about problem is that MAD_ERROR_BADHUFFDATA or any other errors are returned before MAD_ERROR_BUFLEN and this seems like MAD won't recognize that it hasn't complete frame at the end of buffered data, tries to decode it with these errors and then returns MAD_ERROR_BUFLEN. Then after passing new block of data is first frame in buffer of course incomplete too and MAD gets unsynchronized with errors.