Skip to content

drop() no longer calls midiOutReset#123

Open
dwmuller wants to merge 1 commit into
Boddlnagg:masterfrom
dwmuller:dwmuller/issue122
Open

drop() no longer calls midiOutReset#123
dwmuller wants to merge 1 commit into
Boddlnagg:masterfrom
dwmuller:dwmuller/issue122

Conversation

@dwmuller

Copy link
Copy Markdown

Fixes #122

On Windows using the winmm backend, midiOutReset was being called before midiOutClose, presumably to cancel any pending output. This caused extra MIDI commands to be sent. Instead, we now call midiOutClose repeatedly until it's no longer blocked by pending output.

Tested it in a very simple application, monitoring MIDI activity using "BC Manager", which is also how I verified the original problem. No extraneous MIDI is being sent now.

Fixes Boddlnagg#122

On Windows, midiOutReset was being called before midiOutClose,
presumably to cancel any pending output. This caused extra MIDI
commands to be sent. Instead, we now call midiOutClose repeatedly
until it's no longer blocked by pending output.
@dwmuller

Copy link
Copy Markdown
Author

FWIW, I also tried my app with midir's winrt backend. Works fine, and does not suffer the same problem that I saw with winmm. Although the MIDI port names are different in RT vs MM. The names that WinMM sees are more reasonable.

@Boddlnagg

Copy link
Copy Markdown
Owner

Thanks for the PR (and sorry that it took me so long to respond)! It looks good to me, except for the potential endless loop ... is there any guarantee that midiOutClose will not return MIDIERR_STILLPLAYING "forever"?.
I would feel more comfortable with a solution that retries midiOutClose maybe once or twice and eventually falls back to midiOutReset, since midiOutReset is even explicitly mentioned on the documentation for midiOutClose.
Could you try if that alternative would also work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MidiOutputConnection.drop() produces unwanted output on Windows?

2 participants