mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-23 01:18:11 +00:00
threadshare/jitterbuffer: fix a race condition when stopping
Don't hold the `state` while stopping as the task might attempt to lock it before reaching an `await` point.
This commit is contained in:
parent
bb6ec76951
commit
89682aa6a8
1 changed files with 5 additions and 11 deletions
|
@ -661,11 +661,8 @@ impl PadSinkHandler for SinkHandler {
|
|||
|
||||
gst_log!(CAT, obj: pad.gst_pad(), "Handling {:?}", event);
|
||||
|
||||
match event.view() {
|
||||
EventView::FlushStart(..) => {
|
||||
jb.src_pad.cancel_task();
|
||||
}
|
||||
_ => (),
|
||||
if let EventView::FlushStart(..) = event.view() {
|
||||
jb.src_pad.cancel_task();
|
||||
}
|
||||
|
||||
gst_log!(CAT, obj: pad.gst_pad(), "Forwarding {:?}", event);
|
||||
|
@ -1310,11 +1307,9 @@ impl JitterBuffer {
|
|||
}
|
||||
|
||||
fn start(&self, element: &gst::Element) {
|
||||
let mut state = self.state.lock().unwrap();
|
||||
|
||||
gst_debug!(CAT, obj: element, "Starting");
|
||||
|
||||
*state = State::default();
|
||||
*self.state.lock().unwrap() = State::default();
|
||||
self.sink_pad_handler.clear();
|
||||
self.src_pad_handler.clear();
|
||||
|
||||
|
@ -1325,10 +1320,9 @@ impl JitterBuffer {
|
|||
}
|
||||
|
||||
fn stop(&self, element: &gst::Element) {
|
||||
let mut state = self.state.lock().unwrap();
|
||||
gst_debug!(CAT, obj: element, "Stopping");
|
||||
|
||||
if let Some((_, abort_handle)) = state.wait_handle.take() {
|
||||
if let Some((_, abort_handle)) = self.state.lock().unwrap().wait_handle.take() {
|
||||
abort_handle.abort();
|
||||
}
|
||||
|
||||
|
@ -1336,7 +1330,7 @@ impl JitterBuffer {
|
|||
|
||||
self.src_pad_handler.clear();
|
||||
self.sink_pad_handler.clear();
|
||||
*state = State::default();
|
||||
*self.state.lock().unwrap() = State::default();
|
||||
|
||||
gst_debug!(CAT, obj: element, "Stopped");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue