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.
This commit is contained in:
Sebastian Dröge 2021-12-06 18:41:39 +02:00
parent ee1a5e8395
commit 5a75f3bf8e
9 changed files with 189 additions and 234 deletions

View file

@ -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<T: AudioDecoderImpl> AudioDecoderImplExt for T {
@ -469,24 +469,21 @@ impl<T: AudioDecoderImpl> 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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
query.as_mut_ptr(),
)) {
Ok(())
} else {
Err(gst::error_msg!(
gst::CoreError::StateChange,
["Parent function `propose_allocation` failed"]
))
}
),
gst::CAT_RUST,
"Parent function `propose_allocation` failed",
)
})
.unwrap_or(Ok(()))
}
@ -496,24 +493,21 @@ impl<T: AudioDecoderImpl> 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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
query.as_mut_ptr(),
)) {
Ok(())
} else {
Err(gst::error_msg!(
gst::CoreError::StateChange,
["Parent function `decide_allocation` failed"]
))
}
),
gst::CAT_RUST,
"Parent function `decide_allocation` failed",
)
})
.unwrap_or(Ok(()))
}
@ -835,7 +829,7 @@ unsafe extern "C" fn audio_decoder_propose_allocation<T: AudioDecoderImpl>(
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<T: AudioDecoderImpl>(
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
Ok(()) => true,
Err(err) => {
wrap.post_error_message(err);
err.log_with_object(&*wrap);
false
}
}

View file

@ -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<T: AudioEncoderImpl> AudioEncoderImplExt for T {
@ -419,24 +419,21 @@ impl<T: AudioEncoderImpl> 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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
query.as_mut_ptr(),
)) {
Ok(())
} else {
Err(gst::error_msg!(
gst::CoreError::StateChange,
["Parent function `propose_allocation` failed"]
))
}
),
gst::CAT_RUST,
"Parent function `propose_allocation` failed",
)
})
.unwrap_or(Ok(()))
}
@ -446,24 +443,21 @@ impl<T: AudioEncoderImpl> 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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
query.as_mut_ptr(),
)) {
Ok(())
} else {
Err(gst::error_msg!(
gst::CoreError::StateChange,
["Parent function `decide_allocation` failed"]
))
}
),
gst::CAT_RUST,
"Parent function `decide_allocation` failed",
)
})
.unwrap_or(Ok(()))
}
@ -755,7 +749,7 @@ unsafe extern "C" fn audio_encoder_propose_allocation<T: AudioEncoderImpl>(
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<T: AudioEncoderImpl>(
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
Ok(()) => true,
Err(err) => {
wrap.post_error_message(err);
err.log_with_object(&*wrap);
false
}
}

View file

@ -155,7 +155,7 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl {
pad: &AggregatorPad,
decide_query: Option<gst::query::Allocation<&gst::QueryRef>>,
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<gst::query::Allocation<&gst::QueryRef>>,
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<T: AggregatorImpl> AggregatorImplExt for T {
pad: &AggregatorPad,
decide_query: Option<gst::query::Allocation<&gst::QueryRef>>,
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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<Aggregator>().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"]
))
}
query.as_mut_ptr()
),
gst::CAT_RUST,
"Parent function `propose_allocation` failed",
)
})
.unwrap_or(Ok(()))
}
@ -726,24 +723,21 @@ impl<T: AggregatorImpl> 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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
query.as_mut_ptr(),
)) {
Ok(())
} else {
Err(gst::error_msg!(
gst::CoreError::StateChange,
["Parent function `decide_allocation` failed"]
))
}
),
gst::CAT_RUST,
"Parent function `decide_allocation` failed",
)
})
.unwrap_or(Ok(()))
}
@ -1197,7 +1191,7 @@ unsafe extern "C" fn aggregator_propose_allocation<T: AggregatorImpl>(
) {
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<T: AggregatorImpl>(
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
Ok(()) => true,
Err(err) => {
wrap.post_error_message(err);
err.log_with_object(&*wrap);
false
}
}

View file

@ -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<T: BaseParseImpl> 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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<BaseParse>().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::CAT_RUST,
"Parent function `set_sink_caps` failed",
)
})
.unwrap_or(Ok(()))
}
@ -259,7 +256,7 @@ unsafe extern "C" fn base_parse_set_sink_caps<T: BaseParseImpl>(
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
}
}

View file

@ -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<T: BaseSinkImpl> BaseSinkImplExt for T {
@ -404,24 +404,21 @@ impl<T: BaseSinkImpl> 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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
query.as_mut_ptr(),
)) {
Ok(())
} else {
Err(gst::error_msg!(
gst::CoreError::StateChange,
["Parent function `propose_allocation` failed"]
))
}
),
gst::CAT_RUST,
"Parent function `propose_allocation` failed",
)
})
.unwrap_or(Ok(()))
}
@ -682,7 +679,7 @@ unsafe extern "C" fn base_sink_propose_allocation<T: BaseSinkImpl>(
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
Ok(()) => true,
Err(err) => {
wrap.post_error_message(err);
err.log_with_object(&*wrap);
false
}
}

View file

@ -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<T: BaseSrcImpl> BaseSrcImplExt for T {
@ -588,24 +588,21 @@ impl<T: BaseSrcImpl> 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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
query.as_mut_ptr(),
)) {
Ok(())
} else {
Err(gst::error_msg!(
gst::CoreError::StateChange,
["Parent function `decide_allocation` failed"]
))
}
),
gst::CAT_RUST,
"Parent function `decide_allocation` failed",
)
})
.unwrap_or(Ok(()))
}
@ -1031,7 +1028,7 @@ unsafe extern "C" fn base_src_decide_allocation<T: BaseSrcImpl>(
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
Ok(()) => true,
Err(err) => {
wrap.post_error_message(err);
err.log_with_object(&*wrap);
false
}
}

View file

@ -140,7 +140,7 @@ pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl {
element: &Self::Type,
decide_query: Option<gst::query::Allocation<&gst::QueryRef>>,
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<gst::query::Allocation<&gst::QueryRef>>,
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<T: BaseTransformImpl> BaseTransformImplExt for T {
element: &Self::Type,
decide_query: Option<gst::query::Allocation<&gst::QueryRef>>,
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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<BaseTransform>().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::CAT_RUST,
"Parent function `propose_allocation` failed",
)
})
.unwrap_or(Ok(()))
}
@ -750,24 +747,21 @@ impl<T: BaseTransformImpl> 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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
query.as_mut_ptr(),
)) {
Ok(())
} else {
Err(gst::error_msg!(
gst::CoreError::StateChange,
["Parent function `decide_allocation` failed"]
))
}
),
gst::CAT_RUST,
"Parent function `decide_allocation` failed,"
)
})
.unwrap_or(Ok(()))
}
@ -1343,7 +1337,7 @@ unsafe extern "C" fn base_transform_propose_allocation<T: BaseTransformImpl>(
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<T: BaseTransformImpl>(
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
Ok(()) => true,
Err(err) => {
wrap.post_error_message(err);
err.log_with_object(&*wrap);
false
}
}

View file

@ -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<T: VideoDecoderImpl> 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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
query.as_mut_ptr(),
)) {
Ok(())
} else {
Err(gst::error_msg!(
gst::CoreError::StateChange,
["Parent function `propose_allocation` failed"]
))
}
),
gst::CAT_RUST,
"Parent function `propose_allocation` failed",
)
})
.unwrap_or(Ok(()))
}
@ -522,24 +519,21 @@ impl<T: VideoDecoderImpl> 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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
query.as_mut_ptr(),
)) {
Ok(())
} else {
Err(gst::error_msg!(
gst::CoreError::StateChange,
["Parent function `decide_allocation` failed"]
))
}
),
gst::CAT_RUST,
"Parent function `decide_allocation` failed",
)
})
.unwrap_or(Ok(()))
}
@ -883,7 +877,7 @@ unsafe extern "C" fn video_decoder_propose_allocation<T: VideoDecoderImpl>(
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<T: VideoDecoderImpl>(
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
Ok(()) => true,
Err(err) => {
wrap.post_error_message(err);
err.log_with_object(&*wrap);
false
}
}

View file

@ -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<T: VideoEncoderImpl> VideoEncoderImplExt for T {
@ -411,24 +411,21 @@ impl<T: VideoEncoderImpl> 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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
query.as_mut_ptr(),
)) {
Ok(())
} else {
Err(gst::error_msg!(
gst::CoreError::StateChange,
["Parent function `propose_allocation` failed"]
))
}
),
gst::CAT_RUST,
"Parent function `propose_allocation` failed",
)
})
.unwrap_or(Ok(()))
}
@ -438,24 +435,21 @@ impl<T: VideoEncoderImpl> 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(
gst::result_from_gboolean!(
f(
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
query.as_mut_ptr(),
)) {
Ok(())
} else {
Err(gst::error_msg!(
gst::CoreError::StateChange,
["Parent function `decide_allocation` failed"]
))
}
),
gst::CAT_RUST,
"Parent function `decide_allocation` failed",
)
})
.unwrap_or(Ok(()))
}
@ -735,7 +729,7 @@ unsafe extern "C" fn video_encoder_propose_allocation<T: VideoEncoderImpl>(
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<T: VideoEncoderImpl>(
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
Ok(()) => true,
Err(err) => {
wrap.post_error_message(err);
err.log_with_object(&*wrap);
false
}
}