I answered this in private email: I think the problem is that you are refilling your stream buffer without copying the unconsumed data from the end of the previous buffer.
Right on the money -- I changed the code to accomodate, and it seems to be working now. I actually pre-fetch blocks of mp3 into buffers via a seperate thread, so copying them around wouldn't work -- Instead, I have the buffers overlap by 2880+MAD_BUFFER_GUARD bytes. Works like a charm.
So, now, it actually gets through the entire MP3 before it dies. However, it still sounds like shit. It makes a clicking/swooshing sound at about 4Hz, but you can clearly hear the audio in the background. Could this be a result of the simplified scale() function in minimad (which I'm currently using?) Here are all the specs I have to go on for the rio's audio device (from some source code) :
// Must output buffers of 4608 bytes or audio driver barfs. // Sample rate is always 44.1k, format always 16-bit stereo, alternating // left/right samples.
and this is the contents of /proc/audio
buffers : 32 buf size : 4608 samples : 27767808 interrupts: 0 wakeups : 0 fifo errs : 0 buffer hwm: 31 first fill: 1 below half: 18
Thanks, Reza