fix(reflector): restrict monitor-TG UDP audio to passive observers

A client with a non-zero selected TG must never receive UDP audio
for a monitored TG. svxlink's priority/auto-switch for monitor TGs
is driven by the TCP TalkerStart message; once svxlink decides to
switch, it sends MsgSelectTG and from then on the audio arrives via
the selected-TG arm of the fanout (TgFilter). The monitor arm is
only meaningful for passive observers (currentTG=0).

a661879 (v1.3.10) introduced the monitor arm to support passive
multi-hop monitoring, but gated it loosely. dc3a8c0 narrowed the
gate to "selected TG idle right now" — too eager, since a real
QSO has 0.5-3s inter-PTT gaps where the selected TG is talkerless.
5c585be added first-talker-wins on top, masking but not fixing
the leak. The net effect: while a user was mid-QSO on TG 9 with
TG 110 in MONITOR_TGS, TG 110 audio bled into the inter-PTT gaps
and was played by svxlink. Tragedy.

Replace SelectedTgIdleFilter with PassiveObserverFilter
(`m_current_tg == 0`) at all 9 UDP fanout sites in Reflector.cpp,
SatelliteClient.cpp, SatelliteLink.cpp, and TrunkLink.cpp.
EarliestMonitorTalkerFilter is retained — passive observers with
multiple monitor TGs still need first-talker-wins to avoid Opus
decoder mixing (test_44).

Tests:
- New test_45 pins down the contract: A select_tg=9,
  monitor_tgs=[110]; C continuously talks on 110; A receives zero
  TG 110 UDP frames. Fails on master, passes after fix.
- test_43 repurposed from "first-talker-wins for selected" (a
  property that should never have been asserted) to the
  multi-monitor variant of test_45.
- test_39/40/41/42/44 stay green by construction.

All suites: 48 trunk + 7 mqtt + 6 logging + 15 twin = 76/76.
This commit is contained in:
Audric committed 2026-05-12 16:48:52 +02:00
1 parent 5c585bebbc
commit d5860ad1dc
7 files changed
+120 -55

No files matched your search

+2 -2
View File
@@ -1164,7 +1164,7 @@ void TrunkLink::handleMsgPeerAudio(std::istream& is)
ReflectorClient::mkAndFilter(
ReflectorClient::TgMonitorFilter(local_tg),
ReflectorClient::mkAndFilter(
ReflectorClient::SelectedTgIdleFilter(),
ReflectorClient::PassiveObserverFilter(),
ReflectorClient::EarliestMonitorTalkerFilter(local_tg)))));
// Forward trunk audio to connected satellites
@@ -1206,7 +1206,7 @@ void TrunkLink::handleMsgPeerFlush(std::istream& is)
ReflectorClient::mkAndFilter(
ReflectorClient::TgMonitorFilter(local_tg),
ReflectorClient::mkAndFilter(
ReflectorClient::SelectedTgIdleFilter(),
ReflectorClient::PassiveObserverFilter(),
ReflectorClient::EarliestMonitorTalkerFilter(local_tg)))));
// Forward trunk flush to connected satellites