OSS (at least Alsa's OSS emulation) seems to include a huge buffer on itself. "Write - Get next audio data - Write" works.
Not entirely with Alsa; not at all with MME. 

I need better data flow. Now:

administration
ask for data from inputs
wait for them
do the mixing; write data to outbut buffers
ask outputs to do playback
wait for them

better:

administration
ask for data from inputs
wait for them
do the mixing; write data to outbut buffers B
wait until output buffers A are done
ask outputs to do playback with buffer B
switch A / B

Question is who does the double buffering - the output itself or the mixer?
For performance I'd prefer the output... Also, not all output need this (file writer).

But this calls for multithreading outputs... Especially with MME the waveOutWrite seems to correlate very tightly with the actual playback.

Let's test it on Alsa:

Create one thread that gets signalled by play() and sets a local semaphore if it has done writing (play() waits for this semaphore).


Not forget: The administration stage is within the playback zone now!


*** Saturday, the 19th of November 2005... a dark living room ***

After mainly duplicating the double-buffering code of Alsa for MME, I realized two things:

1. I should write this code _once_ in the genreic output device class
2. The semaphore stuff for the output in mixer is senseless when the outputs do this on their own.

Face it. Code it.


*** One day later ***

Coded generic multithreaded double-buffering for all outputs... and it's worse than before. Even OSS has stuttering on some mixer action.

Of course big buffers solve this; but there is a limit (p.ex. in Alsa output - or should I decouple the Alsa buffer from the output device buffer?).

Somehow the process of the real output action being parallel to any other action (administration and inputs) makes things worse on my laptop. Looks like thread switching and scheduling (the outdated linuxthreads implementation in my glibc?) kill the fun.

Some hours later: Hm, after fixing some glitches, the playback feels better. Hm. Hm.
