mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-06 01:29:37 +00:00
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:
parent
d5317cccdd
commit
d470881ac2
1 changed files with 48 additions and 24 deletions
|
@ -1080,8 +1080,31 @@ where
|
|||
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 {
|
||||
Some(PadProbeData::Buffer(buffer)) => {
|
||||
assert_eq!(data_type, Some(Buffer::static_type()));
|
||||
|
@ -1107,10 +1130,11 @@ where
|
|||
assert_eq!(data_type, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(*info).ABI.abi.flow_ret = probe_info.flow_ret.to_glib();
|
||||
|
||||
ret
|
||||
ret.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn trampoline_activate_function<
|
||||
|
|
Loading…
Reference in a new issue