From 5a75f3bf8e43fc5ff2af18f527a84d4bde1d6d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 6 Dec 2021 18:41:39 +0200 Subject: [PATCH] Don't post error messages in subclasses on propose/decide_allocation() errors and BaseParse::set_sink_caps() Instead just log the error and return false. --- gstreamer-audio/src/subclass/audio_decoder.rs | 54 +++++++--------- gstreamer-audio/src/subclass/audio_encoder.rs | 54 +++++++--------- gstreamer-base/src/subclass/aggregator.rs | 64 +++++++++---------- gstreamer-base/src/subclass/base_parse.rs | 27 ++++---- gstreamer-base/src/subclass/base_sink.rs | 27 ++++---- gstreamer-base/src/subclass/base_src.rs | 27 ++++---- gstreamer-base/src/subclass/base_transform.rs | 62 ++++++++---------- gstreamer-video/src/subclass/video_decoder.rs | 54 +++++++--------- gstreamer-video/src/subclass/video_encoder.rs | 54 +++++++--------- 9 files changed, 189 insertions(+), 234 deletions(-) diff --git a/gstreamer-audio/src/subclass/audio_decoder.rs b/gstreamer-audio/src/subclass/audio_decoder.rs index 951853ddf..f178d6d3b 100644 --- a/gstreamer-audio/src/subclass/audio_decoder.rs +++ b/gstreamer-audio/src/subclass/audio_decoder.rs @@ -88,7 +88,7 @@ pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_propose_allocation(element, query) } @@ -96,7 +96,7 @@ pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_decide_allocation(element, query) } } @@ -152,13 +152,13 @@ pub trait AudioDecoderImplExt: ObjectSubclass { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; fn parent_decide_allocation( &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; } impl AudioDecoderImplExt for T { @@ -469,24 +469,21 @@ impl AudioDecoderImplExt for T { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass; (*parent_class) .propose_allocation .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - query.as_mut_ptr(), - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `propose_allocation` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + query.as_mut_ptr(), + ), + gst::CAT_RUST, + "Parent function `propose_allocation` failed", + ) }) .unwrap_or(Ok(())) } @@ -496,24 +493,21 @@ impl AudioDecoderImplExt for T { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass; (*parent_class) .decide_allocation .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - query.as_mut_ptr(), - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `decide_allocation` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + query.as_mut_ptr(), + ), + gst::CAT_RUST, + "Parent function `decide_allocation` failed", + ) }) .unwrap_or(Ok(())) } @@ -835,7 +829,7 @@ unsafe extern "C" fn audio_decoder_propose_allocation( match imp.propose_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } } @@ -859,7 +853,7 @@ unsafe extern "C" fn audio_decoder_decide_allocation( match imp.decide_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } } diff --git a/gstreamer-audio/src/subclass/audio_encoder.rs b/gstreamer-audio/src/subclass/audio_encoder.rs index 6b877d7c1..47d1d1615 100644 --- a/gstreamer-audio/src/subclass/audio_encoder.rs +++ b/gstreamer-audio/src/subclass/audio_encoder.rs @@ -80,7 +80,7 @@ pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_propose_allocation(element, query) } @@ -88,7 +88,7 @@ pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_decide_allocation(element, query) } } @@ -138,13 +138,13 @@ pub trait AudioEncoderImplExt: ObjectSubclass { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; fn parent_decide_allocation( &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; } impl AudioEncoderImplExt for T { @@ -419,24 +419,21 @@ impl AudioEncoderImplExt for T { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass; (*parent_class) .propose_allocation .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - query.as_mut_ptr(), - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `propose_allocation` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + query.as_mut_ptr(), + ), + gst::CAT_RUST, + "Parent function `propose_allocation` failed", + ) }) .unwrap_or(Ok(())) } @@ -446,24 +443,21 @@ impl AudioEncoderImplExt for T { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass; (*parent_class) .decide_allocation .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - query.as_mut_ptr(), - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `decide_allocation` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + query.as_mut_ptr(), + ), + gst::CAT_RUST, + "Parent function `decide_allocation` failed", + ) }) .unwrap_or(Ok(())) } @@ -755,7 +749,7 @@ unsafe extern "C" fn audio_encoder_propose_allocation( match imp.propose_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } } @@ -779,7 +773,7 @@ unsafe extern "C" fn audio_encoder_decide_allocation( match imp.decide_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } } diff --git a/gstreamer-base/src/subclass/aggregator.rs b/gstreamer-base/src/subclass/aggregator.rs index c55e22d95..d755f142c 100644 --- a/gstreamer-base/src/subclass/aggregator.rs +++ b/gstreamer-base/src/subclass/aggregator.rs @@ -155,7 +155,7 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl { pad: &AggregatorPad, decide_query: Option>, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_propose_allocation(element, pad, decide_query, query) } @@ -163,7 +163,7 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_decide_allocation(element, query) } @@ -291,13 +291,13 @@ pub trait AggregatorImplExt: ObjectSubclass { pad: &AggregatorPad, decide_query: Option>, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; fn parent_decide_allocation( &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] @@ -694,29 +694,26 @@ impl AggregatorImplExt for T { pad: &AggregatorPad, decide_query: Option>, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; (*parent_class) .propose_allocation .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - pad.to_glib_none().0, - decide_query - .as_ref() - .map(|q| q.as_mut_ptr()) - .unwrap_or(ptr::null_mut()), - query.as_mut_ptr(), - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `propose_allocation` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + pad.to_glib_none().0, + decide_query + .as_ref() + .map(|q| q.as_mut_ptr()) + .unwrap_or(ptr::null_mut()), + query.as_mut_ptr() + ), + gst::CAT_RUST, + "Parent function `propose_allocation` failed", + ) }) .unwrap_or(Ok(())) } @@ -726,24 +723,21 @@ impl AggregatorImplExt for T { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; (*parent_class) .decide_allocation .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - query.as_mut_ptr(), - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `decide_allocation` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + query.as_mut_ptr(), + ), + gst::CAT_RUST, + "Parent function `decide_allocation` failed", + ) }) .unwrap_or(Ok(())) } @@ -1197,7 +1191,7 @@ unsafe extern "C" fn aggregator_propose_allocation( ) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } } @@ -1221,7 +1215,7 @@ unsafe extern "C" fn aggregator_decide_allocation( match imp.decide_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } } diff --git a/gstreamer-base/src/subclass/base_parse.rs b/gstreamer-base/src/subclass/base_parse.rs index f3f12d8f9..4e6094811 100644 --- a/gstreamer-base/src/subclass/base_parse.rs +++ b/gstreamer-base/src/subclass/base_parse.rs @@ -24,7 +24,7 @@ pub trait BaseParseImpl: BaseParseImplExt + ElementImpl { &self, element: &Self::Type, caps: &gst::Caps, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_set_sink_caps(element, caps) } @@ -55,7 +55,7 @@ pub trait BaseParseImplExt: ObjectSubclass { &self, element: &Self::Type, caps: &gst::Caps, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; fn parent_handle_frame<'a>( &'a self, @@ -116,24 +116,21 @@ impl BaseParseImplExt for T { &self, element: &Self::Type, caps: &gst::Caps, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseParseClass; (*parent_class) .set_sink_caps .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - caps.to_glib_none().0, - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `set_sink_caps` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + caps.to_glib_none().0, + ), + gst::CAT_RUST, + "Parent function `set_sink_caps` failed", + ) }) .unwrap_or(Ok(())) } @@ -259,7 +256,7 @@ unsafe extern "C" fn base_parse_set_sink_caps( match imp.set_sink_caps(wrap.unsafe_cast_ref(), &caps) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } } diff --git a/gstreamer-base/src/subclass/base_sink.rs b/gstreamer-base/src/subclass/base_sink.rs index 7e9feb63e..ffdbc1667 100644 --- a/gstreamer-base/src/subclass/base_sink.rs +++ b/gstreamer-base/src/subclass/base_sink.rs @@ -82,7 +82,7 @@ pub trait BaseSinkImpl: BaseSinkImplExt + ElementImpl { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_propose_allocation(element, query) } } @@ -138,7 +138,7 @@ pub trait BaseSinkImplExt: ObjectSubclass { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; } impl BaseSinkImplExt for T { @@ -404,24 +404,21 @@ impl BaseSinkImplExt for T { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; (*parent_class) .propose_allocation .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - query.as_mut_ptr(), - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `propose_allocation` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + query.as_mut_ptr(), + ), + gst::CAT_RUST, + "Parent function `propose_allocation` failed", + ) }) .unwrap_or(Ok(())) } @@ -682,7 +679,7 @@ unsafe extern "C" fn base_sink_propose_allocation( match imp.propose_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } } diff --git a/gstreamer-base/src/subclass/base_src.rs b/gstreamer-base/src/subclass/base_src.rs index b79714693..97bf536bf 100644 --- a/gstreamer-base/src/subclass/base_src.rs +++ b/gstreamer-base/src/subclass/base_src.rs @@ -112,7 +112,7 @@ pub trait BaseSrcImpl: BaseSrcImplExt + ElementImpl { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_decide_allocation(element, query) } } @@ -181,7 +181,7 @@ pub trait BaseSrcImplExt: ObjectSubclass { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; } impl BaseSrcImplExt for T { @@ -588,24 +588,21 @@ impl BaseSrcImplExt for T { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .decide_allocation .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - query.as_mut_ptr(), - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `decide_allocation` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + query.as_mut_ptr(), + ), + gst::CAT_RUST, + "Parent function `decide_allocation` failed", + ) }) .unwrap_or(Ok(())) } @@ -1031,7 +1028,7 @@ unsafe extern "C" fn base_src_decide_allocation( match imp.decide_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } } diff --git a/gstreamer-base/src/subclass/base_transform.rs b/gstreamer-base/src/subclass/base_transform.rs index 44b0932e5..e72129698 100644 --- a/gstreamer-base/src/subclass/base_transform.rs +++ b/gstreamer-base/src/subclass/base_transform.rs @@ -140,7 +140,7 @@ pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl { element: &Self::Type, decide_query: Option>, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_propose_allocation(element, decide_query, query) } @@ -148,7 +148,7 @@ pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_decide_allocation(element, query) } @@ -279,13 +279,13 @@ pub trait BaseTransformImplExt: ObjectSubclass { element: &Self::Type, decide_query: Option>, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; fn parent_decide_allocation( &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; fn parent_copy_metadata( &self, @@ -719,28 +719,25 @@ impl BaseTransformImplExt for T { element: &Self::Type, decide_query: Option>, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .propose_allocation .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - decide_query - .as_ref() - .map(|q| q.as_mut_ptr()) - .unwrap_or(ptr::null_mut()), - query.as_mut_ptr(), - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `propose_allocation` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + decide_query + .as_ref() + .map(|q| q.as_mut_ptr()) + .unwrap_or(ptr::null_mut()), + query.as_mut_ptr(), + ), + gst::CAT_RUST, + "Parent function `propose_allocation` failed", + ) }) .unwrap_or(Ok(())) } @@ -750,24 +747,21 @@ impl BaseTransformImplExt for T { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .decide_allocation .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - query.as_mut_ptr(), - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `decide_allocation` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + query.as_mut_ptr(), + ), + gst::CAT_RUST, + "Parent function `decide_allocation` failed," + ) }) .unwrap_or(Ok(())) } @@ -1343,7 +1337,7 @@ unsafe extern "C" fn base_transform_propose_allocation( match imp.propose_allocation(wrap.unsafe_cast_ref(), decide_query, query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } } @@ -1367,7 +1361,7 @@ unsafe extern "C" fn base_transform_decide_allocation( match imp.decide_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } } diff --git a/gstreamer-video/src/subclass/video_decoder.rs b/gstreamer-video/src/subclass/video_decoder.rs index a660eceb5..41f297990 100644 --- a/gstreamer-video/src/subclass/video_decoder.rs +++ b/gstreamer-video/src/subclass/video_decoder.rs @@ -92,7 +92,7 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_propose_allocation(element, query) } @@ -100,7 +100,7 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_decide_allocation(element, query) } @@ -167,13 +167,13 @@ pub trait VideoDecoderImplExt: ObjectSubclass { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; fn parent_decide_allocation( &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; #[cfg(any(feature = "v1_20", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] @@ -495,24 +495,21 @@ impl VideoDecoderImplExt for T { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass; (*parent_class) .propose_allocation .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - query.as_mut_ptr(), - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `propose_allocation` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + query.as_mut_ptr(), + ), + gst::CAT_RUST, + "Parent function `propose_allocation` failed", + ) }) .unwrap_or(Ok(())) } @@ -522,24 +519,21 @@ impl VideoDecoderImplExt for T { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass; (*parent_class) .decide_allocation .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - query.as_mut_ptr(), - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `decide_allocation` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + query.as_mut_ptr(), + ), + gst::CAT_RUST, + "Parent function `decide_allocation` failed", + ) }) .unwrap_or(Ok(())) } @@ -883,7 +877,7 @@ unsafe extern "C" fn video_decoder_propose_allocation( match imp.propose_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } } @@ -907,7 +901,7 @@ unsafe extern "C" fn video_decoder_decide_allocation( match imp.decide_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } } diff --git a/gstreamer-video/src/subclass/video_encoder.rs b/gstreamer-video/src/subclass/video_encoder.rs index 020c02b4e..d02d46cd1 100644 --- a/gstreamer-video/src/subclass/video_encoder.rs +++ b/gstreamer-video/src/subclass/video_encoder.rs @@ -78,7 +78,7 @@ pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_propose_allocation(element, query) } @@ -86,7 +86,7 @@ pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { self.parent_decide_allocation(element, query) } } @@ -132,13 +132,13 @@ pub trait VideoEncoderImplExt: ObjectSubclass { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; fn parent_decide_allocation( &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage>; + ) -> Result<(), gst::LoggableError>; } impl VideoEncoderImplExt for T { @@ -411,24 +411,21 @@ impl VideoEncoderImplExt for T { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoEncoderClass; (*parent_class) .propose_allocation .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - query.as_mut_ptr(), - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `propose_allocation` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + query.as_mut_ptr(), + ), + gst::CAT_RUST, + "Parent function `propose_allocation` failed", + ) }) .unwrap_or(Ok(())) } @@ -438,24 +435,21 @@ impl VideoEncoderImplExt for T { &self, element: &Self::Type, query: gst::query::Allocation<&mut gst::QueryRef>, - ) -> Result<(), gst::ErrorMessage> { + ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoEncoderClass; (*parent_class) .decide_allocation .map(|f| { - if from_glib(f( - element.unsafe_cast_ref::().to_glib_none().0, - query.as_mut_ptr(), - )) { - Ok(()) - } else { - Err(gst::error_msg!( - gst::CoreError::StateChange, - ["Parent function `decide_allocation` failed"] - )) - } + gst::result_from_gboolean!( + f( + element.unsafe_cast_ref::().to_glib_none().0, + query.as_mut_ptr(), + ), + gst::CAT_RUST, + "Parent function `decide_allocation` failed", + ) }) .unwrap_or(Ok(())) } @@ -735,7 +729,7 @@ unsafe extern "C" fn video_encoder_propose_allocation( match imp.propose_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } } @@ -759,7 +753,7 @@ unsafe extern "C" fn video_encoder_decide_allocation( match imp.decide_allocation(wrap.unsafe_cast_ref(), query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(err); + err.log_with_object(&*wrap); false } }