Re: MAD_ERROR_BADHUFFDATA before MAD_ERROR_BUFLEN

Rob Leslie <[email protected]> Tue, 22 May 2007 12:56:58 -0700
Newsgroups gmane.comp.audio.mad.devel
Message-ID <[email protected]>
> 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.

I just realized that your mpeg_buffer is on the stack. MAD doesn't  
copy this buffer; it keeps pointers to it. Unless you're decoding the  
entire file in one go, this is very likely a source of corruption and  
consequent decoding errors.

Try moving line 5 outside the function, to file scope.

-- 
Rob Leslie
[email protected]