Fix various clippy warnings

This commit is contained in:
Sebastian Dröge 2018-10-11 13:49:10 +03:00
parent 162311d2f1
commit f2deb2264b
13 changed files with 61 additions and 61 deletions

View file

@ -274,7 +274,7 @@ impl BaseTransformImpl<BaseTransform> for AudioEcho {
let buffer_size = size * (info.channels() as u64);
*self.state.lock().unwrap() = Some(State {
info: info,
info,
buffer: RingBuffer::new(buffer_size as usize),
});
@ -353,10 +353,10 @@ impl<'a> RingBufferIter<'a> {
let buffer = &mut buffer.buffer;
RingBufferIter {
buffer: buffer,
buffer_pos: buffer_pos,
read_pos: read_pos,
write_pos: write_pos,
buffer,
buffer_pos,
read_pos,
write_pos,
}
}
}

View file

@ -102,7 +102,7 @@ impl SinkImpl for FileSink {
gst_debug!(self.cat, obj: sink, "Opened file {:?}", file);
self.streaming_state = StreamingState::Started {
file: file,
file,
position: 0,
};

View file

@ -113,7 +113,7 @@ impl SourceImpl for FileSrc {
gst_debug!(self.cat, obj: src, "Opened file {:?}", file);
self.streaming_state = StreamingState::Started {
file: file,
file,
position: 0,
};

View file

@ -129,14 +129,12 @@ impl AudioFormat {
}
fn update_with_metadata(&mut self, metadata: &Metadata) -> bool {
let mut changed = false;
if self.bitrate != metadata.audio_bitrate {
self.bitrate = metadata.audio_bitrate;
changed = true;
true
} else {
false
}
changed
}
fn to_caps(&self) -> Option<gst::Caps> {
@ -233,18 +231,18 @@ impl AudioFormat {
};
if self.rate != 0 {
caps.as_mut().map(|c| {
c.get_mut()
if let Some(ref mut caps) = caps.as_mut() {
caps.get_mut()
.unwrap()
.set_simple(&[("rate", &(self.rate as i32))])
});
}
}
if self.channels != 0 {
caps.as_mut().map(|c| {
c.get_mut()
if let Some(ref mut caps) = caps.as_mut() {
caps.get_mut()
.unwrap()
.set_simple(&[("channels", &(self.channels as i32))])
});
}
}
caps
@ -338,32 +336,32 @@ impl VideoFormat {
};
if let (Some(width), Some(height)) = (self.width, self.height) {
caps.as_mut().map(|c| {
c.get_mut()
if let Some(ref mut caps) = caps.as_mut() {
caps.get_mut()
.unwrap()
.set_simple(&[("width", &(width as i32)), ("height", &(height as i32))])
});
}
}
if let Some(par) = self.pixel_aspect_ratio {
if *par.numer() != 0 && par.numer() != par.denom() {
caps.as_mut().map(|c| {
c.get_mut().unwrap().set_simple(&[(
if let Some(ref mut caps) = caps.as_mut() {
caps.get_mut().unwrap().set_simple(&[(
"pixel-aspect-ratio",
&gst::Fraction::new(*par.numer(), *par.denom()),
)])
});
}
}
}
if let Some(fps) = self.framerate {
if *fps.numer() != 0 {
caps.as_mut().map(|c| {
c.get_mut().unwrap().set_simple(&[(
if let Some(ref mut caps) = caps.as_mut() {
caps.get_mut().unwrap().set_simple(&[(
"framerate",
&gst::Fraction::new(*fps.numer(), *fps.denom()),
)])
});
}
}
}
@ -1091,7 +1089,7 @@ impl FlvDemux {
impl DemuxerImpl for FlvDemux {
fn start(
&mut self,
demuxer: &Element,
_demuxer: &Element,
_upstream_size: Option<u64>,
_random_access: bool,
) -> Result<(), gst::ErrorMessage> {
@ -1100,7 +1098,7 @@ impl DemuxerImpl for FlvDemux {
Ok(())
}
fn stop(&mut self, demuxer: &Element) -> Result<(), gst::ErrorMessage> {
fn stop(&mut self, _demuxer: &Element) -> Result<(), gst::ErrorMessage> {
self.state = State::Stopped;
self.adapter.clear();
self.streaming_state = None;
@ -1110,9 +1108,9 @@ impl DemuxerImpl for FlvDemux {
fn seek(
&mut self,
demuxer: &Element,
start: gst::ClockTime,
stop: gst::ClockTime,
_demuxer: &Element,
_start: gst::ClockTime,
_stop: gst::ClockTime,
) -> Result<SeekResult, gst::ErrorMessage> {
unimplemented!();
}
@ -1129,16 +1127,16 @@ impl DemuxerImpl for FlvDemux {
self.update_state(demuxer)
}
fn end_of_stream(&mut self, demuxer: &Element) -> Result<(), gst::ErrorMessage> {
fn end_of_stream(&mut self, _demuxer: &Element) -> Result<(), gst::ErrorMessage> {
// nothing to do here, all data we have left is incomplete
Ok(())
}
fn is_seekable(&self, demuxer: &Element) -> bool {
fn is_seekable(&self, _demuxer: &Element) -> bool {
false
}
fn get_position(&self, demuxer: &Element) -> gst::ClockTime {
fn get_position(&self, _demuxer: &Element) -> gst::ClockTime {
if let Some(StreamingState { last_position, .. }) = self.streaming_state {
return last_position;
}
@ -1146,7 +1144,7 @@ impl DemuxerImpl for FlvDemux {
gst::CLOCK_TIME_NONE
}
fn get_duration(&self, demuxer: &Element) -> gst::ClockTime {
fn get_duration(&self, _demuxer: &Element) -> gst::ClockTime {
if let Some(StreamingState {
metadata: Some(Metadata { duration, .. }),
..

View file

@ -131,13 +131,13 @@ impl HttpSrc {
gst_debug!(cat, obj: src, "Request successful: {:?}", response);
Ok(StreamingState::Started {
uri: uri,
response: response,
seekable: seekable,
uri,
response,
seekable,
position: 0,
size: size,
start: start,
stop: stop,
size,
start,
stop,
})
}
}

View file

@ -82,9 +82,9 @@ pub struct Stream {
impl Stream {
pub fn new(index: StreamIndex, caps: gst::Caps, stream_id: String) -> Stream {
Stream {
index: index,
caps: caps,
stream_id: stream_id,
index,
caps,
stream_id,
}
}
}
@ -138,7 +138,7 @@ impl Demuxer {
gst::DebugColorFlags::empty(),
"Rust demuxer base class",
),
sinkpad: sinkpad,
sinkpad,
flow_combiner: Mutex::new(Default::default()),
group_id: Mutex::new(gst::util_group_id_next()),
srcpads: Mutex::new(BTreeMap::new()),
@ -671,7 +671,7 @@ pub fn demuxer_register(plugin: &gst::Plugin, demuxer_info: DemuxerInfo) {
let demuxer_static = DemuxerStatic {
name: format!("Demuxer-{}", name),
demuxer_info: demuxer_info,
demuxer_info,
};
let type_ = register_type(demuxer_static);

View file

@ -22,7 +22,7 @@ pub struct UriError {
impl UriError {
pub fn new<T: Into<String>>(error: gst::URIError, message: T) -> UriError {
UriError {
error: error,
error,
message: message.into(),
}
}

View file

@ -294,7 +294,7 @@ pub fn sink_register(plugin: &gst::Plugin, sink_info: SinkInfo) {
let sink_static = SinkStatic {
name: format!("Sink-{}", name),
sink_info: sink_info,
sink_info,
};
let type_ = register_type(sink_static);

View file

@ -378,7 +378,7 @@ pub fn source_register(plugin: &gst::Plugin, source_info: SourceInfo) {
let source_static = SourceStatic {
name: format!("Source-{}", name),
source_info: source_info,
source_info,
};
let type_ = register_type(source_static);

View file

@ -80,8 +80,8 @@ impl Eq for Stream {}
impl Stream {
fn new(sinkpad: gst::Pad, srcpad: gst::Pad) -> Self {
Self {
sinkpad: sinkpad,
srcpad: srcpad,
sinkpad,
srcpad,
state: Arc::new(Mutex::new(StreamState::default())),
}
}
@ -193,7 +193,7 @@ impl ToggleRecord {
),
settings: Mutex::new(Settings::default()),
state: Mutex::new(State::default()),
main_stream: main_stream,
main_stream,
main_stream_cond: Condvar::new(),
other_streams: Mutex::new((Vec::new(), 0)),
pads: Mutex::new(pads),

View file

@ -354,8 +354,8 @@ impl BaseTransformImpl<BaseTransform> for Rgb2Gray {
);
*self.state.lock().unwrap() = Some(State {
in_info: in_info,
out_info: out_info,
in_info,
out_info,
});
true

View file

@ -418,9 +418,9 @@ impl BaseSrcImpl<BaseSrc> for SineSrc {
*state = State {
info: Some(info),
sample_offset: sample_offset,
sample_stop: sample_stop,
accumulator: accumulator,
sample_offset,
sample_stop,
accumulator,
};
drop(state);
@ -720,9 +720,9 @@ impl BaseSrcImpl<BaseSrc> for SineSrc {
*state = State {
info: state.info.clone(),
sample_offset: sample_offset,
sample_stop: sample_stop,
accumulator: accumulator,
sample_offset,
sample_stop,
accumulator,
};
true

View file

@ -6,6 +6,8 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
extern crate byteorder;
pub extern crate glib_sys as glib_ffi;