webmidi: do not call an observer callback that was not set - #259
Merged
Merged
Conversation
Every other backend checks first; the browser one did not, so an observer watching only inputs threw std::bad_function_call as soon as an output port showed up. Also fixes the emscripten guard of midi1::default_api(), which never matched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SCvayD61okH7PATstw4whi
stop_stream() passes one argument and read it as $1, so closing a Web MIDI input threw a TypeError out of the destructor and aborted the program. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SCvayD61okH7PATstw4whi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
observer_emscripten::update()callsconfiguration.input_addedandconfiguration.output_addedunconditionally. Every other backend guards them(
alsa_seq/observer.hpp:272, and the rest), so an observer that only wantsinputs works everywhere except in a browser, where it throws
std::bad_function_callas soon as Web MIDI reports an output port.Found from ossia score's device enumerator, which installs one observer per
direction: adding a MIDI input device in the web build aborted.
Also:
midi1::default_api()guarded its branch on__emscripten__, which isnever defined — the macro is
__EMSCRIPTEN__— so wasm fell through toAPI::DUMMY. The branch also namedAPI::EMSCRIPTEN_WEBMIDI, which does notexist in the enum; it is
API::WEBMIDI, asobserver_emscripten::get_current_api()already returns.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SCvayD61okH7PATstw4whi