Clippy pass

This commit is contained in:
François Laignel 2019-11-24 23:00:27 +01:00
parent ff470e9799
commit bdadf25f5c
11 changed files with 56 additions and 73 deletions

View file

@ -195,7 +195,10 @@ impl VideoDecoderImpl for CdgDec {
query: &mut gst::QueryRef,
) -> Result<(), gst::ErrorMessage> {
if let gst::query::QueryView::Allocation(allocation) = query.view() {
if let Some(_) = allocation.find_allocation_meta::<gst_video::VideoMeta>() {
if allocation
.find_allocation_meta::<gst_video::VideoMeta>()
.is_some()
{
let pools = allocation.get_allocation_pools();
if let Some((ref pool, _, _, _)) = pools.first() {
if let Some(pool) = pool {

View file

@ -673,7 +673,7 @@ impl MccParse {
fn start_task(&self, element: &gst::Element) -> Result<(), gst::LoggableError> {
let element_weak = element.downgrade();
let pad_weak = self.sinkpad.downgrade();
if let Err(_) = self.sinkpad.start_task(move || {
let res = self.sinkpad.start_task(move || {
let element = match element_weak.upgrade() {
Some(element) => element,
None => {
@ -686,7 +686,8 @@ impl MccParse {
let parse = Self::from_instance(&element);
parse.loop_fn(&element);
}) {
});
if res.is_err() {
return Err(gst_loggable_error!(CAT, "Failed to start pad task"));
}
Ok(())
@ -771,24 +772,22 @@ impl MccParse {
}
while let Some(line) = reader.get_line_with_drain(true) {
match parser.parse_line(line, false).map_err(|err| (line, err)) {
Ok(MccLine::Caption(tc, None)) => {
let state = self.state.lock().unwrap();
let (framerate, drop_frame) = parse_timecode_rate(state.timecode_rate)
.map_err(|_| {
gst_loggable_error!(CAT, "Failed to parse timecode rate")
})?;
last_tc = match parse_timecode(framerate, drop_frame, tc) {
Ok(mut timecode) => {
/* We're looking for the total duration */
timecode.increment_frame();
Some(timecode)
}
Err(_) => None,
if let Ok(MccLine::Caption(tc, None)) =
parser.parse_line(line, false).map_err(|err| (line, err))
{
let state = self.state.lock().unwrap();
let (framerate, drop_frame) = parse_timecode_rate(state.timecode_rate)
.map_err(|_| gst_loggable_error!(CAT, "Failed to parse timecode rate"))?;
last_tc = match parse_timecode(framerate, drop_frame, tc) {
Ok(mut timecode) => {
/* We're looking for the total duration */
timecode.increment_frame();
Some(timecode)
}
Err(_) => None,
}
_ => { /* We ignore everything else including errors */ }
}
/* We ignore everything else including errors */
}
if last_tc.is_some() || offset == 0 {

View file

@ -610,7 +610,7 @@ impl AggregatorImpl for FallbackSwitch {
// Otherwise if we have a fallback sinkpad and it has a buffer, then the timeout is going
// to be its running time. We will then either output the buffer or drop it, depending on
// its distance from the last sinkpad time
if let Some(_) = self.sinkpad.peek_buffer() {
if self.sinkpad.peek_buffer().is_some() {
gst_debug!(CAT, obj: agg, "Have buffer on sinkpad, immediate timeout");
0.into()
} else if self.sinkpad.is_eos() {
@ -731,7 +731,7 @@ impl AggregatorImpl for FallbackSwitch {
audio_info.rate(),
audio_info.bpf(),
)
} else if let Some(_) = pad_state.video_info {
} else if pad_state.video_info.is_some() {
segment.clip(pts, pts + duration).map(|(start, stop)| {
{
let buffer = buffer.make_mut();

View file

@ -339,7 +339,7 @@ impl LewtonDec {
audio_info = audio_info.positions(to);
let mut map = [0; 8];
if let Err(_) = gst_audio::get_channel_reorder_map(from, to, &mut map[..channels]) {
if gst_audio::get_channel_reorder_map(from, to, &mut map[..channels]).is_err() {
gst_error!(
CAT,
obj: element,

View file

@ -619,7 +619,7 @@ impl VideoEncoderImpl for Rav1Enc {
gst_loggable_error!(CAT, "Failed to create context: {:?}", err)
})?)
},
video_info: video_info.clone(),
video_info,
});
let output_state = element
@ -638,13 +638,8 @@ impl VideoEncoderImpl for Rav1Enc {
let mut state_guard = self.state.borrow_mut();
if let Some(ref mut state) = *state_guard {
state.context.flush();
loop {
match state.context.receive_packet() {
Ok(_) | Err(data::EncoderStatus::Encoded) => {
gst_debug!(CAT, obj: element, "Dropping packet on flush",);
}
_ => break,
}
while let Ok(_) | Err(data::EncoderStatus::Encoded) = state.context.receive_packet() {
gst_debug!(CAT, obj: element, "Dropping packet on flush",);
}
}

View file

@ -857,11 +857,8 @@ impl ElementImpl for ReqwestHttpSrc {
element: &gst::Element,
transition: gst::StateChange,
) -> Result<gst::StateChangeSuccess, gst::StateChangeError> {
match transition {
gst::StateChange::ReadyToNull => {
*self.client.lock().unwrap() = None;
}
_ => (),
if let gst::StateChange::ReadyToNull = transition {
*self.client.lock().unwrap() = None;
}
self.parent_change_state(element, transition)

View file

@ -191,7 +191,7 @@ impl S3Sink {
}
};
state.completed_parts.push(CompletedPart {
e_tag: output.e_tag.clone(),
e_tag: output.e_tag,
part_number: Some(part_number),
});
gst_info!(CAT, obj: element, "Uploaded part {}", part_number);
@ -374,7 +374,7 @@ impl S3Sink {
fn cancel(&self) {
let mut canceller = self.canceller.lock().unwrap();
if let Some(_) = canceller.take() {
if canceller.take().is_some() {
/* We don't do anything, the Sender will be dropped, and that will cause the
* Receiver to be cancelled */
}
@ -540,19 +540,16 @@ impl BaseSinkImpl for S3Sink {
}
fn event(&self, element: &gst_base::BaseSink, event: gst::Event) -> bool {
match event.view() {
gst::EventView::Eos(_) => {
if let Err(error_message) = self.finalize_upload(element) {
gst_error!(
CAT,
obj: element,
"Failed to finalize the upload: {}",
error_message
);
return false;
}
if let gst::EventView::Eos(_) = event.view() {
if let Err(error_message) = self.finalize_upload(element) {
gst_error!(
CAT,
obj: element,
"Failed to finalize the upload: {}",
error_message
);
return false;
}
_ => (),
}
BaseSinkImplExt::parent_event(self, element, event)

View file

@ -67,7 +67,7 @@ impl S3Src {
fn cancel(&self) {
let mut canceller = self.canceller.lock().unwrap();
if let Some(_) = canceller.take() {
if canceller.take().is_some() {
/* We don't do anything, the Sender will be dropped, and that will cause the
* Receiver to be cancelled */
}
@ -394,18 +394,15 @@ impl BaseSrcImpl for S3Src {
}
fn query(&self, src: &gst_base::BaseSrc, query: &mut gst::QueryRef) -> bool {
match query.view_mut() {
gst::QueryView::Scheduling(ref mut q) => {
q.set(
gst::SchedulingFlags::SEQUENTIAL | gst::SchedulingFlags::BANDWIDTH_LIMITED,
1,
-1,
0,
);
q.add_scheduling_modes(&[gst::PadMode::Push, gst::PadMode::Pull]);
return true;
}
_ => (),
if let gst::QueryView::Scheduling(ref mut q) = query.view_mut() {
q.set(
gst::SchedulingFlags::SEQUENTIAL | gst::SchedulingFlags::BANDWIDTH_LIMITED,
1,
-1,
0,
);
q.add_scheduling_modes(&[gst::PadMode::Push, gst::PadMode::Pull]);
return true;
}
BaseSrcImplExt::parent_query(self, src, query)

View file

@ -326,7 +326,7 @@ impl HandleData for gst::Buffer {
audio_info.rate(),
audio_info.bpf(),
)
} else if let Some(_) = state.video_info {
} else if state.video_info.is_some() {
segment.clip(pts, stop).map(move |(start, stop)| {
{
let buffer = self.make_mut();
@ -1472,9 +1472,9 @@ impl ToggleRecord {
};
if pad == &stream.srcpad {
gst::Iterator::from_vec(vec![stream.sinkpad.clone()])
gst::Iterator::from_vec(vec![stream.sinkpad])
} else {
gst::Iterator::from_vec(vec![stream.srcpad.clone()])
gst::Iterator::from_vec(vec![stream.srcpad])
}
}
}

View file

@ -416,11 +416,8 @@ impl ElementImpl for SineSrc {
let basesrc = element.downcast_ref::<gst_base::BaseSrc>().unwrap();
// Configure live'ness once here just before starting the source
match transition {
gst::StateChange::ReadyToPaused => {
basesrc.set_live(self.settings.lock().unwrap().is_live);
}
_ => (),
if let gst::StateChange::ReadyToPaused = transition {
basesrc.set_live(self.settings.lock().unwrap().is_live);
}
// Call the parent class' implementation of ::change_state()

View file

@ -13,9 +13,7 @@
//! ```rust,ignore
//! extern crate gst_plugin_version_helper;
//!
//! fn main() {
//! gst_plugin_version_helper::get_info()
//! }
//! gst_plugin_version_helper::get_info();
//! ```
//!
//! Inside `lib.rs` of the plugin, the information provided by `get_info` are usable as follows:
@ -101,7 +99,7 @@ pub fn get_info() {
let dt = chrono::Utc.timestamp(timestamp, 0);
commit_date = dt.format("%Y-%m-%d").to_string()
} else if let Ok(release_file) = fs::File::open(release_file) {
let mut cargo_toml = crate_dir.clone();
let mut cargo_toml = crate_dir;
cargo_toml.push("Cargo.toml");
let cargo_toml = fs::File::open(cargo_toml).expect("Can't open Cargo.toml");