fix(twin): mirror inbound trunk audio across the twin link

When an external PAIRED=1 peer transmits to a twin pair, it picks a
single sticky socket per transmission and sends every frame on it. The
sticky-selected twin's TrunkLink::handleMsgPeerAudio used to broadcast
locally and to satellites but never relayed to the partner twin — so
local clients on the non-sticky twin were deaf to the audio even though
the talker state was mirrored correctly. The satellite-receive path
already had the symmetric forwarder (forwardSatelliteRawAudioToTwin);
the trunk path was just missing it.

Add Reflector::forwardTrunkAudioToTwin and forwardTrunkFlushToTwin,
modelled on the satellite variants, and invoke them from
TrunkLink::handleMsgPeerAudio and handleMsgPeerFlush after the local +
satellite broadcasts. Loop safety: TwinLink::handleMsgPeerAudio does
not re-forward to trunks, so there is no echo back to the originating
peer. Requires the external peer to use PAIRED=1 with both twin
hostnames in a single section — two independent trunk sections would
defeat the source-trunk exclusion at the external owner and cause
duplicates/echo. The docs now flag PAIRED=1 as mandatory for this
topology.

Test: test_twin.py::test_X4_paired_inbound_reaches_both_twins drives a
refa client on TG 26201 and asserts both ref1 and ref2 receive audio
frames and flush. Also rewrite test_01_twin_handshake and
test_05_twin_wiring_no_errors to read /status.twin instead of scraping
a 120s docker-logs window — the previous form flaked when the mesh had
been up long enough for boot-time log lines to scroll off.
This commit is contained in:
Audric committed 2026-05-14 19:37:44 +02:00
1 parent ef42da52de
commit 6a6cfadd95
6 files changed
+215 -35

No files matched your search

+19
View File
@@ -2855,6 +2855,25 @@ void Reflector::forwardSatelliteFlushToTwin(uint32_t tg)
} /* Reflector::forwardSatelliteFlushToTwin */
void Reflector::forwardTrunkAudioToTwin(uint32_t tg,
const std::vector<uint8_t>& audio)
{
if (m_twin_link != nullptr)
{
m_twin_link->onLocalAudio(tg, audio);
}
} /* Reflector::forwardTrunkAudioToTwin */
void Reflector::forwardTrunkFlushToTwin(uint32_t tg)
{
if (m_twin_link != nullptr)
{
m_twin_link->onLocalFlush(tg);
}
} /* Reflector::forwardTrunkFlushToTwin */
void Reflector::forwardAudioToSatellitesExcept(SatelliteLink* except,
uint32_t tg, const std::vector<uint8_t>& audio)
{