gstreamer/pad: Handle PadProbeReturn::Handled more correctly

If the probe returns Handled and the data was a Buffer we need to ensure
it was consumed. Queries need to be returned. The behavior of Handled
for other probes is not clear.
This commit is contained in:
Jan Alexander Steffens (heftig) 2019-05-12 15:03:16 +02:00
parent d5317cccdd
commit d470881ac2
No known key found for this signature in database
GPG key ID: DE5E0C5F25941CA5

View file

@ -1080,8 +1080,31 @@ where
flow_ret: from_glib((*info).ABI.abi.flow_ret), flow_ret: from_glib((*info).ABI.abi.flow_ret),
}; };
let ret = func(&Pad::from_glib_borrow(pad).unsafe_cast(), &mut probe_info).to_glib(); let ret = func(&Pad::from_glib_borrow(pad).unsafe_cast(), &mut probe_info);
if ret == PadProbeReturn::Handled {
// Handled queries need to be returned
// Handled buffers are consumed
// No other types can safely be used here
match probe_info.data {
Some(PadProbeData::Query(query)) => {
assert_eq!(data_type, Some(Query::static_type()));
(*info).data = query.as_mut_ptr() as *mut libc::c_void;
}
Some(PadProbeData::Buffer(_)) => {
assert_eq!(data_type, Some(Buffer::static_type()));
// Buffer not consumed by probe; consume it here
}
None if data_type == Some(Buffer::static_type()) => {
// Buffer consumed by probe
}
other => panic!(
"Bad data for {:?} pad probe returning Handled: {:?}",
data_type, other
),
}
} else {
match probe_info.data { match probe_info.data {
Some(PadProbeData::Buffer(buffer)) => { Some(PadProbeData::Buffer(buffer)) => {
assert_eq!(data_type, Some(Buffer::static_type())); assert_eq!(data_type, Some(Buffer::static_type()));
@ -1107,10 +1130,11 @@ where
assert_eq!(data_type, None); assert_eq!(data_type, None);
} }
} }
}
(*info).ABI.abi.flow_ret = probe_info.flow_ret.to_glib(); (*info).ABI.abi.flow_ret = probe_info.flow_ret.to_glib();
ret ret.to_glib()
} }
unsafe extern "C" fn trampoline_activate_function< unsafe extern "C" fn trampoline_activate_function<