On Sep 27, 2009, at 12:43 AM, Troy Watson wrote:
Is there a method to detect if the frame sent to mad_synth_frame is the last frame in the stream, without knowing in advance how many frames the input stream has? I am using libsamplerate and it requires the last block of audio data for a stream to set an end_of_input flag. Checking the EOF indicator for the input file is insufficient as that only informs me when the file has been fully buffered, not when the last frame has been synthesized. Any ideas or suggestions?
You may need to decode the next frame before you output the previously synth'ed one to be absolutely sure.
Keep in mind that when mad_frame_decode() (or mad_header_decode()) returns -1 and stream->error is MAD_ERROR_BUFLEN, and you are at EOF, there may be one last frame you can decode by appending MAD_BUFFER_GUARD zero bytes at the end of the buffer, but not necessarily.