In a nutt shell, the audio portion of the example code was a little distracting from learning how to use libtheora properly. The audio video synchronization mechanism was quite horrendous to follow. And quite frankly, the audio handler didn't work at all on my platform.
SDL's audio library is pretty rock solid. Just a little side note on how SDL_audio does things (with streaming data): Instead of buffering the audio data and then writting to the device when you want to, SDL_audio uses a callback function, provides you with a buffer location and it's size for you to fill in.
In other words, for SDL_audio, read, decode and write the audio data when they ask for it. Accumulating the size of the samples read-in, then provides the same data to synchronize the audio and video streams. I threw out all of "calibration/timing" and "audiobuf_ready/videobuf_ready" code and just used the accumulated value against the video's current time from:
th_granule_time();This streamlined a lot of the code.
The modifications should be close to a drop in replacement. The intention was to keep the code as close to the current examples already in place to maintain its original purpose as a learning resource. So, there are no additional error checks, globals are kept where they are and most of the original lines of code are there (they may have been moved around though). Only the audio code and synchronization mechanism have been surgically replaced. =)
I thought about also posting a cleaned up version with no globals (for true re-entrant function usage) and move lines of code into well defined functions. But, there are examples of these already online by some fine random folks for both C and C++ versions.