https://bugs.winehq.org/show_bug.cgi?id=3930
--- Comment #82 from Damjan Jovanovic damjan.jov@gmail.com --- (In reply to Dmitry Timoshkov from comment #81)
(In reply to Damjan Jovanovic from comment #80)
In other words, Windows probably checks something like "if emulating Windows 9x and the WINMM callback is located in a file called WAIL32.DLL", then it runs the callback in a separate thread. (I say that because Windows does not use a separate callback thread when you set Windows 95 compatibility and call waveOutOpen() directly, but does use it when WAIL32.DLL calls it.)
So that's why HOMM works on recent Windows versions, but doesn't work on Wine: Windows has application-specific workarounds :-(.
What happens if you rename WAIL32.DLL to something else?
With Windows 95 compatibility set, Windows successfully avoids the deadlock in my test regardless of the WAIL DLL name.
Either Windows detects the WAIL DLL some other way (DLL checksum, some resource string, presence of SuspendThread in the DLL's import table, etc.), or I missed something and WINMM behaves differently based on some parameter that differs between WAIL's waveOutOpen() call and my direct waveOutOpen() call.