bus: Take ownership of the message in post()

This commit is contained in:
Sebastian Dröge 2022-06-28 23:17:58 +03:00
parent 20ac231146
commit 14f485d0b1
3 changed files with 14 additions and 14 deletions

View file

@ -608,8 +608,8 @@ final_type = true
[[object.function]]
name = "post"
[object.function.return]
bool_return_is_error = "Failed to post message"
# transfer ownership of the message
manual = true
[[object]]
name = "Gst.Caps"

View file

@ -76,16 +76,6 @@ impl Bus {
unsafe { from_glib_full(ffi::gst_bus_pop(self.to_glib_none().0)) }
}
#[doc(alias = "gst_bus_post")]
pub fn post(&self, message: &Message) -> Result<(), glib::error::BoolError> {
unsafe {
glib::result_from_gboolean!(
ffi::gst_bus_post(self.to_glib_none().0, message.to_glib_full()),
"Failed to post message"
)
}
}
#[doc(alias = "gst_bus_remove_signal_watch")]
pub fn remove_signal_watch(&self) {
unsafe {

View file

@ -302,6 +302,16 @@ impl Bus {
future::ready(message_types.contains(&message_type))
})
}
#[doc(alias = "gst_bus_post")]
pub fn post(&self, message: crate::Message) -> Result<(), glib::error::BoolError> {
unsafe {
glib::result_from_gboolean!(
ffi::gst_bus_post(self.to_glib_none().0, message.into_glib_ptr()),
"Failed to post message"
)
}
}
}
#[derive(Debug)]
@ -382,7 +392,7 @@ mod tests {
BusSyncReply::Pass
});
bus.post(&crate::message::Eos::new()).unwrap();
bus.post(crate::message::Eos::new()).unwrap();
let msgs = msgs.lock().unwrap();
assert_eq!(msgs.len(), 1);
@ -400,7 +410,7 @@ mod tests {
let bus_stream = bus.stream();
let eos_message = crate::message::Eos::new();
bus.post(&eos_message).unwrap();
bus.post(eos_message).unwrap();
let bus_future = bus_stream.into_future();
let (message, _) = futures_executor::block_on(bus_future);