Failure to post a message is an error, so return a Result instead of a bool

This commit is contained in:
Sebastian Dröge 2017-12-20 18:07:28 +02:00
parent 6d8cfa5de0
commit e2970db84c
3 changed files with 15 additions and 5 deletions

View file

@ -147,6 +147,10 @@ trait = false
name = "message"
concurrency = "send"
[[object.function]]
name = "post"
[object.function.return]
bool_return_is_error = "Failed to post message"
[[object]]
name = "Gst.Structure"
@ -277,6 +281,11 @@ status = "generate"
[object.function.return]
bool_return_is_error = "Failed to link pads"
[[object.function]]
name = "post_message"
[object.function.return]
bool_return_is_error = "Failed to post message"
[[object.function]]
name = "seek"
[object.function.return]

View file

@ -5,6 +5,7 @@ use ClockTime;
use Message;
use Object;
use ffi;
use glib;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
@ -79,9 +80,9 @@ impl Bus {
}
}
pub fn post(&self, message: &Message) -> bool {
pub fn post(&self, message: &Message) -> Result<(), glib::error::BoolError> {
unsafe {
from_glib(ffi::gst_bus_post(self.to_glib_none().0, message.to_glib_full()))
glib::error::BoolError::from_glib(ffi::gst_bus_post(self.to_glib_none().0, message.to_glib_full()), "Failed to post message")
}
}

View file

@ -132,7 +132,7 @@ pub trait ElementExt {
fn no_more_pads(&self);
fn post_message(&self, message: &Message) -> bool;
fn post_message(&self, message: &Message) -> Result<(), glib::error::BoolError>;
fn provide_clock(&self) -> Option<Clock>;
@ -373,9 +373,9 @@ impl<O: IsA<Element> + IsA<glib::object::Object>> ElementExt for O {
}
}
fn post_message(&self, message: &Message) -> bool {
fn post_message(&self, message: &Message) -> Result<(), glib::error::BoolError> {
unsafe {
from_glib(ffi::gst_element_post_message(self.to_glib_none().0, message.to_glib_full()))
glib::error::BoolError::from_glib(ffi::gst_element_post_message(self.to_glib_none().0, message.to_glib_full()), "Failed to post message")
}
}