Fix some new clippy warnings

This commit is contained in:
Sebastian Dröge 2020-07-28 17:00:48 +03:00
parent 7255c1d204
commit a022bbe260
8 changed files with 23 additions and 32 deletions

View file

@ -290,7 +290,7 @@ impl BaseTransformImpl for AudioEcho {
}
let info = gst_audio::AudioInfo::from_caps(incaps)
.or_else(|_| Err(gst_loggable_error!(CAT, "Failed to parse input caps")))?;
.map_err(|_| gst_loggable_error!(CAT, "Failed to parse input caps"))?;
let max_delay = self.settings.lock().unwrap().max_delay;
let size = max_delay * (info.rate() as u64) / gst::SECOND_VAL;
let buffer_size = size * (info.channels() as u64);

View file

@ -592,19 +592,15 @@ impl BaseTransformImpl for CsoundFilter {
) -> Result<(), gst::LoggableError> {
// Flush previous state
if self.state.lock().unwrap().is_some() {
self.drain(element).or_else(|e| {
Err(gst_loggable_error!(
CAT,
"Error flusing previous state data {:?}",
e
))
self.drain(element).map_err(|e| {
gst_loggable_error!(CAT, "Error flusing previous state data {:?}", e)
})?;
}
let in_info = gst_audio::AudioInfo::from_caps(incaps)
.or_else(|_| Err(gst_loggable_error!(CAT, "Failed to parse input caps")))?;
.map_err(|_| gst_loggable_error!(CAT, "Failed to parse input caps"))?;
let out_info = gst_audio::AudioInfo::from_caps(outcaps)
.or_else(|_| Err(gst_loggable_error!(CAT, "Failed to parse output caps")))?;
.map_err(|_| gst_loggable_error!(CAT, "Failed to parse output caps"))?;
let csound = self.csound.lock().unwrap();

View file

@ -30,11 +30,11 @@ impl FileLocation {
));
}
let path = url.to_file_path().or_else(|_| {
Err(glib::Error::new(
let path = url.to_file_path().map_err(|_| {
glib::Error::new(
gst::URIError::BadUri,
format!("Unsupported URI {}", uri_str).as_str(),
))
)
})?;
FileLocation::try_from(path)

View file

@ -338,7 +338,7 @@ impl TaskInner {
gst_log!(RUNTIME_CAT, "Pushing {:?}", triggering_evt);
triggering_evt_tx.try_send(triggering_evt).or_else(|err| {
triggering_evt_tx.try_send(triggering_evt).map_err(|err| {
let resource_err = if err.is_full() {
gst::ResourceError::NoSpaceLeft
} else {
@ -346,11 +346,11 @@ impl TaskInner {
};
gst_warning!(RUNTIME_CAT, "Unable to send {:?}: {:?}", trigger, err);
Err(TransitionError {
TransitionError {
trigger,
state: self.state,
err_msg: gst_error_msg!(resource_err, ["Unable to send {:?}: {:?}", trigger, err]),
})
}
})?;
Ok(ack_rx)

View file

@ -44,7 +44,7 @@ impl ToString for GstS3Url {
}
pub fn parse_s3_url(url_str: &str) -> Result<GstS3Url, String> {
let url = Url::parse(url_str).or_else(|err| Err(format!("Parse error: {}", err)))?;
let url = Url::parse(url_str).map_err(|err| format!("Parse error: {}", err))?;
if url.scheme() != "s3" {
return Err(format!("Unsupported URI '{}'", url.scheme()));
@ -55,7 +55,7 @@ pub fn parse_s3_url(url_str: &str) -> Result<GstS3Url, String> {
}
let host = url.host_str().unwrap();
let region = Region::from_str(host).or_else(|_| Err(format!("Invalid region '{}'", host)))?;
let region = Region::from_str(host).map_err(|_| format!("Invalid region '{}'", host))?;
let mut path = url
.path_segments()

View file

@ -434,12 +434,8 @@ impl BaseSrcImpl for SineSrc {
) -> Result<(), gst::LoggableError> {
use std::f64::consts::PI;
let info = gst_audio::AudioInfo::from_caps(caps).or_else(|_| {
Err(gst_loggable_error!(
CAT,
"Failed to build `AudioInfo` from caps {}",
caps
))
let info = gst_audio::AudioInfo::from_caps(caps).map_err(|_| {
gst_loggable_error!(CAT, "Failed to build `AudioInfo` from caps {}", caps)
})?;
gst_debug!(CAT, obj: element, "Configuring for caps {}", caps);

View file

@ -410,13 +410,12 @@ The first part that we have to implement, just like last time, is caps negotiati
First of all, we need to get notified whenever the caps that our source is configured for are changing. This will happen once in the very beginning and then whenever the pipeline topology or state changes and new caps would be more optimal for the new situation. This notification happens via the `BaseTransform::set_caps` virtual method.
```rust
fn set_caps(&self, element: &BaseSrc, caps: &gst::Caps) -> bool {
fn set_caps(&self, element: &BaseSrc, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
use std::f64::consts::PI;
let info = match gst_audio::AudioInfo::from_caps(caps) {
None => return false,
Some(info) => info,
};
let info = gst_audio::AudioInfo::from_caps(caps).map_err(|_| {
gst_loggable_error!(CAT, "Failed to build `AudioInfo` from caps {}", caps)
})?;
gst_debug!(CAT, obj: element, "Configuring for caps {}", caps);
@ -457,7 +456,7 @@ First of all, we need to get notified whenever the caps that our source is confi
let _ = element.post_message(&gst::Message::new_latency().src(Some(element)).build());
true
Ok(())
}
```

View file

@ -457,7 +457,7 @@ impl ObjectImpl for FallbackSrc {
// Called whenever a value of a property is read. It can be called
// at any time from any thread.
#[allow(clippy::block_in_if_condition_stmt)]
#[allow(clippy::blocks_in_if_conditions)]
fn get_property(&self, _obj: &glib::Object, id: usize) -> Result<glib::Value, ()> {
let prop = &PROPERTIES[id];
@ -1984,7 +1984,7 @@ impl FallbackSrc {
});
}
#[allow(clippy::block_in_if_condition_stmt)]
#[allow(clippy::blocks_in_if_conditions)]
fn schedule_source_restart_timeout(
&self,
element: &gst::Bin,
@ -2061,7 +2061,7 @@ impl FallbackSrc {
state.source_restart_timeout = Some(timeout);
}
#[allow(clippy::block_in_if_condition_stmt)]
#[allow(clippy::blocks_in_if_conditions)]
fn have_fallback_activated(&self, _element: &gst::Bin, state: &State) -> bool {
let mut have_audio = false;
let mut have_video = false;