Commit e2970db8 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵
Browse files

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

parent 6d8cfa5d
...@@ -147,6 +147,10 @@ trait = false ...@@ -147,6 +147,10 @@ trait = false
name = "message" name = "message"
concurrency = "send" concurrency = "send"
[[object.function]]
name = "post"
[object.function.return]
bool_return_is_error = "Failed to post message"
[[object]] [[object]]
name = "Gst.Structure" name = "Gst.Structure"
...@@ -277,6 +281,11 @@ status = "generate" ...@@ -277,6 +281,11 @@ status = "generate"
[object.function.return] [object.function.return]
bool_return_is_error = "Failed to link pads" 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]] [[object.function]]
name = "seek" name = "seek"
[object.function.return] [object.function.return]
......
...@@ -5,6 +5,7 @@ use ClockTime; ...@@ -5,6 +5,7 @@ use ClockTime;
use Message; use Message;
use Object; use Object;
use ffi; use ffi;
use glib;
use glib::signal::SignalHandlerId; use glib::signal::SignalHandlerId;
use glib::signal::connect; use glib::signal::connect;
use glib::translate::*; use glib::translate::*;
...@@ -79,9 +80,9 @@ impl Bus { ...@@ -79,9 +80,9 @@ impl Bus {
} }
} }
pub fn post(&self, message: &Message) -> bool { pub fn post(&self, message: &Message) -> Result<(), glib::error::BoolError> {
unsafe { 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")
} }
} }
......
...@@ -132,7 +132,7 @@ pub trait ElementExt { ...@@ -132,7 +132,7 @@ pub trait ElementExt {
fn no_more_pads(&self); 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>; fn provide_clock(&self) -> Option<Clock>;
...@@ -373,9 +373,9 @@ impl<O: IsA<Element> + IsA<glib::object::Object>> ElementExt for O { ...@@ -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 { 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")
} }
} }
......
Supports Markdown
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