From 4fbbf4862242bca20112cafb0276456429703d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 1 Jul 2020 01:15:57 +0300 Subject: [PATCH] gstreamer/element: Change post_message() vfunc return type to bool It regularly fails in normal situations, e.g. when the element is not inside a bin and has no bus, and we don't really want to log errors for that. --- gstreamer/src/subclass/element.rs | 35 ++++++++----------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/gstreamer/src/subclass/element.rs b/gstreamer/src/subclass/element.rs index ff4393c23..52d04ea1a 100644 --- a/gstreamer/src/subclass/element.rs +++ b/gstreamer/src/subclass/element.rs @@ -71,7 +71,7 @@ pub trait ElementImpl: ElementImplExt + ObjectImpl + Send + Sync + 'static { self.parent_provide_clock(element) } - fn post_message(&self, element: &::Element, msg: ::Message) -> Result<(), ::LoggableError> { + fn post_message(&self, element: &::Element, msg: ::Message) -> bool { self.parent_post_message(element, msg) } } @@ -103,11 +103,7 @@ pub trait ElementImplExt { fn parent_provide_clock(&self, element: &::Element) -> Option<::Clock>; - fn parent_post_message( - &self, - element: &::Element, - msg: ::Message, - ) -> Result<(), ::LoggableError>; + fn parent_post_message(&self, element: &::Element, msg: ::Message) -> bool; fn catch_panic< R, @@ -246,23 +242,16 @@ where } } - fn parent_post_message( - &self, - element: &::Element, - msg: ::Message, - ) -> Result<(), ::LoggableError> { + fn parent_post_message(&self, element: &::Element, msg: ::Message) -> bool { unsafe { let data = self.get_type_data(); let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstElementClass; - let f = (*parent_class).post_message.ok_or_else(|| { - gst_loggable_error!(::CAT_RUST, "Parent function `post_message` is not defined") - })?; - gst_result_from_gboolean!( - f(element.to_glib_none().0, msg.into_ptr()), - ::CAT_RUST, - "Failed to post message on the element using the parent function" - ) + if let Some(f) = (*parent_class).post_message { + from_glib(f(element.to_glib_none().0, msg.into_ptr())) + } else { + false + } } } @@ -562,13 +551,7 @@ where let wrap: Borrowed = from_glib_borrow(ptr); gst_panic_to_error!(&wrap, &instance.panicked(), false, { - match imp.post_message(&wrap, from_glib_full(msg)) { - Ok(()) => true, - Err(err) => { - err.log_with_object(&*wrap); - false - } - } + imp.post_message(&wrap, from_glib_full(msg)) }) .to_glib() }