From b20e4454f1fa395897e016a4b1ad36da3151ef8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Laignel?= Date: Thu, 17 Jan 2019 23:10:58 +0100 Subject: [PATCH] Return () instead of bool for some functions See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/171 --- Gir_Gst.toml | 5 +++++ gstreamer/src/auto/stream_collection.rs | 8 -------- gstreamer/src/clock.rs | 19 +++++++------------ gstreamer/src/stream_collection.rs | 11 +++++++++++ 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Gir_Gst.toml b/Gir_Gst.toml index a2789b4ce..a818a07f0 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -867,6 +867,11 @@ trait = false # Work-around for 1.14 switch from transfer-floating to transfer-full ignore = true + [[object.function]] + name = "add_stream" + # Ignore return value which is always `true` + ignore = true + [[object]] name = "Gst.Plugin" status = "generate" diff --git a/gstreamer/src/auto/stream_collection.rs b/gstreamer/src/auto/stream_collection.rs index 91ba361c2..451c566a8 100644 --- a/gstreamer/src/auto/stream_collection.rs +++ b/gstreamer/src/auto/stream_collection.rs @@ -9,7 +9,6 @@ use ffi; use glib::GString; use glib::StaticType; use glib::Value; -use glib::object::IsA; use glib::object::ObjectType; use glib::signal::SignalHandlerId; use glib::signal::connect_raw; @@ -28,13 +27,6 @@ glib_wrapper! { } impl StreamCollection { - #[cfg(any(feature = "v1_10", feature = "dox"))] - pub fn add_stream>(&self, stream: &P) -> bool { - unsafe { - from_glib(ffi::gst_stream_collection_add_stream(self.to_glib_none().0, stream.as_ref().to_glib_full())) - } - } - #[cfg(any(feature = "v1_10", feature = "dox"))] pub fn get_size(&self) -> u32 { unsafe { diff --git a/gstreamer/src/clock.rs b/gstreamer/src/clock.rs index b084c4f2c..ffc858286 100644 --- a/gstreamer/src/clock.rs +++ b/gstreamer/src/clock.rs @@ -39,25 +39,22 @@ unsafe extern "C" fn trampoline_wait_async( func: gpointer, ) -> gboolean { #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] - let f: &&(Fn(&Clock, ClockTime, &ClockId) -> bool + Send + 'static) = transmute(func); + let f: &&(Fn(&Clock, ClockTime, &ClockId) + Send + 'static) = transmute(func); f( &from_glib_borrow(clock), from_glib(time), &from_glib_borrow(id), - ) - .to_glib() + ); + glib_ffi::GTRUE } unsafe extern "C" fn destroy_closure_wait_async(ptr: gpointer) { - Box:: bool + Send + 'static>>::from_raw(ptr as *mut _); + Box::>::from_raw(ptr as *mut _); } -fn into_raw_wait_async bool + Send + 'static>( - func: F, -) -> gpointer { +fn into_raw_wait_async(func: F) -> gpointer { #[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] - let func: Box bool + Send + 'static>> = - Box::new(Box::new(func)); + let func: Box> = Box::new(Box::new(func)); Box::into_raw(func) as gpointer } @@ -81,7 +78,7 @@ impl ClockId { pub fn wait_async(&self, func: F) -> Result where - F: Fn(&Clock, ClockTime, &ClockId) -> bool + Send + 'static, + F: Fn(&Clock, ClockTime, &ClockId) + Send + 'static, { let ret: ClockReturn = unsafe { from_glib(ffi::gst_clock_id_wait_async( @@ -269,8 +266,6 @@ mod tests { let id = clock.new_single_shot_id(now + 20 * ::MSECOND).unwrap(); let res = id.wait_async(move |_, _, _| { sender.send(()).unwrap(); - - true }); assert!(res == Ok(ClockSuccess::Ok)); diff --git a/gstreamer/src/stream_collection.rs b/gstreamer/src/stream_collection.rs index 4cedb030d..7ed579bb2 100644 --- a/gstreamer/src/stream_collection.rs +++ b/gstreamer/src/stream_collection.rs @@ -7,6 +7,7 @@ // except according to those terms. use ffi; +use glib::object::IsA; use glib::translate::*; use Stream; use StreamCollection; @@ -80,6 +81,16 @@ impl StreamCollection { } } + #[cfg(any(feature = "v1_10", feature = "dox"))] + pub fn add_stream>(&self, stream: &P) { + unsafe { + ffi::gst_stream_collection_add_stream( + self.to_glib_none().0, + stream.as_ref().to_glib_full(), + ); + } + } + pub fn iter(&self) -> Iter { Iter::new(self) }