diff --git a/src/webrtc/universal_session.rs b/src/webrtc/universal_session.rs index 2cf41c57..eed763d5 100644 --- a/src/webrtc/universal_session.rs +++ b/src/webrtc/universal_session.rs @@ -674,7 +674,13 @@ impl UniversalSession { ); }); - *self.video_receiver_handle.lock().await = Some(handle); + { + let mut guard = self.video_receiver_handle.lock().await; + if let Some(old) = guard.take() { + old.abort(); + } + *guard = Some(handle); + } } pub async fn start_audio_from_opus( @@ -761,7 +767,13 @@ impl UniversalSession { ); }); - *self.audio_receiver_handle.lock().await = Some(handle); + { + let mut guard = self.audio_receiver_handle.lock().await; + if let Some(old) = guard.take() { + old.abort(); + } + *guard = Some(handle); + } } pub fn has_audio(&self) -> bool {