Every MIDI link by wired address: flag links joined by name, hold MIDI moves them, refuse non-wired addresses

Tracks had joined NA Ingest, Lighting PC and Studio B by Bonjour name: macOS picks the network
each time, so a reconnect could land on Wi-Fi or Dante. The wired check now also names a link
joined by name; holding MIDI moves it to the wired address its own MIDI check names (a hold
only: auto-fix never moves a working link). Reconnects prefer a wired address over a Wi-Fi or
by-name one they last saw. The settings refuse a MIDI link whose address is a name or off the
wired network, and the add-a-link screen fills in the wired address. Studio B's link now has its
wired address, and Tracks' link to NA Ingest is watched (TRK INGEST). All links on the four Macs
were moved and checked: wired IPv4, running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 10:38:22 -04:00
co-authored by Claude Opus 5.5
parent 340100b5bb
commit 6ae17e5b90
7 changed files with 186 additions and 21 deletions
+11 -4
View File
@@ -168,14 +168,21 @@ def stuck_peer(sess, peer_name):
return any(p.get("name") == peer_name and p.get("state") not in LIVE_STATES for p in sess.get("peers", []))
def connect_peer(session_name, peer_name, address, settle=time.sleep):
def listed_elsewhere(sess, peer_name, address):
"""True if the peer is in the session at another address (a Bonjour name, a Wi-Fi address)."""
return any(p.get("name") == peer_name and p.get("address") != address for p in sess.get("peers", []))
def connect_peer(session_name, peer_name, address, settle=time.sleep, repoint=False):
"""Ask macOS to connect `peer_name` at `address` ("10.1.10.206:5004") to the named session,
like Audio MIDI Setup's Connect. Returns "already" (it is in the session and live), "asked",
or "kicked" (it was listed but stuck: dropped, then connected again)."""
"kicked" (it was listed but stuck: dropped, then connected again) or, with `repoint`, "moved"
(it was listed at another address - a Bonjour name, Wi-Fi - and now joins at this one)."""
with _lock:
found = [(e, s) for e, s in _session_entities()
if (s.get("dns-sd-name") or _string_prop(e, "name")) == session_name]
if found and stuck_peer(found[0][1], peer_name):
moving = bool(found and repoint and listed_elsewhere(found[0][1], peer_name, address))
if found and (moving or stuck_peer(found[0][1], peer_name)):
ent, sess = found[0]
dropped = without_peer(sess, peer_name)
with _lock:
@@ -188,7 +195,7 @@ def connect_peer(session_name, peer_name, address, settle=time.sleep):
err = _set_dict_prop(ent, "apple.midirtp.session", with_peer(dropped, peer_name, address))
if err:
raise OSError("MIDIObjectSetDictionaryProperty failed: %d" % err)
return "kicked"
return "moved" if moving else "kicked"
result = _edit_session(session_name, lambda sess: with_peer(sess, peer_name, address))
return "already" if result == "unchanged" else result