From 3a63b07149fd36308d72378c66b53c41574abb1e Mon Sep 17 00:00:00 2001 From: Colin Marc Date: Tue, 30 Apr 2024 18:44:58 +0200 Subject: [PATCH] fix(mmclient): handle AudioChunk messages on the attachment stream --- mm-client/src/bin/mmclient.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mm-client/src/bin/mmclient.rs b/mm-client/src/bin/mmclient.rs index 77ddd79..d46997f 100644 --- a/mm-client/src/bin/mmclient.rs +++ b/mm-client/src/bin/mmclient.rs @@ -508,6 +508,25 @@ impl App { self.video_stream.recv_chunk(chunk)?; } + AppEvent::StreamMessage(_, protocol::MessageType::AudioChunk(chunk)) + | AppEvent::Datagram(protocol::MessageType::AudioChunk(chunk)) => { + // Detect stream restarts. + if let Some(attachment) = &self.attachment { + if chunk.attachment_id == attachment.attachment_id + && (self.audio_stream_seq.is_none() + || chunk.stream_seq > self.audio_stream_seq.unwrap()) + { + self.audio_stream_seq = Some(chunk.stream_seq); + self.audio_stream.reset( + chunk.stream_seq, + attachment.sample_rate_hz, + attachment.channels.as_ref().unwrap().channels.len() as u32, + )?; + } + } + + self.audio_stream.recv_chunk(chunk)?; + } AppEvent::ConnectionClosed => { bail!("connection closed unexpectedly") }