Skip to content

Commit

Permalink
fix(mmclient): handle AudioChunk messages on the attachment stream
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmarc committed Apr 30, 2024
1 parent 75f409d commit 3a63b07
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions mm-client/src/bin/mmclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit 3a63b07

Please sign in to comment.