Use glib_result_from_gboolean! where applicable

This commit is contained in:
François Laignel 2019-01-25 18:15:01 +01:00
parent f59e35d0a3
commit a88918dd5f
2 changed files with 18 additions and 21 deletions

View file

@ -54,13 +54,10 @@ impl<O: IsA<Bin>> GstBinExtManual for O {
fn add_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError> {
for e in elements {
unsafe {
let ret: bool = from_glib(ffi::gst_bin_add(
self.as_ref().to_glib_none().0,
e.as_ref().to_glib_none().0,
));
if !ret {
return Err(glib_bool_error!("Failed to add elements"));
}
glib_result_from_gboolean!(
ffi::gst_bin_add(self.as_ref().to_glib_none().0, e.as_ref().to_glib_none().0),
"Failed to add elements"
)?;
}
}
@ -70,13 +67,13 @@ impl<O: IsA<Bin>> GstBinExtManual for O {
fn remove_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError> {
for e in elements {
unsafe {
let ret: bool = from_glib(ffi::gst_bin_remove(
self.as_ref().to_glib_none().0,
e.as_ref().to_glib_none().0,
));
if !ret {
return Err(glib_bool_error!("Failed to remove elements"));
}
glib_result_from_gboolean!(
ffi::gst_bin_remove(
self.as_ref().to_glib_none().0,
e.as_ref().to_glib_none().0,
),
"Failed to remove elements"
)?;
}
}

View file

@ -49,13 +49,13 @@ impl Element {
skip_assert_initialized!();
for (e1, e2) in elements.iter().zip(elements.iter().skip(1)) {
unsafe {
let ret: bool = from_glib(ffi::gst_element_link(
e1.as_ref().to_glib_none().0,
e2.as_ref().to_glib_none().0,
));
if !ret {
return Err(glib_bool_error!("Failed to link elements"));
}
glib_result_from_gboolean!(
ffi::gst_element_link(
e1.as_ref().to_glib_none().0,
e2.as_ref().to_glib_none().0,
),
"Failed to link elements"
)?;
}
}