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:
1 parent
93f0274b9e
commit
5c585bebbc
9 files changed
+349
-9
No files matched your search
@@ -197,6 +197,86 @@ bool ReflectorClient::SelectedTgIdleFilter::operator()(
|
||||
} /* ReflectorClient::SelectedTgIdleFilter::operator() */
|
||||
|
||||
|
||||
namespace {
|
||||
// Look up the earliest of (local talker start, trunk talker start) for a TG.
|
||||
// Returns true iff at least one was set. Used by EarliestMonitorTalkerFilter.
|
||||
bool startTimeForTG(uint32_t tg, struct timeval& out)
|
||||
{
|
||||
TGHandler* h = TGHandler::instance();
|
||||
struct timeval local_ts, trunk_ts;
|
||||
bool has_local = h->talkerStartTimeForTG(tg, local_ts);
|
||||
bool has_trunk = h->trunkTalkerStartTimeForTG(tg, trunk_ts);
|
||||
if (has_local && has_trunk)
|
||||
{
|
||||
out = timercmp(&local_ts, &trunk_ts, <) ? local_ts : trunk_ts;
|
||||
return true;
|
||||
}
|
||||
if (has_local)
|
||||
{
|
||||
out = local_ts;
|
||||
return true;
|
||||
}
|
||||
if (has_trunk)
|
||||
{
|
||||
out = trunk_ts;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool ReflectorClient::EarliestMonitorTalkerFilter::operator()(
|
||||
ReflectorClient* client) const
|
||||
{
|
||||
if (client->m_monitored_tgs.count(m_tg) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
struct timeval m_tg_ts;
|
||||
if (!startTimeForTG(m_tg, m_tg_ts))
|
||||
{
|
||||
// m_tg has never had a talker recorded — nothing to deliver.
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t earliest_tg = m_tg;
|
||||
struct timeval earliest_ts = m_tg_ts;
|
||||
|
||||
TGHandler* h = TGHandler::instance();
|
||||
for (uint32_t tg : client->m_monitored_tgs)
|
||||
{
|
||||
if (tg == m_tg)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bool active = (h->talkerForTG(tg) != nullptr) || h->hasTrunkTalker(tg);
|
||||
if (!active)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
struct timeval ts;
|
||||
if (!startTimeForTG(tg, ts))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool earlier = timercmp(&ts, &earliest_ts, <);
|
||||
bool same = !earlier &&
|
||||
ts.tv_sec == earliest_ts.tv_sec &&
|
||||
ts.tv_usec == earliest_ts.tv_usec;
|
||||
if (earlier || (same && tg < earliest_tg))
|
||||
{
|
||||
earliest_tg = tg;
|
||||
earliest_ts = ts;
|
||||
}
|
||||
}
|
||||
|
||||
return earliest_tg == m_tg;
|
||||
} /* ReflectorClient::EarliestMonitorTalkerFilter::operator() */
|
||||
|
||||
|
||||
ReflectorClient::ReflectorClient(Reflector *ref, Async::FramedTcpConnection *con,
|
||||
Async::Config *cfg)
|
||||
: m_con(con), m_con_state(STATE_EXPECT_PROTO_VER),
|
||||
|
||||
Reference in new issue
Block a user