From e0d05353e8a55d8a3800d7bae6421e7d7322eb88 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 25 Mar 2022 14:33:02 +0100 Subject: [PATCH] uriplaylistbin: fix race when handling topology change Keep the state mutex during the whole decodebin pad-added callback. Fix a race when we were checking if state.waiting_for_ss_eos was set and it was removed before we actually processed the item. Fix #184 --- utils/uriplaylistbin/src/uriplaylistbin/imp.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs index bd341b44..a9f5ad8c 100644 --- a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs +++ b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs @@ -1050,14 +1050,10 @@ impl UriPlaylistBin { None => return, }; let imp = element.imp(); + let mut state_guard = imp.state.lock().unwrap(); + let state = state_guard.as_mut().unwrap(); - let item = { - let mut state_guard = imp.state.lock().unwrap(); - let state = state_guard.as_mut().unwrap(); - state.waiting_for_ss_eos.as_ref().cloned() - }; - - if let Some(item) = item { + if let Some(item) = state.waiting_for_ss_eos.as_ref() { // block pad until streamsynchronizer is eos let element_weak = element.downgrade(); let receiver = item.receiver(); @@ -1091,6 +1087,7 @@ impl UriPlaylistBin { item.add_blocked_pad(src_pad.clone()); } else { + drop(state_guard); imp.process_decodebin_pad(src_pad); } });