fallbackswitch: Only drop raw audio/video buffers if they're trailing

Otherwise this can cause decoding errors further downstream.
This commit is contained in:
Sebastian Dröge 2022-04-13 12:50:15 +03:00 committed by Sebastian Dröge
parent bbb7ced95a
commit 930cdca750

View file

@ -620,6 +620,7 @@ impl FallbackSwitch {
let is_active = state.active_sinkpad.as_ref() == Some(pad); let is_active = state.active_sinkpad.as_ref() == Some(pad);
let mut pad_state = pad_imp.state.lock(); let mut pad_state = pad_imp.state.lock();
let raw_pad = !matches!(pad_state.caps_info, CapsInfo::None);
let (start_running_time, end_running_time) = pad_state.get_sync_time(&buffer); let (start_running_time, end_running_time) = pad_state.get_sync_time(&buffer);
log!( log!(
@ -642,15 +643,26 @@ impl FallbackSwitch {
} else if end_running_time.map_or(false, |end_running_time| { } else if end_running_time.map_or(false, |end_running_time| {
end_running_time < state.timeout_running_time end_running_time < state.timeout_running_time
}) { }) {
log!( if raw_pad {
CAT, log!(
obj: pad, CAT,
"Dropping trailing buffer {:?} before timeout {}", obj: pad,
buffer, "Dropping trailing raw {:?} before timeout {}",
state.timeout_running_time buffer,
); state.timeout_running_time
);
return Ok(gst::FlowSuccess::Ok);
} else {
log!(
CAT,
obj: pad,
"Not dropping trailing non-raw {:?} before timeout {}",
buffer,
state.timeout_running_time
);
return Ok(gst::FlowSuccess::Ok); None
}
} else { } else {
pad_state.schedule_clock( pad_state.schedule_clock(
element, element,
@ -699,15 +711,24 @@ impl FallbackSwitch {
start_running_time < output_running_time start_running_time < output_running_time
}, },
) { ) {
log!( if raw_pad {
CAT, log!(
obj: pad, CAT,
"Dropping trailing buffer {:?} before output running time {}", obj: pad,
buffer, "Dropping trailing raw {:?} before output running time {}",
state.output_running_time.display(), buffer,
); state.output_running_time.display(),
);
return Ok(gst::FlowSuccess::Ok); return Ok(gst::FlowSuccess::Ok);
} else {
log!(
CAT,
obj: pad,
"Not dropping trailing non-raw {:?} before output running time {}",
buffer,
state.output_running_time.display(),
);
}
} }
if start_running_time.is_some() { if start_running_time.is_some() {