Use FlowError instead of FlowReturn as error part of Result

This prevents the possibility of a Result that is an Err(Ok), which
would not be meaningful.
This commit is contained in:
Arun Raghavan 2018-10-29 15:12:54 +00:00 committed by Sebastian Dröge
parent 20910b2415
commit 25501233ec
3 changed files with 17 additions and 22 deletions

View file

@ -492,7 +492,7 @@ impl BaseSrcImpl<BaseSrc> for SineSrc {
element: &BaseSrc,
_offset: u64,
_length: u32,
) -> Result<gst::Buffer, gst::FlowReturn> {
) -> Result<gst::Buffer, gst::FlowError> {
// 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<BaseSrc> 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<BaseSrc> 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<BaseSrc> 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<BaseSrc> 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);
}
}

View file

@ -108,7 +108,7 @@ where
&self,
aggregator: &T,
caps: &gst::CapsRef,
) -> Result<gst::Caps, gst::FlowReturn> {
) -> Result<gst::Caps, gst::FlowError> {
aggregator.parent_update_src_caps(caps)
}
@ -322,7 +322,7 @@ pub unsafe trait AggregatorBase:
}
}
fn parent_update_src_caps(&self, caps: &gst::CapsRef) -> Result<gst::Caps, gst::FlowReturn> {
fn parent_update_src_caps(&self, caps: &gst::CapsRef) -> Result<gst::Caps, gst::FlowError> {
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))
}
}

View file

@ -62,7 +62,7 @@ where
element: &T,
offset: u64,
length: u32,
) -> Result<gst::Buffer, gst::FlowReturn> {
) -> Result<gst::Buffer, gst::FlowError> {
element.parent_create(offset, length)
}
@ -108,7 +108,7 @@ any_impl!(BaseSrcBase, BaseSrcImpl, PanicPoison);
pub unsafe trait BaseSrcBase:
IsA<gst::Element> + IsA<gst_base::BaseSrc> + ObjectType
{
fn parent_create(&self, offset: u64, length: u32) -> Result<gst::Buffer, gst::FlowReturn> {
fn parent_create(&self, offset: u64, length: u32) -> Result<gst::Buffer, gst::FlowError> {
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<gst::Buffer, gst::FlowReturn> {
) -> Result<gst::Buffer, gst::FlowError> {
let imp: &$name<T> = 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()