Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop() no longer calls midiOutReset #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dwmuller
Copy link

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
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
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