From b08a101cc6c302ac1e80b8f688885a3c09f444c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 2 Aug 2017 20:15:16 +0300 Subject: [PATCH] Fix clippy warnings in the examples --- examples/src/bin/appsink.rs | 11 ++++------- examples/src/bin/appsrc.rs | 11 ++++------- examples/src/bin/decodebin.rs | 2 +- examples/src/bin/pad_probes.rs | 27 ++++++++++++--------------- 4 files changed, 21 insertions(+), 30 deletions(-) diff --git a/examples/src/bin/appsink.rs b/examples/src/bin/appsink.rs index 81fd8822b..8bcc34805 100644 --- a/examples/src/bin/appsink.rs +++ b/examples/src/bin/appsink.rs @@ -3,9 +3,6 @@ use gst::*; extern crate gstreamer_app as gst_app; use gst_app::*; -extern crate glib; -use glib::*; - use std::u64; use std::i16; use std::i32; @@ -24,10 +21,10 @@ fn main() { appsink.set_caps(&Caps::new_simple( "audio/x-raw", &[ - (&"format", &"S16BE"), - (&"layout", &"interleaved"), - (&"channels", &(1i32)), - (&"rate", &IntRange::::new(1, i32::MAX)), + ("format", &"S16BE"), + ("layout", &"interleaved"), + ("channels", &(1i32)), + ("rate", &IntRange::::new(1, i32::MAX)), ], )); diff --git a/examples/src/bin/appsrc.rs b/examples/src/bin/appsrc.rs index 9a423b081..627de2f3b 100644 --- a/examples/src/bin/appsrc.rs +++ b/examples/src/bin/appsrc.rs @@ -3,9 +3,6 @@ use gst::*; extern crate gstreamer_app as gst_app; use gst_app::*; -extern crate glib; -use glib::*; - use std::u64; use std::thread; @@ -27,10 +24,10 @@ fn main() { appsrc.set_caps(&Caps::new_simple( "video/x-raw", &[ - (&"format", &"BGRx"), - (&"width", &(WIDTH as i32)), - (&"height", &(HEIGHT as i32)), - (&"framerate", &Fraction::new(2, 1)), + ("format", &"BGRx"), + ("width", &(WIDTH as i32)), + ("height", &(HEIGHT as i32)), + ("framerate", &Fraction::new(2, 1)), ], )); appsrc.set_property_format(Format::Time); diff --git a/examples/src/bin/decodebin.rs b/examples/src/bin/decodebin.rs index 1f7a87ce2..ac7285837 100644 --- a/examples/src/bin/decodebin.rs +++ b/examples/src/bin/decodebin.rs @@ -29,7 +29,7 @@ fn main() { // Need to move a new reference into the closure let pipeline_clone = pipeline.clone(); decodebin.connect_pad_added(move |_, src_pad| { - let ref pipeline = pipeline_clone; + let pipeline = &pipeline_clone; let (is_audio, is_video) = { let caps = src_pad.get_current_caps().unwrap(); diff --git a/examples/src/bin/pad_probes.rs b/examples/src/bin/pad_probes.rs index 39be48f64..4a12bc3c5 100644 --- a/examples/src/bin/pad_probes.rs +++ b/examples/src/bin/pad_probes.rs @@ -20,21 +20,18 @@ fn main() { .unwrap(); let src_pad = src.get_static_pad("src").unwrap(); src_pad.add_probe(PAD_PROBE_TYPE_BUFFER, |_, probe_info| { - match probe_info.data { - Some(PadProbeData::Buffer(ref buffer)) => { - let map = buffer.map_read().unwrap(); - let data = map.as_slice(); - let sum: f64 = data.chunks(2) - .map(|sample| { - let u: u16 = ((sample[0] as u16) << 8) | (sample[1] as u16); - let f = (u as i16 as f64) / (i16::MAX as f64); - f * f - }) - .sum(); - let rms = (sum / ((data.len() / 2) as f64)).sqrt(); - println!("rms: {}", rms); - } - _ => (), + if let Some(PadProbeData::Buffer(ref buffer)) = probe_info.data { + let map = buffer.map_read().unwrap(); + let data = map.as_slice(); + let sum: f64 = data.chunks(2) + .map(|sample| { + let u: u16 = ((sample[0] as u16) << 8) | (sample[1] as u16); + let f = (u as i16 as f64) / (i16::MAX as f64); + f * f + }) + .sum(); + let rms = (sum / ((data.len() / 2) as f64)).sqrt(); + println!("rms: {}", rms); } PadProbeReturn::Ok