]> git.nihav.org Git - nihav-player.git/commitdiff
sndplay: fix clippy warnings
authorKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 27 Jul 2023 16:50:39 +0000 (18:50 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 27 Jul 2023 16:50:39 +0000 (18:50 +0200)
sndplay/src/command.rs
sndplay/src/demux.rs
sndplay/src/main.rs

index b706b9a2f05f9ec9787b6f8e97de1b0a37a24fd7..3aac7cb99d1f7509f91ec2b1f1ad7b1de6697bb6 100644 (file)
@@ -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;
index d40c29c72741b8ff4927c54479c3d20467e22a17..c35167c97ae7bbae7803fe054b833f3b5974a2cc 100644 (file)
@@ -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 {
index 4741853702fc81cedb211964d4b4993eade3d25c..97ed3499590c079d81a385e5ee679a1549273f39 100644 (file)
@@ -118,7 +118,7 @@ fn output_vol_i16(device: &AudioDevice, tmp: &mut Vec<i16>, 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<i16>, src: &[u8], mute: bool, volume: u8) {
@@ -135,7 +135,7 @@ fn output_vol_u8(device: &AudioDevice, tmp: &mut Vec<i16>, 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;
                                     },