Fix or silence various new 1.57 clippy warnings

This commit is contained in:
Sebastian Dröge 2021-11-30 16:31:50 +02:00
parent f02322bd80
commit c46901d150
19 changed files with 37 additions and 122 deletions

View file

@ -154,9 +154,9 @@ impl AudioRNNoise {
buffer.set_pts(pts); buffer.set_pts(pts);
let mut out_map = buffer.map_writable().map_err(|_| gst::FlowError::Error)?; let mut out_map = buffer.map_writable().map_err(|_| gst::FlowError::Error)?;
let mut out_data = out_map.as_mut_slice_of::<f32>().unwrap(); let out_data = out_map.as_mut_slice_of::<f32>().unwrap();
state.process(in_data, &mut out_data); state.process(in_data, out_data);
} }
let srcpad = element.static_pad("src").unwrap(); let srcpad = element.static_pad("src").unwrap();
@ -189,9 +189,9 @@ impl AudioRNNoise {
buffer.set_pts(pts); buffer.set_pts(pts);
let mut out_map = buffer.map_writable().map_err(|_| gst::FlowError::Error)?; let mut out_map = buffer.map_writable().map_err(|_| gst::FlowError::Error)?;
let mut out_data = out_map.as_mut_slice_of::<f32>().unwrap(); let out_data = out_map.as_mut_slice_of::<f32>().unwrap();
state.process(in_data, &mut out_data); state.process(in_data, out_data);
} }
Ok(GenerateOutputSuccess::Buffer(buffer)) Ok(GenerateOutputSuccess::Buffer(buffer))

View file

@ -90,6 +90,7 @@ pub(crate) struct FragmentHeaderConfiguration<'a> {
start_dts: Option<gst::ClockTime>, start_dts: Option<gst::ClockTime>,
end_pts: gst::ClockTime, end_pts: gst::ClockTime,
end_dts: Option<gst::ClockTime>, end_dts: Option<gst::ClockTime>,
#[allow(dead_code)]
dts_offset: Option<gst::ClockTime>, dts_offset: Option<gst::ClockTime>,
} }

View file

@ -189,7 +189,7 @@ fn test_pull_range() {
// get the seeking capabilities // get the seeking capabilities
let (seekable, start, stop) = q.result(); let (seekable, start, stop) = q.result();
assert_eq!(seekable, true); assert!(seekable);
assert_eq!( assert_eq!(
start, start,
gst::GenericFormattedValue::Bytes(Some(gst::format::Bytes(0))) gst::GenericFormattedValue::Bytes(Some(gst::format::Bytes(0)))

View file

@ -350,21 +350,12 @@ impl Default for State {
} }
} }
#[derive(Debug)] #[derive(Debug, Default)]
struct Pads { struct Pads {
pad_serial: u32, pad_serial: u32,
sink_pads: HashMap<gst::Pad, PadSink>, sink_pads: HashMap<gst::Pad, PadSink>,
} }
impl Default for Pads {
fn default() -> Pads {
Pads {
pad_serial: 0,
sink_pads: HashMap::new(),
}
}
}
#[derive(Debug)] #[derive(Debug)]
pub struct InputSelector { pub struct InputSelector {
src_pad: PadSrc, src_pad: PadSrc,

View file

@ -967,23 +967,13 @@ impl PadSrcHandler for SrcHandler {
} }
} }
#[derive(Debug)] #[derive(Debug, Default)]
struct Stats { struct Stats {
num_pushed: u64, num_pushed: u64,
num_lost: u64, num_lost: u64,
num_late: u64, num_late: u64,
} }
impl Default for Stats {
fn default() -> Self {
Self {
num_pushed: 0,
num_lost: 0,
num_late: 0,
}
}
}
// Shared state between element, sink and source pad // Shared state between element, sink and source pad
struct State { struct State {
jbuf: glib::SendUniqueCell<RTPJitterBuffer>, jbuf: glib::SendUniqueCell<RTPJitterBuffer>,

View file

@ -131,7 +131,6 @@ enum State {
seekable: bool, seekable: bool,
position: u64, position: u64,
size: Option<u64>, size: Option<u64>,
start: u64,
stop: Option<u64>, stop: Option<u64>,
caps: Option<gst::Caps>, caps: Option<gst::Caps>,
tags: Option<gst::TagList>, tags: Option<gst::TagList>,
@ -612,7 +611,6 @@ impl ReqwestHttpSrc {
seekable, seekable,
position, position,
size, size,
start,
stop, stop,
caps, caps,
tags: if tags.n_tags() > 0 { Some(tags) } else { None }, tags: if tags.n_tags() > 0 { Some(tags) } else { None },

View file

@ -56,6 +56,7 @@ pub struct TranscribeParse {
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
struct Alternative { struct Alternative {
#[allow(dead_code)]
confidence: serde_json::Value, confidence: serde_json::Value,
content: String, content: String,
} }
@ -73,6 +74,7 @@ struct Item {
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
struct Results { struct Results {
#[allow(dead_code)]
transcripts: serde_json::Value, transcripts: serde_json::Value,
items: Vec<Item>, items: Vec<Item>,
} }
@ -80,7 +82,9 @@ struct Results {
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
struct Transcript { struct Transcript {
#[allow(dead_code)]
job_name: String, job_name: String,
#[allow(dead_code)]
account_id: String, account_id: String,
results: Results, results: Results,
} }

View file

@ -29,6 +29,7 @@ const CRC: crc::Crc<u32> = crc::Crc::<u32>::new(&crc::CRC_32_ISO_HDLC);
struct Prelude { struct Prelude {
total_bytes: u32, total_bytes: u32,
header_bytes: u32, header_bytes: u32,
#[allow(dead_code)]
prelude_crc: u32, prelude_crc: u32,
} }
@ -41,9 +42,11 @@ pub struct Header {
#[derive(Debug)] #[derive(Debug)]
pub struct Packet<'a> { pub struct Packet<'a> {
#[allow(dead_code)]
prelude: Prelude, prelude: Prelude,
headers: Vec<Header>, headers: Vec<Header>,
pub payload: &'a [u8], pub payload: &'a [u8],
#[allow(dead_code)]
msg_crc: u32, msg_crc: u32,
} }

View file

@ -43,22 +43,13 @@ impl Default for StreamingState {
} }
} }
#[derive(Default)]
struct Settings { struct Settings {
url: Option<GstS3Url>, url: Option<GstS3Url>,
access_key: Option<String>, access_key: Option<String>,
secret_access_key: Option<String>, secret_access_key: Option<String>,
} }
impl Default for Settings {
fn default() -> Self {
Settings {
url: None,
access_key: None,
secret_access_key: None,
}
}
}
#[derive(Default)] #[derive(Default)]
pub struct S3Src { pub struct S3Src {
settings: Mutex<Settings>, settings: Mutex<Settings>,

View file

@ -47,25 +47,11 @@ static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
) )
}); });
#[derive(Debug)] #[derive(Debug, Default)]
struct State { struct State {
start_ts: Option<gst::ClockTime>,
end_ts: Option<gst::ClockTime>,
current_line: String,
format: Option<String>, format: Option<String>,
} }
impl Default for State {
fn default() -> Self {
Self {
start_ts: None,
end_ts: None,
current_line: "".to_string(),
format: None,
}
}
}
pub struct JsonGstEnc { pub struct JsonGstEnc {
srcpad: gst::Pad, srcpad: gst::Pad,
sinkpad: gst::Pad, sinkpad: gst::Pad,

View file

@ -44,16 +44,11 @@ struct Command {
operation: Operation, operation: Operation,
} }
#[derive(Default)]
struct State { struct State {
commands: Vec<Command>, commands: Vec<Command>,
} }
impl Default for State {
fn default() -> Self {
Self { commands: vec![] }
}
}
pub struct RegEx { pub struct RegEx {
srcpad: gst::Pad, srcpad: gst::Pad,
sinkpad: gst::Pad, sinkpad: gst::Pad,

View file

@ -57,23 +57,13 @@ impl std::error::Error for PlaylistError {
} }
/// Number of different streams currently handled by the element /// Number of different streams currently handled by the element
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Default, Clone, PartialEq)]
struct StreamsTopology { struct StreamsTopology {
audio: u32, audio: u32,
video: u32, video: u32,
text: u32, text: u32,
} }
impl Default for StreamsTopology {
fn default() -> Self {
Self {
audio: 0,
video: 0,
text: 0,
}
}
}
impl StreamsTopology { impl StreamsTopology {
fn n_streams(&self) -> u32 { fn n_streams(&self) -> u32 {
self.audio + self.video + self.text self.audio + self.video + self.text
@ -246,7 +236,6 @@ enum ItemState {
stream_selected_msg: Option<gst::Message>, stream_selected_msg: Option<gst::Message>,
concat_sink_pads: Vec<(gst::Element, gst::Pad)>, concat_sink_pads: Vec<(gst::Element, gst::Pad)>,
sender: crossbeam_channel::Sender<bool>, sender: crossbeam_channel::Sender<bool>,
receiver: crossbeam_channel::Receiver<bool>,
}, },
/// Buffers are flowing /// Buffers are flowing
Streaming { Streaming {
@ -544,7 +533,6 @@ impl Item {
ItemState::WaitingForPads { ItemState::WaitingForPads {
uridecodebin, uridecodebin,
sender, sender,
receiver,
stream_collection_msg, stream_collection_msg,
concat_sink_pads, concat_sink_pads,
.. ..
@ -552,7 +540,6 @@ impl Item {
inner.state = ItemState::Blocked { inner.state = ItemState::Blocked {
uridecodebin: uridecodebin.clone(), uridecodebin: uridecodebin.clone(),
sender: sender.clone(), sender: sender.clone(),
receiver: receiver.clone(),
concat_sink_pads: concat_sink_pads.clone(), concat_sink_pads: concat_sink_pads.clone(),
stream_collection_msg: stream_collection_msg.copy(), stream_collection_msg: stream_collection_msg.copy(),
stream_selected_msg: None, stream_selected_msg: None,

View file

@ -78,8 +78,8 @@ pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
gst::Rank::None, gst::Rank::None,
Some("cdg"), Some("cdg"),
Some(&Caps::builder("video/x-cdg").build()), Some(&Caps::builder("video/x-cdg").build()),
|mut typefind| { |typefind| {
let proba = compute_probability(&mut typefind); let proba = compute_probability(typefind);
if proba != gst::TypeFindProbability::None { if proba != gst::TypeFindProbability::None {
typefind.suggest(proba, &Caps::builder("video/x-cdg").build()); typefind.suggest(proba, &Caps::builder("video/x-cdg").build());

View file

@ -52,21 +52,12 @@ impl Default for State {
} }
} }
#[derive(Debug, Clone)] #[derive(Default, Debug, Clone)]
struct Settings { struct Settings {
uuid: Option<String>, uuid: Option<String>,
creation_date: Option<glib::DateTime>, creation_date: Option<glib::DateTime>,
} }
impl Default for Settings {
fn default() -> Self {
Self {
uuid: None,
creation_date: None,
}
}
}
pub struct MccEnc { pub struct MccEnc {
srcpad: gst::Pad, srcpad: gst::Pad,
sinkpad: gst::Pad, sinkpad: gst::Pad,

View file

@ -33,7 +33,7 @@ pub fn digits(s: &[u8]) -> IResult<&[u8], u32> {
use nom::combinator::map_res; use nom::combinator::map_res;
map_res( map_res(
map_res(take_while(is_digit), |s: &[u8]| std::str::from_utf8(s)), map_res(take_while(is_digit), std::str::from_utf8),
|s: &str| s.parse::<u32>(), |s: &str| s.parse::<u32>(),
)(s) )(s)
} }

View file

@ -657,7 +657,7 @@ impl TtToCea608 {
if j == 0 { if j == 0 {
prepend_space = self.open_line( prepend_space = self.open_line(
element, element,
&mut state, state,
settings, settings,
chunk, chunk,
mut_list, mut_list,
@ -665,7 +665,7 @@ impl TtToCea608 {
row as i32, row as i32,
line.carriage_return, line.carriage_return,
); );
} else if self.open_chunk(element, &mut state, chunk, mut_list, col) { } else if self.open_chunk(element, state, chunk, mut_list, col) {
prepend_space = false; prepend_space = false;
col += 1; col += 1;
} }
@ -754,7 +754,7 @@ impl TtToCea608 {
self.open_line( self.open_line(
element, element,
&mut state, state,
settings, settings,
chunk, chunk,
mut_list, mut_list,

View file

@ -32,20 +32,12 @@ fn init() {
}); });
} }
#[derive(Default)]
struct NotifyState { struct NotifyState {
cc608_count: u32, cc608_count: u32,
cc708_count: u32, cc708_count: u32,
} }
impl Default for NotifyState {
fn default() -> Self {
NotifyState {
cc608_count: 0,
cc708_count: 0,
}
}
}
macro_rules! assert_push_data { macro_rules! assert_push_data {
($h:expr, $state:expr, $data:expr, $ts:expr, $cc608_count:expr, $cc708_count:expr) => { ($h:expr, $state:expr, $data:expr, $ts:expr, $cc608_count:expr, $cc708_count:expr) => {
let mut buf = gst::Buffer::from_mut_slice($data); let mut buf = gst::Buffer::from_mut_slice($data);
@ -399,13 +391,10 @@ fn test_gap_events() {
assert_push_data!(h, state, valid_cc608_data, ClockTime::ZERO, 1, 0); assert_push_data!(h, state, valid_cc608_data, ClockTime::ZERO, 1, 0);
/* pushing gap event within the window changes nothing */ /* pushing gap event within the window changes nothing */
assert_eq!( assert!(h.push_event(gst::event::Gap::new(
h.push_event(gst::event::Gap::new( ClockTime::from_nseconds(100_000_000),
ClockTime::from_nseconds(100_000_000), ClockTime::from_nseconds(1)
ClockTime::from_nseconds(1) )),);
)),
true
);
{ {
let state_guard = state.lock().unwrap(); let state_guard = state.lock().unwrap();
@ -414,13 +403,10 @@ fn test_gap_events() {
} }
/* pushing gap event outside the window moves cc608 property to false */ /* pushing gap event outside the window moves cc608 property to false */
assert_eq!( assert!(h.push_event(gst::event::Gap::new(
h.push_event(gst::event::Gap::new( ClockTime::from_nseconds(1_000_000_000),
ClockTime::from_nseconds(1_000_000_000), ClockTime::from_nseconds(1)
ClockTime::from_nseconds(1) )),);
)),
true
);
{ {
let state_guard = state.lock().unwrap(); let state_guard = state.lock().unwrap();

View file

@ -142,7 +142,7 @@ fn test_one_timed_buffer_and_eos() {
} }
} }
assert_eq!(h.events_in_queue() == 1, true); assert_eq!(h.events_in_queue(), 1);
let event = h.pull_event().unwrap(); let event = h.pull_event().unwrap();
assert_eq!(event.type_(), gst::EventType::Eos); assert_eq!(event.type_(), gst::EventType::Eos);

View file

@ -35,20 +35,12 @@ static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
) )
}); });
#[derive(Default)]
struct State { struct State {
buffers: Vec<gst::Buffer>, buffers: Vec<gst::Buffer>,
total_size: usize, total_size: usize,
} }
impl Default for State {
fn default() -> Self {
Self {
buffers: vec![],
total_size: 0,
}
}
}
struct Decoder<'a> { struct Decoder<'a> {
decoder: *mut ffi::WebPAnimDecoder, decoder: *mut ffi::WebPAnimDecoder,
phantom: PhantomData<&'a [u8]>, phantom: PhantomData<&'a [u8]>,