After trying to implement the alsa mixer I came across a problem: If winmm is unloading, a deadlock could occur if during unloading it's waiting for another thread.
In winmm itself this isn't much of a problem: there aren't any threads.
However, the drivers used by winmm may have threads, and if the application doesn't shut down their drivers properly, it could be possible that a deadlock occurs when the drivers unload because winmm unloads.
For that reason I propose to add a flag that's passed to the sound drivers that signals a shutdown in DLL_DETACH context, so that drivers can choose to call TerminateThread instead of waiting tidily for the thread to finish running.
It's not pretty, but I don't see another way how to make sure that deadlocks won't occur when unloading winmm. I'm open for other suggestions though.
Maarten