I am being severely confused by something.
I need my program to play audio normally during normal gameplay.
But I also might be recording the video and audio, if it's playing back a demo and recording it.
SDL only ever uses the 'pull' model, where the sound driver uses a separate thread and calls a callback function in your program when it's ready for data.
But this means it only generates audio in realtime. So if I'm recording a demo and I generate 50 video frames over, say 2 seconds, then it will generate 2 seconds of audio. But I'm going to play back the video at 50 FPS.... and the audio will be completely wrong.
I'm technically using SDL_mixer, which is a very thin layer over SDL's builtin audio, so it also uses pull-style.
I need to somehow push exactly 20 milliseconds of audio every frame while I'm recording. (during normal play and demo recording, I can use pull, it's not a big deal, it will sound better in realtime) So I'll have to do a lot of _something_ and either write my own audio mixer or modify SDL_mixer so my program activates the callback somehow. I'll have to set up a stream myself, pretend to be the soundcard, and ask it for exactly 20 ms of audio every frame.
Probably will just write my own mixer, since I already almost have one. It's like a crappy prototype I wrote once.
*sigh* audio.