Skip to content

Commit

Permalink
src: stream: sink: Fix lock during WebRTCSink's unlink
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoantoniocardoso committed Apr 14, 2024
1 parent 609cb80 commit c84c5d7
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/stream/sink/webrtc_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,13 @@ impl SinkInterface for WebRTCSink {
warn!("Failed removing WebRTCBin's elements from pipeline: {remove_err:?}");
}

// Set Queue to null
if let Err(state_err) = self.queue.set_state(gst::State::Null) {
warn!("Failed to set Queue's state to NULL: {state_err:#?}");
}

// Set Sink to null
if let Err(state_err) = self.webrtcbin.set_state(gst::State::Null) {
warn!("Failed to set WebRTCBin's to NULL: {state_err:#?}");
}
// Instead of setting each element individually to null, we are using a temporary
// pipeline so we can post and EOS and set the state of the elements to null
// It is important to send EOS to the queue, otherwise it can hang when setting its state to null.
let pipeline = gst::Pipeline::new();
pipeline.add_many(elements).unwrap();
pipeline.post_message(::gst::message::Eos::new()).unwrap();
pipeline.set_state(gst::State::Null).unwrap();

Ok(())
}
Expand Down

0 comments on commit c84c5d7

Please sign in to comment.