mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-26 19:08:09 +00:00
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:
parent
20910b2415
commit
25501233ec
3 changed files with 17 additions and 22 deletions
|
@ -492,7 +492,7 @@ impl BaseSrcImpl<BaseSrc> for SineSrc {
|
||||||
element: &BaseSrc,
|
element: &BaseSrc,
|
||||||
_offset: u64,
|
_offset: u64,
|
||||||
_length: u32,
|
_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
|
// 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
|
// 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
|
// 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 {
|
let info = match state.info {
|
||||||
None => {
|
None => {
|
||||||
gst_element_error!(element, gst::CoreError::Negotiation, ["Have no caps yet"]);
|
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(),
|
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 {
|
let n_samples = if let Some(sample_stop) = state.sample_stop {
|
||||||
if sample_stop <= state.sample_offset {
|
if sample_stop <= state.sample_offset {
|
||||||
gst_log!(self.cat, obj: element, "At EOS");
|
gst_log!(self.cat, obj: element, "At EOS");
|
||||||
return Err(gst::FlowReturn::Eos);
|
return Err(gst::FlowError::Eos);
|
||||||
}
|
}
|
||||||
|
|
||||||
sample_stop - state.sample_offset
|
sample_stop - state.sample_offset
|
||||||
|
@ -606,7 +606,7 @@ impl BaseSrcImpl<BaseSrc> for SineSrc {
|
||||||
let mut clock_wait = self.clock_wait.lock().unwrap();
|
let mut clock_wait = self.clock_wait.lock().unwrap();
|
||||||
if clock_wait.flushing {
|
if clock_wait.flushing {
|
||||||
gst_debug!(self.cat, obj: element, "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();
|
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.
|
// and we should return Flushing immediately.
|
||||||
if res == gst::ClockReturn::Unscheduled {
|
if res == gst::ClockReturn::Unscheduled {
|
||||||
gst_debug!(self.cat, obj: element, "Flushing");
|
gst_debug!(self.cat, obj: element, "Flushing");
|
||||||
return Err(gst::FlowReturn::Flushing);
|
return Err(gst::FlowError::Flushing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ where
|
||||||
&self,
|
&self,
|
||||||
aggregator: &T,
|
aggregator: &T,
|
||||||
caps: &gst::CapsRef,
|
caps: &gst::CapsRef,
|
||||||
) -> Result<gst::Caps, gst::FlowReturn> {
|
) -> Result<gst::Caps, gst::FlowError> {
|
||||||
aggregator.parent_update_src_caps(caps)
|
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 {
|
unsafe {
|
||||||
let klass = self.get_class();
|
let klass = self.get_class();
|
||||||
let parent_klass =
|
let parent_klass =
|
||||||
|
@ -333,13 +333,9 @@ pub unsafe trait AggregatorBase:
|
||||||
let mut out_caps = ptr::null_mut();
|
let mut out_caps = ptr::null_mut();
|
||||||
let flow_ret =
|
let flow_ret =
|
||||||
from_glib(f(self.to_glib_none().0, caps.as_mut_ptr(), &mut out_caps));
|
from_glib(f(self.to_glib_none().0, caps.as_mut_ptr(), &mut out_caps));
|
||||||
if flow_ret == gst::FlowReturn::Ok {
|
flow_ret.into_result_value(|| from_glib_full(out_caps))
|
||||||
Ok(from_glib_full(out_caps))
|
|
||||||
} else {
|
|
||||||
Err(flow_ret)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.unwrap_or(Err(gst::FlowReturn::Error))
|
.unwrap_or(Err(gst::FlowError::Error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ where
|
||||||
element: &T,
|
element: &T,
|
||||||
offset: u64,
|
offset: u64,
|
||||||
length: u32,
|
length: u32,
|
||||||
) -> Result<gst::Buffer, gst::FlowReturn> {
|
) -> Result<gst::Buffer, gst::FlowError> {
|
||||||
element.parent_create(offset, length)
|
element.parent_create(offset, length)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ any_impl!(BaseSrcBase, BaseSrcImpl, PanicPoison);
|
||||||
pub unsafe trait BaseSrcBase:
|
pub unsafe trait BaseSrcBase:
|
||||||
IsA<gst::Element> + IsA<gst_base::BaseSrc> + ObjectType
|
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 {
|
unsafe {
|
||||||
let klass = self.get_class();
|
let klass = self.get_class();
|
||||||
let parent_klass = (*klass).get_parent_class() as *const gst_base_ffi::GstBaseSrcClass;
|
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
|
// FIXME: Wrong signature in -sys bindings
|
||||||
// https://github.com/sdroege/gstreamer-sys/issues/3
|
// https://github.com/sdroege/gstreamer-sys/issues/3
|
||||||
let buffer_ref = &mut buffer as *mut _ as *mut gst_ffi::GstBuffer;
|
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)) {
|
let ret: gst::FlowReturn = from_glib(f(self.to_glib_none().0, offset, length, buffer_ref));
|
||||||
gst::FlowReturn::Ok => Ok(from_glib_full(buffer)),
|
|
||||||
ret => Err(ret),
|
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,
|
element: &T,
|
||||||
offset: u64,
|
offset: u64,
|
||||||
length: u32,
|
length: u32,
|
||||||
) -> Result<gst::Buffer, gst::FlowReturn> {
|
) -> Result<gst::Buffer, gst::FlowError> {
|
||||||
let imp: &$name<T> = self.as_ref();
|
let imp: &$name<T> = self.as_ref();
|
||||||
imp.create(element, offset, length)
|
imp.create(element, offset, length)
|
||||||
}
|
}
|
||||||
|
@ -495,7 +494,7 @@ where
|
||||||
*buffer_ptr = buffer.into_ptr();
|
*buffer_ptr = buffer.into_ptr();
|
||||||
gst::FlowReturn::Ok
|
gst::FlowReturn::Ok
|
||||||
}
|
}
|
||||||
Err(err) => err,
|
Err(err) => gst::FlowReturn::from(err),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
|
|
Loading…
Reference in a new issue