From: Kostya Shishkov Date: Thu, 27 Jul 2023 16:50:39 +0000 (+0200) Subject: sndplay: fix clippy warnings X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=9d3219879da0eeefa1efac00529d22dde92e7bbb;p=nihav-player.git sndplay: fix clippy warnings --- diff --git a/sndplay/src/command.rs b/sndplay/src/command.rs index b706b9a..3aac7cb 100644 --- a/sndplay/src/command.rs +++ b/sndplay/src/command.rs @@ -26,7 +26,7 @@ pub struct CmdLineState { } impl CmdLineState { pub fn new() -> Self { - let mut orig_state: termios = unsafe { std::mem::MaybeUninit::uninit().assume_init() }; + let mut orig_state: termios = unsafe { let tmp = std::mem::MaybeUninit::uninit(); tmp.assume_init() }; unsafe { tcgetattr(0, &mut orig_state); } let mut new_state = orig_state; new_state.c_lflag &= !(libc::ECHO | libc::ICANON); @@ -34,7 +34,7 @@ impl CmdLineState { Self { orig_state } } pub fn new_normal() -> Self { - let mut orig_state: termios = unsafe { std::mem::MaybeUninit::uninit().assume_init() }; + let mut orig_state: termios = unsafe { let tmp = std::mem::MaybeUninit::uninit(); tmp.assume_init() }; unsafe { tcgetattr(0, &mut orig_state); } let mut new_state = orig_state; new_state.c_lflag |= libc::ECHO | libc::ICANON; diff --git a/sndplay/src/demux.rs b/sndplay/src/demux.rs index d40c29c..c35167c 100644 --- a/sndplay/src/demux.rs +++ b/sndplay/src/demux.rs @@ -81,7 +81,7 @@ impl<'a> DemuxerObject<'a> { if !is_raw { let res = detect::detect_format(name, br); let (dmx_name, _) = res.unwrap_or(("", detect::DetectionScore::No)); - if dmx_name != "" { + if !dmx_name.is_empty() { println!("trying demuxer {} on {}", dmx_name, name); if let Some(dmx_fact) = reg.dmx_reg.find_demuxer(dmx_name) { br.seek(SeekFrom::Start(0)).unwrap(); @@ -89,7 +89,7 @@ impl<'a> DemuxerObject<'a> { return DemuxerObject::Normal(dmx); } } - if dmx_name != "" { + if !dmx_name.is_empty() { println!("trying raw demuxer {} on {}", dmx_name, name); if let Some(rdmx_fact) = reg.rdmx_reg.find_demuxer(dmx_name) { br.seek(SeekFrom::Start(0)).unwrap(); @@ -138,7 +138,7 @@ impl<'a> DemuxerObject<'a> { break; } } - if pname != "" { + if !pname.is_empty() { println!("found raw stream of type {} for {}", pname, name); let pcreate = reg.pkt_reg.find_packetiser(pname).unwrap(); let mut packetiser = (pcreate)(); @@ -151,10 +151,7 @@ impl<'a> DemuxerObject<'a> { } } pub fn is_none(&self) -> bool { - match *self { - DemuxerObject::None => true, - _ => false, - } + matches!(*self, DemuxerObject::None) } pub fn get_duration(&self) -> u64 { match *self { diff --git a/sndplay/src/main.rs b/sndplay/src/main.rs index 4741853..97ed349 100644 --- a/sndplay/src/main.rs +++ b/sndplay/src/main.rs @@ -118,7 +118,7 @@ fn output_vol_i16(device: &AudioDevice, tmp: &mut Vec, src: &[i16], mute: b tmp.clear(); tmp.resize(src.len(), 0); } - device.queue(&tmp); + device.queue(tmp); } fn output_vol_u8(device: &AudioDevice, tmp: &mut Vec, src: &[u8], mute: bool, volume: u8) { @@ -135,7 +135,7 @@ fn output_vol_u8(device: &AudioDevice, tmp: &mut Vec, src: &[u8], mute: boo tmp.clear(); tmp.resize(src.len() / 2, 0); } - device.queue(&tmp); + device.queue(tmp); } impl<'a> Decoder<'a> { @@ -160,17 +160,17 @@ impl<'a> Decoder<'a> { match out_buf { NABufferType::AudioI16(abuf) => { if !self.mute && self.volume == 100 { - device.queue(&abuf.get_data()); + device.queue(abuf.get_data()); } else { - output_vol_i16(device, self.buf, &abuf.get_data(), self.mute, self.volume); + output_vol_i16(device, self.buf, abuf.get_data(), self.mute, self.volume); } self.samplepos += abuf.get_length() as u64; }, NABufferType::AudioPacked(abuf) => { if !self.mute && self.volume == 100 { - device.queue_bytes(&abuf.get_data()); + device.queue_bytes(abuf.get_data()); } else { - output_vol_u8(device, self.buf, &abuf.get_data(), self.mute, self.volume); + output_vol_u8(device, self.buf, abuf.get_data(), self.mute, self.volume); } self.samplepos += abuf.get_length() as u64; },