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,37 +1080,61 @@ 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);
|
||||||
|
|
||||||
match probe_info.data {
|
if ret == PadProbeReturn::Handled {
|
||||||
Some(PadProbeData::Buffer(buffer)) => {
|
// Handled queries need to be returned
|
||||||
assert_eq!(data_type, Some(Buffer::static_type()));
|
// Handled buffers are consumed
|
||||||
(*info).data = buffer.into_ptr() as *mut libc::c_void;
|
// 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
|
||||||
|
),
|
||||||
}
|
}
|
||||||
Some(PadProbeData::BufferList(bufferlist)) => {
|
} else {
|
||||||
assert_eq!(data_type, Some(BufferList::static_type()));
|
match probe_info.data {
|
||||||
(*info).data = bufferlist.into_ptr() as *mut libc::c_void;
|
Some(PadProbeData::Buffer(buffer)) => {
|
||||||
}
|
assert_eq!(data_type, Some(Buffer::static_type()));
|
||||||
Some(PadProbeData::Event(event)) => {
|
(*info).data = buffer.into_ptr() as *mut libc::c_void;
|
||||||
assert_eq!(data_type, Some(Event::static_type()));
|
}
|
||||||
(*info).data = event.into_ptr() as *mut libc::c_void;
|
Some(PadProbeData::BufferList(bufferlist)) => {
|
||||||
}
|
assert_eq!(data_type, Some(BufferList::static_type()));
|
||||||
Some(PadProbeData::Query(query)) => {
|
(*info).data = bufferlist.into_ptr() as *mut libc::c_void;
|
||||||
assert_eq!(data_type, Some(Query::static_type()));
|
}
|
||||||
(*info).data = query.as_mut_ptr() as *mut libc::c_void;
|
Some(PadProbeData::Event(event)) => {
|
||||||
}
|
assert_eq!(data_type, Some(Event::static_type()));
|
||||||
Some(PadProbeData::__Unknown(ptr)) => {
|
(*info).data = event.into_ptr() as *mut libc::c_void;
|
||||||
assert_eq!(data_type, None);
|
}
|
||||||
(*info).data = ptr as *mut libc::c_void;
|
Some(PadProbeData::Query(query)) => {
|
||||||
}
|
assert_eq!(data_type, Some(Query::static_type()));
|
||||||
None => {
|
(*info).data = query.as_mut_ptr() as *mut libc::c_void;
|
||||||
assert_eq!(data_type, None);
|
}
|
||||||
|
Some(PadProbeData::__Unknown(ptr)) => {
|
||||||
|
assert_eq!(data_type, None);
|
||||||
|
(*info).data = ptr as *mut libc::c_void;
|
||||||
|
}
|
||||||
|
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<
|
||||||
|
|
Loading…
Reference in a new issue