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> { fn add_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError> {
for e in elements { for e in elements {
unsafe { unsafe {
let ret: bool = from_glib(ffi::gst_bin_add( glib_result_from_gboolean!(
self.as_ref().to_glib_none().0, ffi::gst_bin_add(self.as_ref().to_glib_none().0, e.as_ref().to_glib_none().0),
e.as_ref().to_glib_none().0, "Failed to add elements"
)); )?;
if !ret {
return Err(glib_bool_error!("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> { fn remove_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError> {
for e in elements { for e in elements {
unsafe { unsafe {
let ret: bool = from_glib(ffi::gst_bin_remove( glib_result_from_gboolean!(
self.as_ref().to_glib_none().0, ffi::gst_bin_remove(
e.as_ref().to_glib_none().0, 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")); "Failed to remove elements"
} )?;
} }
} }

View file

@ -49,13 +49,13 @@ impl Element {
skip_assert_initialized!(); skip_assert_initialized!();
for (e1, e2) in elements.iter().zip(elements.iter().skip(1)) { for (e1, e2) in elements.iter().zip(elements.iter().skip(1)) {
unsafe { unsafe {
let ret: bool = from_glib(ffi::gst_element_link( glib_result_from_gboolean!(
e1.as_ref().to_glib_none().0, ffi::gst_element_link(
e2.as_ref().to_glib_none().0, 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")); "Failed to link elements"
} )?;
} }
} }