shithub: choc

Download patch

ref: dde9b2c1bf6184d7d525ebbf52485549f31196ba
parent: d34a98b434ccccf5bedbd799ec003551f34707d8
author: Roman Fomin <rfomin@gmail.com>
date: Thu Dec 29 15:51:21 EST 2022

win midi: Prevent rare `midiOutUnprepareHeader()` fail (#1564)

Fix by ceski.

--- a/src/i_winmusic.c
+++ b/src/i_winmusic.c
@@ -1460,6 +1460,10 @@
 
     if (buffer.data)
     {
+        // Windows doesn't always immediately clear the MHDR_INQUEUE flag, even
+        // after midiStreamStop() is called. There doesn't seem to be any side
+        // effect to just forcing the flag off.
+        MidiStreamHdr.dwFlags &= ~MHDR_INQUEUE;
         mmr = midiOutUnprepareHeader((HMIDIOUT)hMidiStream, &MidiStreamHdr,
                                      sizeof(MIDIHDR));
         if (mmr != MMSYSERR_NOERROR)