mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 17:41:05 +00:00
gstreamer-base: update signatures to Result<(), ErrorMessage>
See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/175
This commit is contained in:
parent
5d1a839558
commit
c65214b207
4 changed files with 166 additions and 44 deletions
|
@ -88,11 +88,11 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
timeout: bool,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn start(&self, aggregator: &Aggregator) -> bool {
|
||||
fn start(&self, aggregator: &Aggregator) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start(aggregator)
|
||||
}
|
||||
|
||||
fn stop(&self, aggregator: &Aggregator) -> bool {
|
||||
fn stop(&self, aggregator: &Aggregator) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop(aggregator)
|
||||
}
|
||||
|
||||
|
@ -287,25 +287,45 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_start(&self, aggregator: &Aggregator) -> bool {
|
||||
fn parent_start(&self, aggregator: &Aggregator) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
(*parent_class)
|
||||
.start
|
||||
.map(|f| from_glib(f(aggregator.to_glib_none().0)))
|
||||
.unwrap_or(false)
|
||||
let f = (*parent_class).start.ok_or_else(|| {
|
||||
gst_error_msg!(
|
||||
gst::CoreError::Failed,
|
||||
["Parent function `start` is not defined"]
|
||||
)
|
||||
})?;
|
||||
if from_glib(f(aggregator.to_glib_none().0)) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst_error_msg!(
|
||||
gst::CoreError::Failed,
|
||||
["Parent function `start` failed"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_stop(&self, aggregator: &Aggregator) -> bool {
|
||||
fn parent_stop(&self, aggregator: &Aggregator) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
(*parent_class)
|
||||
.stop
|
||||
.map(|f| from_glib(f(aggregator.to_glib_none().0)))
|
||||
.unwrap_or(false)
|
||||
let f = (*parent_class).stop.ok_or_else(|| {
|
||||
gst_error_msg!(
|
||||
gst::CoreError::Failed,
|
||||
["Parent function `stop` is not defined"]
|
||||
)
|
||||
})?;
|
||||
if from_glib(f(aggregator.to_glib_none().0)) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst_error_msg!(
|
||||
gst::CoreError::Failed,
|
||||
["Parent function `stop` failed"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -635,7 +655,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Aggregator = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.start(&wrap) }).to_glib()
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.start(&wrap) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(&err);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn aggregator_stop<T: ObjectSubclass>(
|
||||
|
@ -650,7 +679,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Aggregator = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.stop(&wrap) }).to_glib()
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.stop(&wrap) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(&err);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn aggregator_get_next_time<T: ObjectSubclass>(
|
||||
|
|
|
@ -23,12 +23,12 @@ use BaseSink;
|
|||
use BaseSinkClass;
|
||||
|
||||
pub trait BaseSinkImpl: ElementImpl + Send + Sync + 'static {
|
||||
fn start(&self, _element: &BaseSink) -> bool {
|
||||
true
|
||||
fn start(&self, _element: &BaseSink) -> Result<(), gst::ErrorMessage> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn stop(&self, _element: &BaseSink) -> bool {
|
||||
true
|
||||
fn stop(&self, _element: &BaseSink) -> Result<(), gst::ErrorMessage> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn render(
|
||||
|
@ -87,12 +87,12 @@ pub trait BaseSinkImpl: ElementImpl + Send + Sync + 'static {
|
|||
self.parent_fixate(element, caps)
|
||||
}
|
||||
|
||||
fn unlock(&self, _element: &BaseSink) -> bool {
|
||||
true
|
||||
fn unlock(&self, _element: &BaseSink) -> Result<(), gst::ErrorMessage> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn unlock_stop(&self, _element: &BaseSink) -> bool {
|
||||
true
|
||||
fn unlock_stop(&self, _element: &BaseSink) -> Result<(), gst::ErrorMessage> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parent_query(&self, element: &BaseSink, query: &mut gst::QueryRef) -> bool {
|
||||
|
@ -207,7 +207,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: BaseSink = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.start(&wrap) }).to_glib()
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.start(&wrap) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(&err);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_sink_stop<T: ObjectSubclass>(
|
||||
|
@ -222,7 +231,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: BaseSink = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.stop(&wrap) }).to_glib()
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.stop(&wrap) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(&err);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_sink_render<T: ObjectSubclass>(
|
||||
|
@ -427,7 +445,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: BaseSink = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.unlock(&wrap) }).to_glib()
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.unlock(&wrap) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(&err);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_sink_unlock_stop<T: ObjectSubclass>(
|
||||
|
@ -443,7 +470,13 @@ where
|
|||
let wrap: BaseSink = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
imp.unlock_stop(&wrap)
|
||||
match imp.unlock_stop(&wrap) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(&err);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ use BaseSrc;
|
|||
use BaseSrcClass;
|
||||
|
||||
pub trait BaseSrcImpl: ElementImpl + Send + Sync + 'static {
|
||||
fn start(&self, _element: &BaseSrc) -> bool {
|
||||
true
|
||||
fn start(&self, _element: &BaseSrc) -> Result<(), gst::ErrorMessage> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn stop(&self, _element: &BaseSrc) -> bool {
|
||||
true
|
||||
fn stop(&self, _element: &BaseSrc) -> Result<(), gst::ErrorMessage> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn is_seekable(&self, _element: &BaseSrc) -> bool {
|
||||
|
@ -86,12 +86,12 @@ pub trait BaseSrcImpl: ElementImpl + Send + Sync + 'static {
|
|||
self.parent_fixate(element, caps)
|
||||
}
|
||||
|
||||
fn unlock(&self, _element: &BaseSrc) -> bool {
|
||||
true
|
||||
fn unlock(&self, _element: &BaseSrc) -> Result<(), gst::ErrorMessage> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn unlock_stop(&self, _element: &BaseSrc) -> bool {
|
||||
true
|
||||
fn unlock_stop(&self, _element: &BaseSrc) -> Result<(), gst::ErrorMessage> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parent_create(
|
||||
|
@ -259,7 +259,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: BaseSrc = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.start(&wrap) }).to_glib()
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.start(&wrap) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(&err);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_src_stop<T: ObjectSubclass>(
|
||||
|
@ -274,7 +283,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: BaseSrc = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.stop(&wrap) }).to_glib()
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.stop(&wrap) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(&err);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_src_is_seekable<T: ObjectSubclass>(
|
||||
|
@ -537,7 +555,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: BaseSrc = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.unlock(&wrap) }).to_glib()
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.unlock(&wrap) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(&err);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_src_unlock_stop<T: ObjectSubclass>(
|
||||
|
@ -553,7 +580,13 @@ where
|
|||
let wrap: BaseSrc = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
imp.unlock_stop(&wrap)
|
||||
match imp.unlock_stop(&wrap) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(&err);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@ use BaseTransform;
|
|||
use BaseTransformClass;
|
||||
|
||||
pub trait BaseTransformImpl: ElementImpl + Send + Sync + 'static {
|
||||
fn start(&self, _element: &BaseTransform) -> bool {
|
||||
true
|
||||
fn start(&self, _element: &BaseTransform) -> Result<(), gst::ErrorMessage> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn stop(&self, _element: &BaseTransform) -> bool {
|
||||
true
|
||||
fn stop(&self, _element: &BaseTransform) -> Result<(), gst::ErrorMessage> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn transform_caps(
|
||||
|
@ -349,7 +349,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: BaseTransform = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.start(&wrap) }).to_glib()
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.start(&wrap) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(&err);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_transform_stop<T: ObjectSubclass>(
|
||||
|
@ -364,7 +373,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: BaseTransform = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.stop(&wrap) }).to_glib()
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.stop(&wrap) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(&err);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_transform_transform_caps<T: ObjectSubclass>(
|
||||
|
|
Loading…
Reference in a new issue