Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2023-02-13 12:50:57 +0300
committerSebastian Dröge <sebastian@centricular.com>2023-02-13 12:50:57 +0300
commit04e101c605cf93642f3ebc837ec0dbcc9b4e93d0 (patch)
treed3796e85fc308f847dfc1dd032e04d3234c98584
parent034c0f0fd8f9c87bea0bddf50179cbe5257dfe85 (diff)
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.
-rw-r--r--audio/claxon/src/claxondec/imp.rs4
-rw-r--r--audio/csound/src/filter/imp.rs6
-rw-r--r--audio/spotify/src/spotifyaudiosrc/imp.rs5
-rw-r--r--generic/sodium/src/decrypter/imp.rs10
-rw-r--r--generic/sodium/src/encrypter/imp.rs10
-rw-r--r--net/webrtchttp/src/whepsrc/imp.rs4
-rw-r--r--net/webrtchttp/src/whipsink/imp.rs4
-rw-r--r--utils/uriplaylistbin/src/uriplaylistbin/imp.rs9
-rw-r--r--video/closedcaption/src/ccdetect/imp.rs4
-rw-r--r--video/closedcaption/src/cea608overlay/imp.rs4
-rw-r--r--video/gif/src/gifenc/imp.rs2
-rw-r--r--video/png/src/pngenc/imp.rs12
12 files changed, 34 insertions, 40 deletions
diff --git a/audio/claxon/src/claxondec/imp.rs b/audio/claxon/src/claxondec/imp.rs
index 58f422d9a..001559e33 100644
--- a/audio/claxon/src/claxondec/imp.rs
+++ b/audio/claxon/src/claxondec/imp.rs
@@ -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
})?;
diff --git a/audio/csound/src/filter/imp.rs b/audio/csound/src/filter/imp.rs
index ea0fa4654..6b7a181d0 100644
--- a/audio/csound/src/filter/imp.rs
+++ b/audio/csound/src/filter/imp.rs
@@ -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(())
diff --git a/audio/spotify/src/spotifyaudiosrc/imp.rs b/audio/spotify/src/spotifyaudiosrc/imp.rs
index 05f342431..999313874 100644
--- a/audio/spotify/src/spotifyaudiosrc/imp.rs
+++ b/audio/spotify/src/spotifyaudiosrc/imp.rs
@@ -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(_)) => {}
diff --git a/generic/sodium/src/decrypter/imp.rs b/generic/sodium/src/decrypter/imp.rs
index f01ee29b8..6486f6d05 100644
--- a/generic/sodium/src/decrypter/imp.rs
+++ b/generic/sodium/src/decrypter/imp.rs
@@ -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()]
+ ]
)
})?;
diff --git a/generic/sodium/src/encrypter/imp.rs b/generic/sodium/src/encrypter/imp.rs
index ac1ea1013..f5f72db85 100644
--- a/generic/sodium/src/encrypter/imp.rs
+++ b/generic/sodium/src/encrypter/imp.rs
@@ -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()]
+ ]
)
})?;
diff --git a/net/webrtchttp/src/whepsrc/imp.rs b/net/webrtchttp/src/whepsrc/imp.rs
index 2ee1ac935..e0752ac8c 100644
--- a/net/webrtchttp/src/whepsrc/imp.rs
+++ b/net/webrtchttp/src/whepsrc/imp.rs
@@ -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) {
diff --git a/net/webrtchttp/src/whipsink/imp.rs b/net/webrtchttp/src/whipsink/imp.rs
index 4f30afa65..c1ac7c28e 100644
--- a/net/webrtchttp/src/whipsink/imp.rs
+++ b/net/webrtchttp/src/whipsink/imp.rs
@@ -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) {
diff --git a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs
index 3b6ae3ec6..620d5cb4f 100644
--- a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs
+++ b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs
@@ -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()
);
}
diff --git a/video/closedcaption/src/ccdetect/imp.rs b/video/closedcaption/src/ccdetect/imp.rs
index 1208a08c2..39ea519f9 100644
--- a/video/closedcaption/src/ccdetect/imp.rs
+++ b/video/closedcaption/src/ccdetect/imp.rs
@@ -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,
diff --git a/video/closedcaption/src/cea608overlay/imp.rs b/video/closedcaption/src/cea608overlay/imp.rs
index b6a78f7fd..ce7988d33 100644
--- a/video/closedcaption/src/cea608overlay/imp.rs
+++ b/video/closedcaption/src/cea608overlay/imp.rs
@@ -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 {
diff --git a/video/gif/src/gifenc/imp.rs b/video/gif/src/gifenc/imp.rs
index 67a19474b..c813a809d 100644
--- a/video/gif/src/gifenc/imp.rs
+++ b/video/gif/src/gifenc/imp.rs
@@ -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);
}
}
diff --git a/video/png/src/pngenc/imp.rs b/video/png/src/pngenc/imp.rs
index fc022515e..5adacbdef 100644
--- a/video/png/src/pngenc/imp.rs
+++ b/video/png/src/pngenc/imp.rs
@@ -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
})?;