fix(reflector): first-talker-wins arbitration for multi-monitor TGs

dc3a8c0's SelectedTgIdleFilter closed the v1.3.10 mixing window only
when the listener's selected TG was busy. When the selected TG is
idle (or 0) and >=2 monitor TGs have simultaneous talkers, the filter
let every frame through and the single Opus decoder mixed them --
a configuration MONITOR_TGS=1++,9+,110,112 hits this whenever 110 and 112
overlap, since svxlink's priority logic stays on the prio-1 TG 9.

TGHandler now records a per-TG talker-start timestamp (local + trunk),
retained across talker-clear so the flush-fanout filter can still
identify the freshly-stopped TG. ReflectorClient gains
EarliestMonitorTalkerFilter(tg): returns true iff tg is the earliest-
started TG (local OR trunk) among the client's monitored set; ties
broken by smaller TG id. Wired alongside the existing
SelectedTgIdleFilter at all nine UDP fanout sites. The selected-TG
arm of the OR is untouched, so svxlink priority and the pre-v1.3.10
single-TG-at-a-time invariant both keep working.

Adds test_43 (selected idle + two simultaneous monitor talkers ->
only earliest delivered) and test_44 (same, passive observer).
test_39 and test_40-42 remain green; full test_trunk.py: 47/47.
This commit is contained in:
Audric committed 2026-05-11 11:51:47 +02:00
1 parent 93f0274b9e
commit 5c585bebbc
9 files changed
+349 -9

No files matched your search

+9 -3
View File
@@ -1413,7 +1413,9 @@ void Reflector::udpDatagramReceived(const IpAddress& addr, uint16_t port,
ReflectorClient::TgFilter(tg),
ReflectorClient::mkAndFilter(
ReflectorClient::TgMonitorFilter(tg),
ReflectorClient::SelectedTgIdleFilter()))));
ReflectorClient::mkAndFilter(
ReflectorClient::SelectedTgIdleFilter(),
ReflectorClient::EarliestMonitorTalkerFilter(tg))))));
if (m_is_satellite && m_satellite_client != nullptr)
{
m_satellite_client->onLocalAudio(tg, msg.audioData());
@@ -1581,7 +1583,9 @@ void Reflector::onTalkerUpdated(uint32_t tg, ReflectorClient* old_talker,
ReflectorClient::TgFilter(tg),
ReflectorClient::mkAndFilter(
ReflectorClient::TgMonitorFilter(tg),
ReflectorClient::SelectedTgIdleFilter())),
ReflectorClient::mkAndFilter(
ReflectorClient::SelectedTgIdleFilter(),
ReflectorClient::EarliestMonitorTalkerFilter(tg)))),
ReflectorClient::ExceptFilter(old_talker)));
if (m_mqtt != nullptr)
{
@@ -2898,7 +2902,9 @@ void Reflector::onTrunkTalkerUpdated(uint32_t tg,
ReflectorClient::TgFilter(tg),
ReflectorClient::mkAndFilter(
ReflectorClient::TgMonitorFilter(tg),
ReflectorClient::SelectedTgIdleFilter())));
ReflectorClient::mkAndFilter(
ReflectorClient::SelectedTgIdleFilter(),
ReflectorClient::EarliestMonitorTalkerFilter(tg)))));
if (m_mqtt != nullptr)
{
m_mqtt->onPeerTalkerStop(peer_id, tg, old_cs);