Three reliability fixes. Wire format and audio pipeline unchanged from
v1.4 / v1.5 — all interoperate.
Peer address recovery:
* When a tracked peer goes Unreachable (its resolved address — often a
stale DNS / Pi-hole record, or a peer that rebooted onto a new IP) but
the same peer is still heartbeat-pinging us from a different address,
RemSound now adopts the live address instead of transmitting to a dead
one. HeartbeatService records untracked ping sources; MainForm's
TryAdoptLiveHeartbeatAddress (1 Hz) re-points the sender, heartbeat
tracking and receiver allow-list. Conservative: fires only on the
unambiguous one-unreachable-and-one-source case, private-range (RFC1918)
addresses only so a relay can't hijack the sender, 10 s cooldown.
Reconnect crash:
* Fixed IndexOutOfRangeException in MainForm.SyncConnectedList. A churny
peer-list rebuild (peer reboot) left SelectedIndex pointing past the
rebuilt item array; the 1 Hz status timer read SelectedItem and crashed
the app. New SafeSelectedItem bounds-checks the index; applied to all
three timer-driven sync methods. The status tick is also wrapped in
try/catch so a transient WinForms hiccup logs instead of crashing.
Long-run memory / CPU leak:
* A receiver left running for hours grew to gigabytes and climbing CPU.
Decoder sessions orphaned by peer reconnects were not reaped — every
reconnect mints a fresh (endpoint, streamId) key, and PruneIdleSessions
silently skipped sessions whose PlayoutEngine lookup missed. Rewrote it
to reap on each session's own LastWriteUtc (no cross-dictionary lookup),
added a hard MaxLiveSessions cap as a backstop, and a "stream sessions
live: N" diagnostic line. Bounds both memory and render-thread CPU.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>