fallbackswitch: Make sure to flush/reset pads during pad (de)activation

Otherwise this can potentially deadlock or delay state changes for a
longer time.
This commit is contained in:
Sebastian Dröge 2022-08-23 19:46:16 +03:00
parent 1f7126a8a1
commit 00411523d4

View file

@ -535,6 +535,21 @@ impl FallbackSwitch {
.expect("Failed to wait async");
}
fn sink_activatemode(
pad: &super::FallbackSwitchSinkPad,
_mode: gst::PadMode,
activate: bool,
) -> Result<(), gst::LoggableError> {
let mut pad_state = pad.imp().state.lock();
if activate {
pad_state.reset();
} else {
pad_state.flush_start();
}
Ok(())
}
fn sink_chain(
&self,
pad: &super::FallbackSwitchSinkPad,
@ -1387,6 +1402,9 @@ impl ElementImpl for FallbackSwitch {
|fallbackswitch, element| fallbackswitch.sink_query(pad, element, query),
)
})
.activatemode_function(|pad, _parent, mode, activate| {
Self::sink_activatemode(pad, mode, activate)
})
.build();
pad.set_active(true).unwrap();