Commit a986914b authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Use Option<&T> instead of &Option<T> everywhere

Fixes #203
parent 32d7f42d
Pipeline #38227 passed with stages
in 21 minutes and 12 seconds
......@@ -53,11 +53,11 @@ pub fn type_find_helper_for_extension<P: IsA<gst::Object>>(obj: Option<&P>, exte
}
}
//pub fn type_find_helper_get_range<P: IsA<gst::Object>, Q: IsA<gst::Object>, R: FnMut(&gst::Object, &Option<gst::Object>, u64, u32, &gst::Buffer) -> gst::FlowReturn>(obj: &P, parent: Option<&Q>, func: R, size: u64, extension: Option<&str>) -> (Option<gst::Caps>, gst::TypeFindProbability) {
//pub fn type_find_helper_get_range<P: IsA<gst::Object>, Q: IsA<gst::Object>, R: FnMut(&gst::Object, Option<&gst::Object>, u64, u32, &gst::Buffer) -> gst::FlowReturn>(obj: &P, parent: Option<&Q>, func: R, size: u64, extension: Option<&str>) -> (Option<gst::Caps>, gst::TypeFindProbability) {
// unsafe { TODO: call gst_base_sys:gst_type_find_helper_get_range() }
//}
//#[cfg(any(feature = "v1_14_3", feature = "dox"))]
//pub fn type_find_helper_get_range_full<P: IsA<gst::Object>, Q: IsA<gst::Object>, R: FnMut(&gst::Object, &Option<gst::Object>, u64, u32, &gst::Buffer) -> gst::FlowReturn>(obj: &P, parent: Option<&Q>, func: R, size: u64, extension: Option<&str>) -> (gst::FlowReturn, gst::Caps, gst::TypeFindProbability) {
//pub fn type_find_helper_get_range_full<P: IsA<gst::Object>, Q: IsA<gst::Object>, R: FnMut(&gst::Object, Option<&gst::Object>, u64, u32, &gst::Buffer) -> gst::FlowReturn>(obj: &P, parent: Option<&Q>, func: R, size: u64, extension: Option<&str>) -> (gst::FlowReturn, gst::Caps, gst::TypeFindProbability) {
// unsafe { TODO: call gst_base_sys:gst_type_find_helper_get_range_full() }
//}
......@@ -83,7 +83,7 @@ impl Discoverer {
}
}
pub fn connect_discovered<F: Fn(&Discoverer, &DiscovererInfo, &Option<Error>) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
pub fn connect_discovered<F: Fn(&Discoverer, &DiscovererInfo, Option<&Error>) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"discovered\0".as_ptr() as *const _,
......@@ -128,9 +128,9 @@ impl Discoverer {
unsafe impl Send for Discoverer {}
unsafe impl Sync for Discoverer {}
unsafe extern "C" fn discovered_trampoline<F: Fn(&Discoverer, &DiscovererInfo, &Option<Error>) + Send + Sync + 'static>(this: *mut gst_pbutils_sys::GstDiscoverer, info: *mut gst_pbutils_sys::GstDiscovererInfo, error: *mut glib_sys::GError, f: glib_sys::gpointer) {
unsafe extern "C" fn discovered_trampoline<F: Fn(&Discoverer, &DiscovererInfo, Option<&Error>) + Send + Sync + 'static>(this: *mut gst_pbutils_sys::GstDiscoverer, info: *mut gst_pbutils_sys::GstDiscovererInfo, error: *mut glib_sys::GError, f: glib_sys::gpointer) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), &from_glib_borrow(info), &from_glib_borrow(error))
f(&from_glib_borrow(this), &from_glib_borrow(info), Option::<Error>::from_glib_borrow(error).as_ref())
}
unsafe extern "C" fn finished_trampoline<F: Fn(&Discoverer) + Send + Sync + 'static>(this: *mut gst_pbutils_sys::GstDiscoverer, f: glib_sys::gpointer) {
......
This diff is collapsed.
......@@ -156,7 +156,7 @@ impl SampleRef {
}
#[cfg(any(feature = "v1_16", feature = "dox"))]
pub fn set_segment(&mut self, segment: &Option<&Segment>) {
pub fn set_segment(&mut self, segment: Option<&Segment>) {
unsafe { gst_sys::gst_sample_set_segment(self.as_mut_ptr(), segment.to_glib_none().0) }
}
......
......@@ -100,7 +100,7 @@ pub trait ElementImplExt {
) -> R;
fn catch_panic_pad_function<R, F: FnOnce(&Self, &::Element) -> R, G: FnOnce() -> R>(
parent: &Option<::Object>,
parent: Option<&::Object>,
fallback: G,
f: F,
) -> R;
......@@ -222,7 +222,7 @@ where
}
fn catch_panic_pad_function<R, F: FnOnce(&Self, &::Element) -> R, G: FnOnce() -> R>(
parent: &Option<::Object>,
parent: Option<&::Object>,
fallback: G,
f: F,
) -> R {
......
......@@ -81,10 +81,10 @@ fn print_topology(info: &DiscovererStreamInfo, depth: usize) {
}
}
fn on_connect_discovered(
fn on_discovered(
_discoverer: &Discoverer,
discoverer_info: &DiscovererInfo,
error: &Option<glib::Error>,
error: Option<&glib::Error>,
) {
let uri = discoverer_info.get_uri().unwrap();
match discoverer_info.get_result() {
......@@ -156,7 +156,7 @@ fn run_discoverer() -> Result<(), Error> {
let loop_ = glib::MainLoop::new(None, false);
let timeout = 5 * gst::SECOND;
let discoverer = gst_pbutils::Discoverer::new(timeout)?;
discoverer.connect_discovered(on_connect_discovered);
discoverer.connect_discovered(on_discovered);
let loop_clone = loop_.clone();
discoverer.connect_finished(move |_| {
println!("\nFinished discovering");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment