Skip to content

Commit 5aa808a

Browse files
committed
fix: handle track cleanups
1 parent 920767a commit 5aa808a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pulsebeam/src/participant/downstream/video.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,21 @@ impl VideoAllocator {
4949
}
5050

5151
pub fn remove_track(&mut self, track_id: &Arc<TrackId>) {
52-
if self.tracks.remove(track_id).is_some() {
52+
if let Some(track) = self.tracks.remove(track_id) {
5353
tracing::info!(
5454
track = %track_id,
5555
"video track removed"
5656
);
57+
58+
let Some(assigned_mid) = track.assigned_mid else {
59+
return;
60+
};
61+
62+
let Some(slot) = self.slots.iter_mut().find(|s| s.mid == assigned_mid) else {
63+
return;
64+
};
65+
66+
slot.stop();
5767
self.rebalance();
5868
}
5969
}

pulsebeam/src/room.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ impl actor::Actor<RoomMessageSet> for RoomActor {
122122
if let Some(participant_handle) = self.state.participants.get_mut(&participant_id) {
123123
// if it's closed, then the participant has exited
124124
let _ = participant_handle.handle.terminate().await;
125+
self.handle_participant_left(participant_id).await;
125126
}
126127
}
127128
RoomMessage::PublishTrack(track_handle) => {

0 commit comments

Comments
 (0)