diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2021-10-29 14:34:43 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2021-10-29 14:34:43 +0200 |
commit | b5053bfc25fb327776886269e615c2e5dd63fa08 (patch) | |
tree | 1c7e5153b873da2a5cdcfddbff9ab587eb164719 | |
parent | 69b93cb5370e2ba672d8bd7ac5717038c0bf3d47 (diff) | |
download | nihav-player-b5053bfc25fb327776886269e615c2e5dd63fa08.tar.gz |
replace vec.truncate(0) with vec.clear()
-rw-r--r-- | sndplay/src/main.rs | 8 | ||||
-rw-r--r-- | videoplayer/src/audiodec.rs | 2 | ||||
-rw-r--r-- | videoplayer/src/videodec.rs | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/sndplay/src/main.rs b/sndplay/src/main.rs index 39ee76d..618c227 100644 --- a/sndplay/src/main.rs +++ b/sndplay/src/main.rs @@ -107,7 +107,7 @@ struct Decoder<'a> { fn output_vol_i16(device: &AudioDevice, tmp: &mut Vec<i16>, src: &[i16], mute: bool, volume: u8) { if !mute { - tmp.truncate(0); + tmp.clear(); tmp.reserve(src.len()); let vol = i32::from(volume); for &sample in src.iter() { @@ -115,7 +115,7 @@ fn output_vol_i16(device: &AudioDevice, tmp: &mut Vec<i16>, src: &[i16], mute: b tmp.push(nsamp.min(32767).max(-32768) as i16); } } else { - tmp.truncate(0); + tmp.clear(); tmp.resize(src.len(), 0); } device.queue(&tmp); @@ -123,7 +123,7 @@ fn output_vol_i16(device: &AudioDevice, tmp: &mut Vec<i16>, src: &[i16], mute: b fn output_vol_u8(device: &AudioDevice, tmp: &mut Vec<i16>, src: &[u8], mute: bool, volume: u8) { if !mute { - tmp.truncate(0); + tmp.clear(); tmp.reserve(src.len()); let vol = i32::from(volume); for sample in src.chunks_exact(2) { @@ -132,7 +132,7 @@ fn output_vol_u8(device: &AudioDevice, tmp: &mut Vec<i16>, src: &[u8], mute: boo tmp.push(nsamp.min(32767).max(-32768) as i16); } } else { - tmp.truncate(0); + tmp.clear(); tmp.resize(src.len() / 2, 0); } device.queue(&tmp); diff --git a/videoplayer/src/audiodec.rs b/videoplayer/src/audiodec.rs index dcc5649..3045192 100644 --- a/videoplayer/src/audiodec.rs +++ b/videoplayer/src/audiodec.rs @@ -343,7 +343,7 @@ impl AudioControl { pub fn flush(&mut self) { self.pause(); - self.aqueue.truncate(0); + self.aqueue.clear(); SKIP_ADECODING.store(true, Ordering::Release); CURRENT_TIME_SET.store(false, Ordering::Release); let _ = self.apsend.send(PktSendEvent::Flush); diff --git a/videoplayer/src/videodec.rs b/videoplayer/src/videodec.rs index b8867f1..0a1dcd5 100644 --- a/videoplayer/src/videodec.rs +++ b/videoplayer/src/videodec.rs @@ -246,7 +246,7 @@ impl VideoControl { } } pub fn flush(&mut self) { - self.vqueue.truncate(0); + self.vqueue.clear(); SKIP_VDECODING.store(true, Ordering::Release); for _ in 0..8 { let _ = self.vfrecv.try_recv(); |