How to do use an audio stream
I need help understanding the new audio stream system so I can implement a synth in my game. In Allegro 4 I remember you gave the audio stream a callback and it would just work in the background. Now things seem to be based on the event system. I imagine this could become an issue when executing intensive things like the rendering phase. Are you meant to answer the fragment events in a separate thread?
I don't think A4 had a callback: http://liballeg.org/stabledocs/en/alleg028.html
You would just busy wait calling the stream function over and over - this was the time of DOS before there could be multiple processes competing for CPU (and before CPUs had a feature which allowed them to idle)
I don't think rendering should be an issue. Waiting for vsync can take up to 1/60th of a second (16.6 ms), that should be small enough to not notice audio delay. Actual rendering in Allegro games should be a factor 10 to 100 faster than that so I'd say the rendering itself is never an issue.
Still, I don't see anything that would speak against using a separate thread either - then you can fill audio data even while the main thread waits on vsync in al_flip_display().
Thread #616880. Printed from Allegro.cc
I could have sworn it was a callback in A4. Maybe I was using another library for sound. I discovered the post-process callback; I get a nice stable stream free from pops or clicks so this will work. Not sure if this means the thread is done, but I'm glad it's there.