From 22c5f93d3b2ded6089fdebd3224c8119053533f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 20 Dec 2017 21:36:50 +0200 Subject: [PATCH] Fix various clippy warnings --- gst-plugin-audiofx/src/audioecho.rs | 5 +-- gst-plugin-audiofx/src/lib.rs | 1 - gst-plugin-file/src/filesink.rs | 2 -- gst-plugin-file/src/filesrc.rs | 1 - gst-plugin-flv/src/flvdemux.rs | 31 +++++++------------ gst-plugin-flv/src/lib.rs | 1 - gst-plugin-http/src/httpsrc.rs | 1 - gst-plugin-simple/src/demuxer.rs | 1 - gst-plugin-simple/src/lib.rs | 1 - gst-plugin-simple/src/sink.rs | 1 - gst-plugin-simple/src/source.rs | 1 - .../examples/gtk_recording.rs | 4 +-- gst-plugin-togglerecord/src/togglerecord.rs | 2 +- gst-plugin-togglerecord/tests/tests.rs | 25 +++++++-------- gst-plugin/src/adapter.rs | 2 +- gst-plugin/src/base_sink.rs | 1 - gst-plugin/src/base_src.rs | 1 - gst-plugin/src/base_transform.rs | 1 - gst-plugin/src/error.rs | 5 --- gst-plugin/src/uri_handler.rs | 1 - 20 files changed, 29 insertions(+), 59 deletions(-) diff --git a/gst-plugin-audiofx/src/audioecho.rs b/gst-plugin-audiofx/src/audioecho.rs index 0095f629..5db734f9 100644 --- a/gst-plugin-audiofx/src/audioecho.rs +++ b/gst-plugin-audiofx/src/audioecho.rs @@ -9,10 +9,7 @@ use glib; use gst; use gst::prelude::*; -use gst_base; -use gst_base::prelude::*; use gst_audio; -use gst_audio::prelude::*; use gst_plugin::properties::*; use gst_plugin::object::*; @@ -27,7 +24,7 @@ use byte_slice_cast::*; use num_traits::float::Float; use num_traits::cast::{FromPrimitive, ToPrimitive}; -const DEFAULT_MAX_DELAY: u64 = 1 * gst::SECOND_VAL; +const DEFAULT_MAX_DELAY: u64 = gst::SECOND_VAL; const DEFAULT_DELAY: u64 = 500 * gst::MSECOND_VAL; const DEFAULT_INTENSITY: f64 = 0.5; const DEFAULT_FEEDBACK: f64 = 0.0; diff --git a/gst-plugin-audiofx/src/lib.rs b/gst-plugin-audiofx/src/lib.rs index e33d1179..838aab08 100644 --- a/gst-plugin-audiofx/src/lib.rs +++ b/gst-plugin-audiofx/src/lib.rs @@ -12,7 +12,6 @@ extern crate byte_slice_cast; extern crate glib; #[macro_use] extern crate gst_plugin; -#[macro_use] extern crate gstreamer as gst; extern crate gstreamer_audio as gst_audio; extern crate gstreamer_base as gst_base; diff --git a/gst-plugin-file/src/filesink.rs b/gst-plugin-file/src/filesink.rs index a562ff13..6e107a67 100644 --- a/gst-plugin-file/src/filesink.rs +++ b/gst-plugin-file/src/filesink.rs @@ -11,14 +11,12 @@ use std::fs::File; use url::Url; use std::io::Write; -use std::convert::From; use gst_plugin::error::*; use gst_plugin_simple::sink::*; use gst_plugin_simple::UriValidator; use gst; -use gst::prelude::*; #[derive(Debug)] enum StreamingState { diff --git a/gst-plugin-file/src/filesrc.rs b/gst-plugin-file/src/filesrc.rs index bdec1d4d..b75711d6 100644 --- a/gst-plugin-file/src/filesrc.rs +++ b/gst-plugin-file/src/filesrc.rs @@ -16,7 +16,6 @@ use gst_plugin_simple::source::*; use gst_plugin_simple::UriValidator; use gst; -use gst::prelude::*; #[derive(Debug)] enum StreamingState { diff --git a/gst-plugin-flv/src/flvdemux.rs b/gst-plugin-flv/src/flvdemux.rs index b072db26..e1cdf213 100644 --- a/gst-plugin-flv/src/flvdemux.rs +++ b/gst-plugin-flv/src/flvdemux.rs @@ -21,7 +21,6 @@ use gst_plugin::element::*; use gst_plugin_simple::demuxer::*; use gst; -use gst::prelude::*; use num_rational::Rational32; @@ -97,14 +96,14 @@ impl AudioFormat { aac_sequence_header: &Option, ) -> AudioFormat { let numeric_rate = match (data_header.sound_format, data_header.sound_rate) { - (flavors::SoundFormat::NELLYMOSER_16KHZ_MONO, _) => 16000, - (flavors::SoundFormat::NELLYMOSER_8KHZ_MONO, _) => 8000, - (flavors::SoundFormat::MP3_8KHZ, _) => 8000, - (flavors::SoundFormat::SPEEX, _) => 16000, - (_, flavors::SoundRate::_5_5KHZ) => 5512, - (_, flavors::SoundRate::_11KHZ) => 11025, - (_, flavors::SoundRate::_22KHZ) => 22050, - (_, flavors::SoundRate::_44KHZ) => 44100, + (flavors::SoundFormat::NELLYMOSER_16KHZ_MONO, _) => 16_000, + (flavors::SoundFormat::NELLYMOSER_8KHZ_MONO, _) => 8_000, + (flavors::SoundFormat::MP3_8KHZ, _) => 8_000, + (flavors::SoundFormat::SPEEX, _) => 16_000, + (_, flavors::SoundRate::_5_5KHZ) => 5_512, + (_, flavors::SoundRate::_11KHZ) => 11_025, + (_, flavors::SoundRate::_22KHZ) => 22_050, + (_, flavors::SoundRate::_44KHZ) => 44_100, }; let numeric_width = match data_header.sound_size { @@ -188,7 +187,7 @@ impl AudioFormat { data.write_all(&[0; 14]).unwrap(); data.write_u32le(1).unwrap(); // version data.write_u32le(80).unwrap(); // header size - data.write_u32le(16000).unwrap(); // sample rate + data.write_u32le(16_000).unwrap(); // sample rate data.write_u32le(1).unwrap(); // mode = wideband data.write_u32le(4).unwrap(); // mode bitstream version data.write_u32le(1).unwrap(); // channels @@ -1026,9 +1025,7 @@ impl FlvDemux { } let tag_header = match flavors::tag_header(&data[4..]) { - IResult::Error(_) | IResult::Incomplete(_) => { - unimplemented!(); - } + IResult::Error(_) | IResult::Incomplete(_) => unimplemented!(), IResult::Done(_, tag_header) => tag_header, }; @@ -1042,9 +1039,7 @@ impl FlvDemux { gst_trace!(self.cat, obj: demuxer, "Found audio tag"); let data_header = match flavors::audio_data_header(&data[15..]) { - IResult::Error(_) | IResult::Incomplete(_) => { - unimplemented!(); - } + IResult::Error(_) | IResult::Incomplete(_) => unimplemented!(), IResult::Done(_, data_header) => data_header, }; @@ -1054,9 +1049,7 @@ impl FlvDemux { gst_trace!(self.cat, obj: demuxer, "Found video tag"); let data_header = match flavors::video_data_header(&data[15..]) { - IResult::Error(_) | IResult::Incomplete(_) => { - unimplemented!(); - } + IResult::Error(_) | IResult::Incomplete(_) => unimplemented!(), IResult::Done(_, data_header) => data_header, }; diff --git a/gst-plugin-flv/src/lib.rs b/gst-plugin-flv/src/lib.rs index 50132a6a..df3dcd63 100644 --- a/gst-plugin-flv/src/lib.rs +++ b/gst-plugin-flv/src/lib.rs @@ -20,7 +20,6 @@ extern crate num_rational; extern crate url; use gst_plugin_simple::demuxer::*; -use gst::prelude::*; mod flvdemux; diff --git a/gst-plugin-http/src/httpsrc.rs b/gst-plugin-http/src/httpsrc.rs index 86c266b8..729e5e1b 100644 --- a/gst-plugin-http/src/httpsrc.rs +++ b/gst-plugin-http/src/httpsrc.rs @@ -18,7 +18,6 @@ use gst_plugin_simple::source::*; use gst_plugin_simple::UriValidator; use gst; -use gst::prelude::*; #[derive(Debug)] enum StreamingState { diff --git a/gst-plugin-simple/src/demuxer.rs b/gst-plugin-simple/src/demuxer.rs index 4ae8c5aa..fff18e7c 100644 --- a/gst-plugin-simple/src/demuxer.rs +++ b/gst-plugin-simple/src/demuxer.rs @@ -19,7 +19,6 @@ use gst_plugin::element::*; use gst; use gst::prelude::*; use gst_base; -use gst_base::prelude::*; pub type StreamIndex = u32; diff --git a/gst-plugin-simple/src/lib.rs b/gst-plugin-simple/src/lib.rs index 25e2c37c..7c3c4a4b 100644 --- a/gst-plugin-simple/src/lib.rs +++ b/gst-plugin-simple/src/lib.rs @@ -7,7 +7,6 @@ // except according to those terms. extern crate glib; -#[macro_use] extern crate gst_plugin; #[macro_use] extern crate gstreamer as gst; diff --git a/gst-plugin-simple/src/sink.rs b/gst-plugin-simple/src/sink.rs index ceabefd6..8884452f 100644 --- a/gst-plugin-simple/src/sink.rs +++ b/gst-plugin-simple/src/sink.rs @@ -13,7 +13,6 @@ use url::Url; use glib; use gst; use gst::prelude::*; -use gst_base; use gst_base::prelude::*; use gst_plugin::object::*; diff --git a/gst-plugin-simple/src/source.rs b/gst-plugin-simple/src/source.rs index fa622941..056817c7 100644 --- a/gst-plugin-simple/src/source.rs +++ b/gst-plugin-simple/src/source.rs @@ -15,7 +15,6 @@ use url::Url; use glib; use gst; use gst::prelude::*; -use gst_base; use gst_base::prelude::*; use gst_plugin::object::*; diff --git a/gst-plugin-togglerecord/examples/gtk_recording.rs b/gst-plugin-togglerecord/examples/gtk_recording.rs index 51fe3006..be2b7cb9 100644 --- a/gst-plugin-togglerecord/examples/gtk_recording.rs +++ b/gst-plugin-togglerecord/examples/gtk_recording.rs @@ -227,14 +227,14 @@ fn create_ui(app: >k::Application) { let position = video_sink .query_position::() - .unwrap_or(0.into()); + .unwrap_or_else(|| 0.into()); position_label.set_text(&format!("Position: {:.1}", position)); let recording_duration = togglerecord .get_static_pad("src") .unwrap() .query_position::() - .unwrap_or(0.into()); + .unwrap_or_else(|| 0.into()); recorded_duration_label.set_text(&format!("Recorded: {:.1}", recording_duration)); glib::Continue(true) diff --git a/gst-plugin-togglerecord/src/togglerecord.rs b/gst-plugin-togglerecord/src/togglerecord.rs index ab293192..0a89fb32 100644 --- a/gst-plugin-togglerecord/src/togglerecord.rs +++ b/gst-plugin-togglerecord/src/togglerecord.rs @@ -271,7 +271,7 @@ impl ToggleRecord { .downcast::() .unwrap(); let togglerecord = element.get_impl().downcast_ref::().unwrap(); - element.catch_panic(fallback, |element| f(togglerecord, &element)) + element.catch_panic(fallback, |element| f(togglerecord, element)) } fn set_pad_functions(sinkpad: &gst::Pad, srcpad: &gst::Pad) { diff --git a/gst-plugin-togglerecord/tests/tests.rs b/gst-plugin-togglerecord/tests/tests.rs index 3cee1c26..1c96e1d0 100644 --- a/gst-plugin-togglerecord/tests/tests.rs +++ b/gst-plugin-togglerecord/tests/tests.rs @@ -173,10 +173,9 @@ fn setup_sender_receiver( i += 1; }, SendData::Gaps(n) => for _ in 0..n { - let event = gst::Event::new_gap( - (offset + i * 20 * gst::MSECOND).into(), - (20 * gst::MSECOND).into(), - ).build(); + let event = + gst::Event::new_gap(offset + i * 20 * gst::MSECOND, 20 * gst::MSECOND) + .build(); let _ = sinkpad.send_event(event); i += 1; }, @@ -215,7 +214,7 @@ fn recv_buffers( EventView::Gap(ref e) => { let (ts, _) = e.get(); - res.push((segment.to_running_time(ts), ts.into())); + res.push((segment.to_running_time(ts), ts)); n_buffers += 1; if wait_buffers > 0 && n_buffers == wait_buffers { return res; @@ -433,7 +432,7 @@ fn test_one_stream_open_close_open() { let pts_off = if index >= 10 { 10 * 20 * gst::MSECOND } else { - 0 * gst::MSECOND + 0.into() }; let index = index as u64; @@ -813,7 +812,7 @@ fn test_two_stream_open_close_open() { let pts_off = if index >= 10 { 10 * 20 * gst::MSECOND } else { - 0 * gst::MSECOND + 0.into() }; let index = index as u64; @@ -829,7 +828,7 @@ fn test_two_stream_open_close_open() { let pts_off = if index >= 10 { 10 * 20 * gst::MSECOND } else { - 0 * gst::MSECOND + 0.into() }; let index = index as u64; @@ -914,7 +913,7 @@ fn test_two_stream_open_close_open_gaps() { let pts_off = if index >= 10 { 10 * 20 * gst::MSECOND } else { - 0 * gst::MSECOND + 0.into() }; let index = index as u64; @@ -930,7 +929,7 @@ fn test_two_stream_open_close_open_gaps() { let pts_off = if index >= 10 { 10 * 20 * gst::MSECOND } else { - 0 * gst::MSECOND + 0.into() }; let index = index as u64; @@ -1113,7 +1112,7 @@ fn test_three_stream_open_close_open() { let pts_off = if index >= 10 { 10 * 20 * gst::MSECOND } else { - 0 * gst::MSECOND + 0.into() }; let index = index as u64; @@ -1129,7 +1128,7 @@ fn test_three_stream_open_close_open() { let pts_off = if index >= 10 { 10 * 20 * gst::MSECOND } else { - 0 * gst::MSECOND + 0.into() }; let index = index as u64; @@ -1144,7 +1143,7 @@ fn test_three_stream_open_close_open() { let pts_off = if index >= 10 { 10 * 20 * gst::MSECOND } else { - 0 * gst::MSECOND + 0.into() }; let index = index as u64; diff --git a/gst-plugin/src/adapter.rs b/gst-plugin/src/adapter.rs index ddebde02..2e5a1f57 100644 --- a/gst-plugin/src/adapter.rs +++ b/gst-plugin/src/adapter.rs @@ -13,7 +13,6 @@ use std::fmt; use std::error::Error; use gst; -use gst::prelude::*; lazy_static! { static ref CAT: gst::DebugCategory = { @@ -25,6 +24,7 @@ lazy_static! { }; } +#[derive(Default, Debug)] pub struct Adapter { deque: VecDeque>, size: usize, diff --git a/gst-plugin/src/base_sink.rs b/gst-plugin/src/base_sink.rs index 7df41471..4e1d3d3c 100644 --- a/gst-plugin/src/base_sink.rs +++ b/gst-plugin/src/base_sink.rs @@ -19,7 +19,6 @@ use glib::translate::*; use gst; use gst::prelude::*; use gst_base; -use gst_base::prelude::*; use object::*; use element::*; diff --git a/gst-plugin/src/base_src.rs b/gst-plugin/src/base_src.rs index 55b44e16..0f963c12 100644 --- a/gst-plugin/src/base_src.rs +++ b/gst-plugin/src/base_src.rs @@ -19,7 +19,6 @@ use glib::translate::*; use gst; use gst::prelude::*; use gst_base; -use gst_base::prelude::*; use object::*; use element::*; diff --git a/gst-plugin/src/base_transform.rs b/gst-plugin/src/base_transform.rs index 3af3d91b..39516f0a 100644 --- a/gst-plugin/src/base_transform.rs +++ b/gst-plugin/src/base_transform.rs @@ -19,7 +19,6 @@ use glib::translate::*; use gst; use gst::prelude::*; use gst_base; -use gst_base::prelude::*; use object::*; use element::*; diff --git a/gst-plugin/src/error.rs b/gst-plugin/src/error.rs index 5bdb9a64..f98b2257 100644 --- a/gst-plugin/src/error.rs +++ b/gst-plugin/src/error.rs @@ -10,13 +10,8 @@ use std::error::Error; use std::fmt::{Display, Formatter}; use std::fmt::Error as FmtError; -use glib_ffi; -use gst_ffi; - use glib; -use glib::translate::ToGlibPtr; use gst; -use gst::prelude::*; #[derive(Clone, Debug, PartialEq, Eq)] pub enum FlowError { diff --git a/gst-plugin/src/uri_handler.rs b/gst-plugin/src/uri_handler.rs index 7a8a818b..4f088747 100644 --- a/gst-plugin/src/uri_handler.rs +++ b/gst-plugin/src/uri_handler.rs @@ -15,7 +15,6 @@ use libc; use glib; use glib::translate::*; use gst; -use gst::prelude::*; use object::*; use anyimpl::*;