utils/fallbacksrc: Don't error out if we just reached 100% buffering when the timeout triggered

It will take a moment for the fallbackswitch to actually switch to the
main stream. So instead take into account the time since the last
buffering update even when we reached 100%, and don't reset that time
when reaching 100%.
This commit is contained in:
Sebastian Dröge 2020-05-20 12:44:28 +03:00
parent ba161a146d
commit 621907556d

View file

@ -1486,7 +1486,6 @@ impl FallbackSrc {
drop(state_guard); drop(state_guard);
element.notify("status"); element.notify("status");
} else { } else {
state.last_buffering_update = None;
// Check if we can unblock now // Check if we can unblock now
self.unblock_pads(element, state); self.unblock_pads(element, state);
@ -1781,11 +1780,10 @@ impl FallbackSrc {
gst_warning!(CAT, obj: element, "Switched to fallback stream"); gst_warning!(CAT, obj: element, "Switched to fallback stream");
// If we're not actively buffering right now let's restart the source // If we're not actively buffering right now let's restart the source
if state.buffering_percent == 100 if state
|| state
.last_buffering_update .last_buffering_update
.map(|i| i.elapsed() >= Duration::from_nanos(state.settings.timeout)) .map(|i| i.elapsed() >= Duration::from_nanos(state.settings.timeout))
.unwrap_or(true) .unwrap_or(state.buffering_percent == 100)
{ {
gst_debug!(CAT, obj: element, "Not buffering, restarting source"); gst_debug!(CAT, obj: element, "Not buffering, restarting source");
self.handle_source_error(element, state); self.handle_source_error(element, state);