diff --git a/gst-plugin-tutorial/src/sinesrc.rs b/gst-plugin-tutorial/src/sinesrc.rs index fbafe739..303238ca 100644 --- a/gst-plugin-tutorial/src/sinesrc.rs +++ b/gst-plugin-tutorial/src/sinesrc.rs @@ -492,7 +492,7 @@ impl BaseSrcImpl for SineSrc { element: &BaseSrc, _offset: u64, _length: u32, - ) -> Result { + ) -> Result { // Keep a local copy of the values of all our properties at this very moment. This // ensures that the mutex is never locked for long and the application wouldn't // have to block until this function returns when getting/setting property values @@ -503,7 +503,7 @@ impl BaseSrcImpl for SineSrc { let info = match state.info { None => { gst_element_error!(element, gst::CoreError::Negotiation, ["Have no caps yet"]); - return Err(gst::FlowReturn::NotNegotiated); + return Err(gst::FlowError::NotNegotiated); } Some(ref info) => info.clone(), }; @@ -513,7 +513,7 @@ impl BaseSrcImpl for SineSrc { let n_samples = if let Some(sample_stop) = state.sample_stop { if sample_stop <= state.sample_offset { gst_log!(self.cat, obj: element, "At EOS"); - return Err(gst::FlowReturn::Eos); + return Err(gst::FlowError::Eos); } sample_stop - state.sample_offset @@ -606,7 +606,7 @@ impl BaseSrcImpl for SineSrc { let mut clock_wait = self.clock_wait.lock().unwrap(); if clock_wait.flushing { gst_debug!(self.cat, obj: element, "Flushing"); - return Err(gst::FlowReturn::Flushing); + return Err(gst::FlowError::Flushing); } let id = clock.new_single_shot_id(wait_until).unwrap(); @@ -634,7 +634,7 @@ impl BaseSrcImpl for SineSrc { // and we should return Flushing immediately. if res == gst::ClockReturn::Unscheduled { gst_debug!(self.cat, obj: element, "Flushing"); - return Err(gst::FlowReturn::Flushing); + return Err(gst::FlowError::Flushing); } } diff --git a/gst-plugin/src/aggregator.rs b/gst-plugin/src/aggregator.rs index a2ad9e5c..15d91b57 100644 --- a/gst-plugin/src/aggregator.rs +++ b/gst-plugin/src/aggregator.rs @@ -108,7 +108,7 @@ where &self, aggregator: &T, caps: &gst::CapsRef, - ) -> Result { + ) -> Result { aggregator.parent_update_src_caps(caps) } @@ -322,7 +322,7 @@ pub unsafe trait AggregatorBase: } } - fn parent_update_src_caps(&self, caps: &gst::CapsRef) -> Result { + fn parent_update_src_caps(&self, caps: &gst::CapsRef) -> Result { unsafe { let klass = self.get_class(); let parent_klass = @@ -333,13 +333,9 @@ pub unsafe trait AggregatorBase: let mut out_caps = ptr::null_mut(); let flow_ret = from_glib(f(self.to_glib_none().0, caps.as_mut_ptr(), &mut out_caps)); - if flow_ret == gst::FlowReturn::Ok { - Ok(from_glib_full(out_caps)) - } else { - Err(flow_ret) - } + flow_ret.into_result_value(|| from_glib_full(out_caps)) }) - .unwrap_or(Err(gst::FlowReturn::Error)) + .unwrap_or(Err(gst::FlowError::Error)) } } diff --git a/gst-plugin/src/base_src.rs b/gst-plugin/src/base_src.rs index 285c6c34..0c725e0a 100644 --- a/gst-plugin/src/base_src.rs +++ b/gst-plugin/src/base_src.rs @@ -62,7 +62,7 @@ where element: &T, offset: u64, length: u32, - ) -> Result { + ) -> Result { element.parent_create(offset, length) } @@ -108,7 +108,7 @@ any_impl!(BaseSrcBase, BaseSrcImpl, PanicPoison); pub unsafe trait BaseSrcBase: IsA + IsA + ObjectType { - fn parent_create(&self, offset: u64, length: u32) -> Result { + fn parent_create(&self, offset: u64, length: u32) -> Result { unsafe { let klass = self.get_class(); let parent_klass = (*klass).get_parent_class() as *const gst_base_ffi::GstBaseSrcClass; @@ -119,12 +119,11 @@ pub unsafe trait BaseSrcBase: // FIXME: Wrong signature in -sys bindings // https://github.com/sdroege/gstreamer-sys/issues/3 let buffer_ref = &mut buffer as *mut _ as *mut gst_ffi::GstBuffer; - match from_glib(f(self.to_glib_none().0, offset, length, buffer_ref)) { - gst::FlowReturn::Ok => Ok(from_glib_full(buffer)), - ret => Err(ret), - } + let ret: gst::FlowReturn = from_glib(f(self.to_glib_none().0, offset, length, buffer_ref)); + + ret.into_result_value(|| from_glib_full(buffer)) }) - .unwrap_or(Err(gst::FlowReturn::Error)) + .unwrap_or(Err(gst::FlowError::Error)) } } @@ -307,7 +306,7 @@ macro_rules! box_base_src_impl( element: &T, offset: u64, length: u32, - ) -> Result { + ) -> Result { let imp: &$name = self.as_ref(); imp.create(element, offset, length) } @@ -495,7 +494,7 @@ where *buffer_ptr = buffer.into_ptr(); gst::FlowReturn::Ok } - Err(err) => err, + Err(err) => gst::FlowReturn::from(err), } }) .to_glib()