Free the pad's ALSA clients when the Private port is missing.

On Bluetooth there is no Private port, so every Sound or Threshold press
opened two sequencer clients to light the lamps and left them open when the
port lookup raised. After 29 presses the sequencer was full and aconnect
could no longer open it. set_sound_lamps and Link now close both clients
on that path too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-10-23 00:49:25 +13:00
1 parent 9c1ef6f2d4
commit f8c8cea3ef
2 files changed
+15 -9

No files matched your search

+9 -5
View File
@@ -96,11 +96,15 @@ class Link:
rtmidi = load_rtmidi()
self.midiout = rtmidi.MidiOut(rtapi=rtmidi.API_LINUX_ALSA)
self.midiin = rtmidi.MidiIn(rtapi=rtmidi.API_LINUX_ALSA)
self.name = private_port(self.midiout.get_ports())
index = self.midiout.get_ports().index(self.name)
self.midiin.open_port(index)
self.midiin.ignore_types(sysex=False, timing=True, active_sense=True)
self.midiout.open_port(index)
try:
self.name = private_port(self.midiout.get_ports())
index = self.midiout.get_ports().index(self.name)
self.midiin.open_port(index)
self.midiin.ignore_types(sysex=False, timing=True, active_sense=True)
self.midiout.open_port(index)
except BaseException:
self.close()
raise
def close(self) -> None:
for port in (self.midiout, self.midiin):