fallbacksrc: Connect to notify::active-pad after requesting pads

Requesting the first pad will emit the property because the first pad is
then selected. That will cause the callback to be called, which tries to
take the same mutex that is already locked during element setup and
causes a deadlock.
This commit is contained in:
Sebastian Dröge 2022-04-08 19:53:38 +03:00
parent 7daab76f17
commit d3d98c73ca

View file

@ -928,16 +928,6 @@ impl FallbackSrc {
.add_many(&[&fallback_input, &switch, &clocksync_queue, &clocksync])
.unwrap();
let element_weak = element.downgrade();
switch.connect_notify(Some("active-pad"), move |_switch, _pspec| {
let element = match element_weak.upgrade() {
None => return,
Some(element) => element,
};
let src = element.imp();
src.handle_switch_active_pad_change(&element);
});
switch.set_property("timeout", timeout.nseconds());
switch.set_property("min-upstream-latency", min_latency.nseconds());
switch.set_property("immediate-fallback", immediate_fallback);
@ -955,6 +945,17 @@ impl FallbackSrc {
switch_mainsink.set_property("priority", 0u32);
// clocksync_queue sink pad is not connected to anything yet at this point!
let element_weak = element.downgrade();
switch.connect_notify(Some("active-pad"), move |_switch, _pspec| {
let element = match element_weak.upgrade() {
None => return,
Some(element) => element,
};
let src = element.imp();
src.handle_switch_active_pad_change(&element);
});
let srcpad = switch.static_pad("src").unwrap();
let templ = element
.pad_template(if is_audio { "audio" } else { "video" })