fallbackswitch: Improve debug output of clock times and simplify some code

This commit is contained in:
Sebastian Dröge 2022-04-13 12:19:08 +03:00 committed by Sebastian Dröge
parent 9e3f713aa9
commit 6ce523a7a8

View file

@ -276,29 +276,21 @@ impl SinkState {
running_time: Option<gst::ClockTime>, running_time: Option<gst::ClockTime>,
extra_time: gst::ClockTime, extra_time: gst::ClockTime,
) -> Option<gst::SingleShotClockId> { ) -> Option<gst::SingleShotClockId> {
let clock = match element.clock() { let running_time = running_time?;
None => return None, let clock = element.clock()?;
Some(clock) => clock,
};
let base_time = element.base_time(); let base_time = element.base_time()?;
let wait_until = match running_time let wait_until = running_time + base_time;
.zip(base_time)
.map(|(running_time, base_time)| running_time + base_time)
{
Some(wait_until) => wait_until,
None => return None,
};
let wait_until = wait_until.saturating_add(extra_time); let wait_until = wait_until.saturating_add(extra_time);
let now = clock.time(); let now = clock.time()?;
/* If the buffer is already late, skip the clock wait */ /* If the buffer is already late, skip the clock wait */
if now.map_or(true, |now| wait_until < now) { if wait_until < now {
debug!( debug!(
CAT, CAT,
obj: element, obj: element,
"Skipping buffer wait until {} - clock already {:?}", "Skipping buffer wait until {} - clock already {}",
wait_until, wait_until,
now now
); );
@ -308,7 +300,7 @@ impl SinkState {
debug!( debug!(
CAT, CAT,
obj: element, obj: element,
"Scheduling buffer wait until {} = {:?} + extra {:?} + base time {:?}", "Scheduling buffer wait until {} = {} + extra {} + base time {}",
wait_until, wait_until,
running_time, running_time,
extra_time, extra_time,
@ -450,19 +442,14 @@ impl FallbackSwitch {
Some(clock) => clock, Some(clock) => clock,
}; };
let timeout_running_time = running_time let base_time = match element.base_time() {
.saturating_add(state.upstream_latency + settings.timeout + settings.latency); Some(base_time) => base_time,
let base_time = element.base_time();
let wait_until = match Some(timeout_running_time)
.zip(base_time)
.map(|(running_time, base_time)| running_time + base_time)
{
Some(wait_until) => wait_until,
None => return, None => return,
}; };
let timeout_running_time = running_time
.saturating_add(state.upstream_latency + settings.timeout + settings.latency);
let wait_until = timeout_running_time + base_time;
state.timeout_running_time = timeout_running_time; state.timeout_running_time = timeout_running_time;
/* If we're already running behind, fire the timeout immediately */ /* If we're already running behind, fire the timeout immediately */
@ -554,10 +541,10 @@ impl FallbackSwitch {
log!( log!(
CAT, CAT,
obj: pad, obj: pad,
"Handling buffer {:?} run ts start {:?} end {:?} pad active {}", "Handling buffer {:?} run ts start {} end {} pad active {}",
buffer, buffer,
start_running_time, start_running_time.display(),
end_running_time, end_running_time.display(),
is_active is_active
); );