Skip to content

Commit eab88c5

Browse files
joaoantoniocardosopatrickelectric
authored andcommitted
src: stream: sink: Fix lock during WebRTCSink's unlink
1 parent 99230ef commit eab88c5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/stream/sink/webrtc_sink.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,13 @@ impl SinkInterface for WebRTCSink {
241241
warn!("Failed removing WebRTCBin's elements from pipeline: {remove_err:?}");
242242
}
243243

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

254252
Ok(())
255253
}

0 commit comments

Comments
 (0)