Repository navigation
Fix MIDI hot-plug device detection in separated mode - #5
Merged
Merged
Conversation
…as retry Refactor into public entry + private worker (_handle_port_appeared). - Aggregated mode: connect new hw MIDI output to mod-midi-merger:in (defense-in-depth; connect_jack_ports tolerates EEXIST). - Separated mode: retry alias lookup up to 6 times with 0.5s delay when the alias is not ready yet. - No add_hw_port in aggregated mode; graph shows merged ports only.
In aggregated mode the mod-midi-merger JACK client already owns the connection of hot-plugged hardware MIDI outputs to mod-midi-merger:in (its port-registration callback plus a bounded reconcile burst), so the mod-ui fallback was a redundant third writer of the same edge. _handle_port_appeared now ignores new ports in aggregated mode, the original upstream behavior. The separated-mode alias-lookup retry is unchanged.
sastraxi
force-pushed
the
fix/midi-aggregated-hotplug
branch
from
August 18, 2026 03:31
8d924d0 to
0d3d42d
Compare
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.
Observed problem
A USB-MIDI device connected during operation in separated mode. The device did not appear in the MIDI device list. The user had to change the MIDI mode from separated to aggregated and back to make the device appear.
Background
In separated mode, mod-ui reads the ALSA alias of each new hardware MIDI port in its port-registration callback. The alias is not always ready when the callback occurs. If the alias is empty, mod-ui discards the port. The device does not appear in the device list.
Changes
This pull request divides
jack_port_appearedinto a public entry method and a private worker method_handle_port_appeared. In separated mode, the worker reads the port alias again if the alias is not ready. The worker makes a maximum of 6 attempts, at intervals of 0.5 seconds. A device with a late alias appears in the device list.In aggregated mode, the worker ignores new ports. This is the original upstream behavior. The
mod-midi-mergerJACK client makes the connection from each hardware MIDI output tomod-midi-merger:in. The graph shows only the merged ports.Scope
The separated-mode change is necessary. The old code calls
get_jack_port_aliasone time only. If the ALSA alias is not ready when the port-registration callback occurs, the alias is empty and the device does not appear in the device list. The retry loop corrects this.The merger patch does the aggregated-mode hot-plug. See TreeFallSound/pi-gen-pistomp#44. The merger connects each unconnected physical MIDI port after a port-registration event. Thus mod-ui does not need an alternative path.
Necessary version of mod-host
The aggregated-mode part of this change needs
mod-host-pistomp0.10.6-6 or a later version. Versions before 0.10.6-6 were built withoutHAVE_JACK2. mod-host then does not loadmod-midi-mergeras a JACK internal client, and aggregated mode has no merged stream.This pull request alone does not cause a fault with an earlier mod-host. Aggregated mode keeps the original upstream behavior. But aggregated-mode hot-plug is correct only when this pull request, pi-gen-pistomp#44, and mod-host 0.10.6-6 are all installed.
Related pull requests
This pull request was divided into parts:
#6 has this pull request as its base. Change the base of #6 to
mainwhen this pull request is merged.A third part, #7, is closed. It is not tested against a known failure. The branch stays in the repository.