mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-22 03:21:00 +00:00
Optimize various error message / debug message formatting
Directly make use of format strings instead of formatting a string beforehand and then passing it to the macros.
This commit is contained in:
parent
034c0f0fd8
commit
04e101c605
12 changed files with 34 additions and 40 deletions
|
@ -209,12 +209,12 @@ impl ClaxonDec {
|
|||
indata: &[u8],
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let streaminfo = claxon_streaminfo(indata).map_err(|e| {
|
||||
gst::element_imp_error!(self, gst::StreamError::Decode, [e]);
|
||||
gst::element_imp_error!(self, gst::StreamError::Decode, ["{e}"]);
|
||||
gst::FlowError::Error
|
||||
})?;
|
||||
|
||||
let audio_info = gstaudioinfo(&streaminfo).map_err(|e| {
|
||||
gst::element_imp_error!(self, gst::StreamError::Decode, [&e]);
|
||||
gst::element_imp_error!(self, gst::StreamError::Decode, ["{e}"]);
|
||||
gst::FlowError::Error
|
||||
})?;
|
||||
|
||||
|
|
|
@ -144,11 +144,11 @@ impl CsoundFilter {
|
|||
if let Some(ref location) = settings.location {
|
||||
csound
|
||||
.compile_csd(location)
|
||||
.map_err(|e| error_msg!(gst::LibraryError::Failed, [e]))?;
|
||||
.map_err(|e| error_msg!(gst::LibraryError::Failed, ["{e}"]))?;
|
||||
} else if let Some(ref text) = settings.csd_text {
|
||||
csound
|
||||
.compile_csd_text(text)
|
||||
.map_err(|e| error_msg!(gst::LibraryError::Failed, [e]))?;
|
||||
.map_err(|e| error_msg!(gst::LibraryError::Failed, ["{e}"]))?;
|
||||
} else {
|
||||
return Err(error_msg!(
|
||||
gst::LibraryError::Failed,
|
||||
|
@ -470,7 +470,7 @@ impl BaseTransformImpl for CsoundFilter {
|
|||
csound.set_score_offset_seconds(settings.offset);
|
||||
|
||||
if let Err(e) = csound.start() {
|
||||
return Err(error_msg!(gst::LibraryError::Failed, [e]));
|
||||
return Err(error_msg!(gst::LibraryError::Failed, ["{e}"]));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -324,9 +324,8 @@ impl PushSrcImpl for SpotifyAudioSrc {
|
|||
return Err(gst::FlowError::Flushing);
|
||||
}
|
||||
Ok(Err(err)) => {
|
||||
let details = format!("{err:?}");
|
||||
gst::error!(CAT, imp: self, "failed to start: {}", details);
|
||||
gst::element_imp_error!(self, gst::ResourceError::Settings, [&details]);
|
||||
gst::error!(CAT, imp: self, "failed to start: {err:?}");
|
||||
gst::element_imp_error!(self, gst::ResourceError::Settings, ["{err:?}"]);
|
||||
return Err(gst::FlowError::Error);
|
||||
}
|
||||
Ok(Ok(_)) => {}
|
||||
|
|
|
@ -61,11 +61,10 @@ impl State {
|
|||
.ok_or_else(|| {
|
||||
gst::error_msg!(
|
||||
gst::ResourceError::NotFound,
|
||||
[format!(
|
||||
[
|
||||
"Failed to set Sender's Key from property: {:?}",
|
||||
props.sender_key
|
||||
)
|
||||
.as_ref()]
|
||||
]
|
||||
)
|
||||
})?;
|
||||
|
||||
|
@ -76,11 +75,10 @@ impl State {
|
|||
.ok_or_else(|| {
|
||||
gst::error_msg!(
|
||||
gst::ResourceError::NotFound,
|
||||
[format!(
|
||||
[
|
||||
"Failed to set Receiver's Key from property: {:?}",
|
||||
props.receiver_key
|
||||
)
|
||||
.as_ref()]
|
||||
]
|
||||
)
|
||||
})?;
|
||||
|
||||
|
|
|
@ -76,11 +76,10 @@ impl State {
|
|||
.ok_or_else(|| {
|
||||
gst::error_msg!(
|
||||
gst::ResourceError::NotFound,
|
||||
[format!(
|
||||
[
|
||||
"Failed to set Sender's Key from property: {:?}",
|
||||
props.sender_key
|
||||
)
|
||||
.as_ref()]
|
||||
]
|
||||
)
|
||||
})?;
|
||||
|
||||
|
@ -91,11 +90,10 @@ impl State {
|
|||
.ok_or_else(|| {
|
||||
gst::error_msg!(
|
||||
gst::ResourceError::NotFound,
|
||||
[format!(
|
||||
[
|
||||
"Failed to set Receiver's Key from property: {:?}",
|
||||
props.receiver_key
|
||||
)
|
||||
.as_ref()]
|
||||
]
|
||||
)
|
||||
})?;
|
||||
|
||||
|
|
|
@ -403,8 +403,8 @@ impl BinImpl for WhepSrc {
|
|||
|
||||
impl WhepSrc {
|
||||
fn raise_error(&self, resource_error: gst::ResourceError, msg: String) {
|
||||
gst::error_msg!(resource_error, [msg.as_str()]);
|
||||
gst::element_imp_error!(self, resource_error, [msg.as_str()]);
|
||||
gst::error_msg!(resource_error, ["{msg}"]);
|
||||
gst::element_imp_error!(self, resource_error, ["{msg}"]);
|
||||
}
|
||||
|
||||
fn handle_future_error(&self, err: WaitError) {
|
||||
|
|
|
@ -499,8 +499,8 @@ impl ObjectSubclass for WhipSink {
|
|||
|
||||
impl WhipSink {
|
||||
fn raise_error(&self, resource_error: gst::ResourceError, msg: String) {
|
||||
gst::error_msg!(resource_error, [msg.as_str()]);
|
||||
gst::element_imp_error!(self, resource_error, [msg.as_str()]);
|
||||
gst::error_msg!(resource_error, ["{msg}"]);
|
||||
gst::element_imp_error!(self, resource_error, ["{msg}"]);
|
||||
}
|
||||
|
||||
fn handle_future_error(&self, err: WaitError) {
|
||||
|
|
|
@ -1623,14 +1623,13 @@ impl UriPlaylistBin {
|
|||
blocked.set_streaming(state.streams_topology.n_streams());
|
||||
}
|
||||
}
|
||||
let error_msg = error.to_string();
|
||||
gst::error!(CAT, imp: self, "{}", error_msg);
|
||||
gst::error!(CAT, imp: self, "{error}");
|
||||
|
||||
match error {
|
||||
PlaylistError::PluginMissing { .. } => {
|
||||
gst::element_imp_error!(self, gst::CoreError::MissingPlugin, [&error_msg]);
|
||||
gst::element_imp_error!(self, gst::CoreError::MissingPlugin, ["{error}"]);
|
||||
}
|
||||
PlaylistError::ItemFailed { item, .. } => {
|
||||
PlaylistError::ItemFailed { ref item, .. } => {
|
||||
// remove failing uridecodebin
|
||||
let uridecodebin = item.uridecodebin();
|
||||
uridecodebin.call_async(move |uridecodebin| {
|
||||
|
@ -1644,7 +1643,7 @@ impl UriPlaylistBin {
|
|||
gst::element_imp_error!(
|
||||
self,
|
||||
gst::LibraryError::Failed,
|
||||
[&error_msg],
|
||||
["{error}"],
|
||||
details: details.build()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -363,8 +363,8 @@ impl BaseTransformImpl for CCDetect {
|
|||
let cc_packet = match self.detect(format, map.as_slice()) {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
gst::warning!(CAT, imp: self, "{}", &e.to_string());
|
||||
gst::element_imp_warning!(self, gst::StreamError::Decode, [&e.to_string()]);
|
||||
gst::warning!(CAT, imp: self, "{e}");
|
||||
gst::element_imp_warning!(self, gst::StreamError::Decode, ["{e}"]);
|
||||
CCPacketContents {
|
||||
cc608: false,
|
||||
cc708: false,
|
||||
|
|
|
@ -419,8 +419,8 @@ impl Cea608Overlay {
|
|||
self.decode_cc_data(pad, &mut state, data, pts);
|
||||
}
|
||||
Err(e) => {
|
||||
gst::warning!(CAT, "{}", &e.to_string());
|
||||
gst::element_imp_warning!(self, gst::StreamError::Decode, [&e.to_string()]);
|
||||
gst::warning!(CAT, "{e}");
|
||||
gst::element_imp_warning!(self, gst::StreamError::Decode, ["{e}"]);
|
||||
}
|
||||
}
|
||||
} else if meta.caption_type() == gst_video::VideoCaptionType::Cea708Raw {
|
||||
|
|
|
@ -380,7 +380,7 @@ impl VideoEncoderImpl for GifEnc {
|
|||
// encode new frame
|
||||
let context = state.context.as_mut().unwrap();
|
||||
if let Err(e) = context.write_frame(&gif_frame) {
|
||||
gst::element_imp_error!(self, gst::CoreError::Failed, [&e.to_string()]);
|
||||
gst::element_imp_error!(self, gst::CoreError::Failed, ["{e}"]);
|
||||
return Err(gst::FlowError::Error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,8 +232,8 @@ impl VideoEncoderImpl for PngEncoder {
|
|||
encoder.set_filter(png::FilterType::from(settings.filter));
|
||||
|
||||
let mut writer = encoder.write_header().map_err(|e| {
|
||||
gst::error!(CAT, imp: self, "Failed to create encoder: {}", e);
|
||||
gst::element_imp_error!(self, gst::CoreError::Failed, [&e.to_string()]);
|
||||
gst::error!(CAT, imp: self, "Failed to create encoder: {e}");
|
||||
gst::element_imp_error!(self, gst::CoreError::Failed, ["{e}"]);
|
||||
gst::FlowError::Error
|
||||
})?;
|
||||
|
||||
|
@ -241,15 +241,15 @@ impl VideoEncoderImpl for PngEncoder {
|
|||
let input_buffer = frame.input_buffer().expect("frame without input buffer");
|
||||
let input_map = input_buffer.map_readable().unwrap();
|
||||
writer.write_image_data(&input_map).map_err(|e| {
|
||||
gst::error!(CAT, imp: self, "Failed to write image data: {}", e);
|
||||
gst::element_imp_error!(self, gst::CoreError::Failed, [&e.to_string()]);
|
||||
gst::error!(CAT, imp: self, "Failed to write image data: {e}");
|
||||
gst::element_imp_error!(self, gst::CoreError::Failed, ["{e}"]);
|
||||
gst::FlowError::Error
|
||||
})?;
|
||||
}
|
||||
|
||||
writer.finish().map_err(|e| {
|
||||
gst::error!(CAT, imp: self, "Failed to finish encoder: {}", e);
|
||||
gst::element_imp_error!(self, gst::CoreError::Failed, [&e.to_string()]);
|
||||
gst::error!(CAT, imp: self, "Failed to finish encoder: {e}");
|
||||
gst::element_imp_error!(self, gst::CoreError::Failed, ["{e}"]);
|
||||
gst::FlowError::Error
|
||||
})?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue