MIDI inputs list with per-source switches; reconnect dead virtual sources (v0.29.0)

- Setup -> MIDI Sync lists every MIDI source that can send to Sizzle with a
  switch and its state (Listening / Not connected / Off) plus Reconnect.
  Off-choices persist by a stable MidiSourceKey (Android ids change).
- When the app behind a virtual source dies/restarts, Android keeps the
  device and our connection, drops the service binding and sends no callback,
  so Sizzle went deaf to e.g. a restarted Mikro Seq. A worker thread now
  probes open virtual sources every 3 s (openOutputPort is null from a dead
  server) and reopens dead ones; resume re-scans; zero-open port status is
  also treated as dead.
- Verified on an Android 15 emulator: force-stop + restart Mikro Seq ->
  reconnected within ~3 s, notes flowing with both apps in background.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-12 22:32:04 +01:00
co-authored by Claude Opus 5.5
parent fb9a219e27
commit df64af8c9b
12 changed files with 424 additions and 29 deletions
@@ -0,0 +1,49 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
package cc.tiredsysadmin.android.sizzle.input
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
import org.junit.Test
class MidiSourceKeyTest {
private val mikroSeq = MidiSourceKey.of(
2, "tiredsysadmin", "Mikro Seq", null,
"cc.tiredsysadmin.android.mikroseq/cc.tiredsysadmin.android.mikroseq.SeqMidiService", null,
)
@Test fun sameDeviceSameKeyRegardlessOfAndroidId() {
val again = MidiSourceKey.of(
2, "tiredsysadmin", "Mikro Seq", null,
"cc.tiredsysadmin.android.mikroseq/cc.tiredsysadmin.android.mikroseq.SeqMidiService", null,
)
assertEquals(mikroSeq, again)
}
@Test fun differentDevicesDiffer() {
val usb = MidiSourceKey.of(1, "Android", "USB Peripheral Port", "Android USB Peripheral Port", null, null)
val sunvox = MidiSourceKey.of(2, "NightRadio", "SunVox", null, "nightradio.sunvox/x.MidiService", null)
assertNotEquals(mikroSeq, usb)
assertNotEquals(mikroSeq, sunvox)
val bt1 = MidiSourceKey.of(3, null, null, "WIDI", null, "AA:BB")
val bt2 = MidiSourceKey.of(3, null, null, "WIDI", null, "AA:CC")
assertNotEquals(bt1, bt2)
}
@Test fun separatorInsideAFieldCannotForgeAnotherKey() {
assertNotEquals(
MidiSourceKey.of(1, "a|b", null, null, null, null),
MidiSourceKey.of(1, "a", "b", null, null, null),
)
}
@Test fun displayNamePrefersNameThenProductThenMaker() {
assertEquals("Android USB Peripheral Port",
MidiSourceKey.displayName("Android", "USB Peripheral Port", "Android USB Peripheral Port"))
assertEquals("Mikro Seq", MidiSourceKey.displayName("tiredsysadmin", "Mikro Seq", null))
assertEquals("tiredsysadmin", MidiSourceKey.displayName("tiredsysadmin", " ", ""))
assertEquals("MIDI device", MidiSourceKey.displayName(null, null, null))
}
}