From 07adcf5ecffae73e77166cf0d58cf0f7d7bbc6ad Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Wed, 8 Feb 2023 16:44:27 +0100 Subject: [PATCH] livesync: Extract LiveSync::flow_error And add details so it behaves more like the `GST_ELEMENT_FLOW_ERROR` macro. Part-of: --- utils/livesync/src/livesync/imp.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/utils/livesync/src/livesync/imp.rs b/utils/livesync/src/livesync/imp.rs index 9fc22257..fb8bc3f9 100644 --- a/utils/livesync/src/livesync/imp.rs +++ b/utils/livesync/src/livesync/imp.rs @@ -624,13 +624,7 @@ impl LiveSync { if let Err(err) = state.srcresult { if matches!(err, gst::FlowError::Flushing | gst::FlowError::Eos) { - let err = state.srcresult.unwrap_err(); - gst::element_imp_error!( - self, - gst::StreamError::Failed, - ("Internal data flow error."), - ["streaming task paused, reason {} ({:?})", err, err] - ); + self.flow_error(err); } } @@ -952,12 +946,7 @@ impl LiveSync { } if eos && !matches!(err, gst::FlowError::Flushing | gst::FlowError::Eos) { - gst::element_imp_error!( - self, - gst::StreamError::Failed, - ("Internal data flow error."), - ["streaming task paused, reason {} ({:?})", err, err] - ); + self.flow_error(err); pad.push_event(gst::event::Eos::new()); } @@ -1239,4 +1228,18 @@ impl LiveSync { true } + + /// Produces a message like GST_ELEMENT_FLOW_ERROR does + fn flow_error(&self, err: gst::FlowError) { + let details = gst::Structure::builder("details") + .field("flow-return", err.into_glib()) + .build(); + gst::element_imp_error!( + self, + gst::StreamError::Failed, + ("Internal data flow error."), + ["streaming task paused, reason {} ({:?})", err, err], + details: details + ); + } }