http://bugs.winehq.org/show_bug.cgi?id=29531
--- Comment #10 from Jörg Höhle hoehle@users.sourceforge.net 2012-03-09 04:56:58 CST --- Created attachment 39263 --> http://bugs.winehq.org/attachment.cgi?id=39263 lock-free winealsa renderer
The sketch of the lock-less design is as follows.
Here's an implementation. It requires the fix #2 from bug #30071 such that IAC_Reset cannot be executed while the callback is running.
I'd appreciate if somebody with a multi-core machine would test it. A mmdevapi render test loop ran fine while recompiling Wine and starting Firefox. I don't consider lock-less to be a silver bullet. If Linux decides to let other threads run for 100ms, an underrun will occur. Lock-less simply means less contention, giving Linux less reasons to schedule another thread. Also, ALSA may use locks or a mutex internally, so our renderer calling snd_pcm_write while the mmdevapi app calls IAC_GetPosition => snd_pcm_avail&delay still causes a contention. We can be happy that IAC_GetCurrentPadding avoids going through ALSA.