fallbacksrc: Don't forward manual flush events to downstream

fallbackswitch might forward flush event if it's for the currently
active pad. But forwarded flush event will be problematic in various
reasons and that's not a behavior we expected.
This commit is contained in:
Seungha Yang 2022-04-12 23:16:17 +09:00
parent 5788837fb6
commit 930cc41aaa

View file

@ -2142,6 +2142,28 @@ impl FallbackSrc {
}
})
.collect::<Vec<_>>();
let stream_srcpads = [state.audio_stream.as_ref(), state.video_stream.as_ref()]
.into_iter()
.flatten()
.map(|s| {
let srcpad = s.srcpad.clone();
let probe_id = srcpad
.add_probe(
gst::PadProbeType::EVENT_DOWNSTREAM | gst::PadProbeType::EVENT_FLUSH,
move |_pad, info| match info.data {
Some(gst::PadProbeData::Event(ref ev)) => match ev.view() {
gst::EventView::FlushStart(_) => gst::PadProbeReturn::Drop,
gst::EventView::FlushStop(_) => gst::PadProbeReturn::Drop,
_ => gst::PadProbeReturn::Ok,
},
_ => gst::PadProbeReturn::Ok,
},
)
.unwrap();
(probe_id, srcpad)
})
.collect::<Vec<_>>();
drop(state_guard);
gst::debug!(CAT, obj: element, "Flushing source");
@ -2155,6 +2177,10 @@ impl FallbackSrc {
let _ = pad.send_event(gst::event::FlushStop::builder(true).build());
}
for (probe_id, pad) in stream_srcpads {
pad.remove_probe(probe_id);
}
// Sleep for 1s before retrying
let mut state_guard = src.state.lock();