I'm having trouble creating the equivalent of minimad.c, except without loading the whole file into memory. In fact, now that I have added in the error callback I seem to be having trouble doing anything at all.
Without the callback the pcm outputed has errors at the end of each BUF_SIZE chunck read in from the file. With the callback function (taken almost literally from minimad.c) the program ends on a sync. error (101) within the first frame.
I've been double checking and trying slightly different versions of the same thing -- but I can't make any progress. I've attached the program, any pointers?
Thanks verily, Adam Luter
Hi Adam,
I'm having trouble creating the equivalent of minimad.c, except without loading the whole file into memory. In fact, now that I have added in the error callback I seem to be having trouble doing anything at all.
Without the callback the pcm outputed has errors at the end of each BUF_SIZE chunck read in from the file. With the callback function (taken almost literally from minimad.c) the program ends on a sync. error (101) within the first frame.
Your input buffer is on the stack, and is invalid as soon as your input callback returns. The buffer you pass to mad_stream_buffer() must survive until the next call to this function, or until you stop decoding.
For a simple fix, try making your data buffer 'static'.
Cheers,
On Mon, May 05, 2003 at 12:34:44PM -0700, Rob Leslie wrote:
Hi Adam,
I'm having trouble creating the equivalent of minimad.c, except without loading the whole file into memory. In fact, now that I have added in the error callback I seem to be having trouble doing anything at all.
Without the callback the pcm outputed has errors at the end of each BUF_SIZE chunck read in from the file. With the callback function (taken almost literally from minimad.c) the program ends on a sync. error (101) within the first frame.
Your input buffer is on the stack, and is invalid as soon as your input callback returns. The buffer you pass to mad_stream_buffer() must survive until the next call to this function, or until you stop decoding.
For a simple fix, try making your data buffer 'static'.
Oh dear, you're correct. Thanks that cleared it right up. But I've already switched to mmap since my final program won't need to do standard in (efficiently). I appreciate the help -- I guess Perl does rot the brain! :)
-Adam Luter