utils/togglerecord: fix race condition in sink_chain when segment is pending

In `sink_chain` when the Segment is pending, attempting to lock
rec state could lead to a dead lock because the stream state is
already locked while the main stream state was not locked.
This commit is contained in:
François Laignel 2021-12-19 19:15:38 +01:00 committed by Sebastian Dröge
parent a1c89dd17b
commit 7c909e59a9

View file

@ -1216,6 +1216,12 @@ impl ToggleRecord {
};
let out_running_time = {
let main_state = if stream != self.main_stream {
Some(self.main_stream.state.lock())
} else {
None
};
let mut state = stream.state.lock();
if state.discont_pending {
@ -1260,6 +1266,7 @@ impl ToggleRecord {
// Unlock before pushing
drop(state);
drop(main_state);
for e in events.drain(..) {
stream.srcpad.push_event(e);