utils/fallbackswitch: Use the correct segment when deciding to drop fallback buffers

Thanks to Jan Schmidt for noticing.
This commit is contained in:
Sebastian Dröge 2020-09-24 09:34:26 +03:00 committed by Sebastian Dröge
parent bf82e750f4
commit 331374fabe

View file

@ -219,29 +219,33 @@ impl FallbackSwitch {
// Drop all older buffers from the fallback sinkpad // Drop all older buffers from the fallback sinkpad
if let Some(fallback_sinkpad) = fallback_sinkpad { if let Some(fallback_sinkpad) = fallback_sinkpad {
let fallback_segment = self let segment = fallback_sinkpad.get_segment();
.sinkpad
.get_segment()
.downcast::<gst::ClockTime>()
.map_err(|_| {
gst_error!(CAT, obj: agg, "Only TIME segments supported");
gst::FlowError::Error
})?;
while let Some(fallback_buffer) = fallback_sinkpad.peek_buffer() { // Might have no segment at all yet
let fallback_pts = fallback_buffer.get_dts_or_pts(); if segment.get_format() != gst::Format::Undefined {
if fallback_pts.is_none() let fallback_segment = fallback_sinkpad
|| fallback_segment.to_running_time(fallback_pts) <= state.last_sinkpad_time .get_segment()
{ .downcast::<gst::ClockTime>()
gst_debug!( .map_err(|_| {
CAT, gst_error!(CAT, obj: agg, "Only TIME segments supported");
obj: agg, gst::FlowError::Error
"Dropping fallback buffer {:?}", })?;
fallback_buffer
); while let Some(fallback_buffer) = fallback_sinkpad.peek_buffer() {
fallback_sinkpad.drop_buffer(); let fallback_pts = fallback_buffer.get_dts_or_pts();
} else { if fallback_pts.is_none()
break; || fallback_segment.to_running_time(fallback_pts) <= state.last_sinkpad_time
{
gst_debug!(
CAT,
obj: agg,
"Dropping fallback buffer {:?}",
fallback_buffer
);
fallback_sinkpad.drop_buffer();
} else {
break;
}
} }
} }
} }