forked from mirrors/gstreamer-rs
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.
This commit is contained in:
parent
9cc99b27e0
commit
4fbbf48622
1 changed files with 9 additions and 26 deletions
|
@ -71,7 +71,7 @@ pub trait ElementImpl: ElementImplExt + ObjectImpl + Send + Sync + 'static {
|
||||||
self.parent_provide_clock(element)
|
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)
|
self.parent_post_message(element, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,11 +103,7 @@ pub trait ElementImplExt {
|
||||||
|
|
||||||
fn parent_provide_clock(&self, element: &::Element) -> Option<::Clock>;
|
fn parent_provide_clock(&self, element: &::Element) -> Option<::Clock>;
|
||||||
|
|
||||||
fn parent_post_message(
|
fn parent_post_message(&self, element: &::Element, msg: ::Message) -> bool;
|
||||||
&self,
|
|
||||||
element: &::Element,
|
|
||||||
msg: ::Message,
|
|
||||||
) -> Result<(), ::LoggableError>;
|
|
||||||
|
|
||||||
fn catch_panic<
|
fn catch_panic<
|
||||||
R,
|
R,
|
||||||
|
@ -246,23 +242,16 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_post_message(
|
fn parent_post_message(&self, element: &::Element, msg: ::Message) -> bool {
|
||||||
&self,
|
|
||||||
element: &::Element,
|
|
||||||
msg: ::Message,
|
|
||||||
) -> Result<(), ::LoggableError> {
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstElementClass;
|
let parent_class = data.as_ref().get_parent_class() as *mut gst_sys::GstElementClass;
|
||||||
|
|
||||||
let f = (*parent_class).post_message.ok_or_else(|| {
|
if let Some(f) = (*parent_class).post_message {
|
||||||
gst_loggable_error!(::CAT_RUST, "Parent function `post_message` is not defined")
|
from_glib(f(element.to_glib_none().0, msg.into_ptr()))
|
||||||
})?;
|
} else {
|
||||||
gst_result_from_gboolean!(
|
false
|
||||||
f(element.to_glib_none().0, msg.into_ptr()),
|
}
|
||||||
::CAT_RUST,
|
|
||||||
"Failed to post message on the element using the parent function"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,13 +551,7 @@ where
|
||||||
let wrap: Borrowed<Element> = from_glib_borrow(ptr);
|
let wrap: Borrowed<Element> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.post_message(&wrap, from_glib_full(msg)) {
|
imp.post_message(&wrap, from_glib_full(msg))
|
||||||
Ok(()) => true,
|
|
||||||
Err(err) => {
|
|
||||||
err.log_with_object(&*wrap);
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue