Drop the media that comes back on our own slot

A session that loops our voice back (the fake host of the protocol
repository does, so that a test sees media move) made the engine hand our
own packets to the audio thread and show us as talking: the slot map holds
every participant of the server, ourselves included. The engine never plays
itself from the network (a sidetone is local), so on_media returns for the
packets of the slot the host gave us. TeamSpeak never sends a client its own
voice, so nothing changes for the servers the engine reaches today.

Found by the fake-host tests; the test failed before this change with
[1, 50] as the talkers heard (us, then alice).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-24 01:16:51 +03:00
1 parent 82da64d8d3
commit 8d07502e1e
2 files changed
+29 -2

No files matched your search

+23 -2
View File
@@ -95,7 +95,8 @@ struct HostRig {
handle: FakeHandle,
cmds: mpsc::UnboundedSender<LinkCmd>,
events: mpsc::UnboundedReceiver<LinkEvent>,
/// Our voice slot, as the host gave it.
/// Our participant and voice slot, as the host gave them.
own_client: u16,
own_slot: u32,
/// The clients the link told started talking, in order.
talking: Vec<u16>,
@@ -143,7 +144,7 @@ impl HostRig {
})
.expect("the host seated us in voice");
let handle = connector.last_session().expect("the connector made a session");
Self { handle, cmds, events, own_slot, talking: Vec::new() }
Self { handle, cmds, events, own_client, own_slot, talking: Vec::new() }
}
/// The next voice packet the audio thread would get; who started to talk on
@@ -266,6 +267,26 @@ async fn the_voice_of_other_slots_reaches_the_audio_thread() {
assert_eq!(rig.talking, [ALICE as u16, BOB as u16]);
}
/// A host whose session loops our own voice back (the fake one does, so that
/// the conformance suite can see media move) does not make the engine play us
/// our own voice or show us as talking: the engine never plays itself.
#[tokio::test(flavor = "multi_thread")]
async fn our_own_voice_coming_back_is_not_played_back() {
let mut rig = HostRig::connect().await;
// The fake host loops accepted media back into the sink (the default).
rig.give(LinkCmd::Audio(voice(&MONO)));
let handle = rig.handle.clone();
eventually(WAIT, "the packet to leave", || handle.sent_media().len() == 1).await;
// A packet of alice behind it: when this one is out, ours has been through.
handle.inject_media(voice_packet(ALICE_SLOT, voice_sub::CHANNEL, 1, &MONO));
let own = rig.own_client;
let mut heard = Vec::new();
while heard.last().is_none_or(|talker| *talker != ALICE as u16) {
heard.push(rig.audio().await.talker.0);
}
assert!(!heard.contains(&own), "the engine played our own voice back: {heard:?}");
}
/// The link conformance suite of the protocol repository against the session
/// the engine's registry hands over: the registry adds nothing to a plain
/// connector's session (`Backends::connect` returns it untouched), so the 17
@@ -935,6 +935,12 @@ impl Conn {
async fn on_media(&mut self, packet: &MediaPacket) {
let Some(incoming) = Incoming::parse(packet) else { return };
// Our own voice, if the session loops it back (the fake host of the
// protocol repository does, so that a test sees media move): the engine
// neither plays us to ourselves nor shows us as talking.
if incoming.slot == self.slot {
return;
}
if !self.slots.contains_key(&incoming.slot) {
// The push that tells who has this slot may be on its way: media and
// pushes travel apart.