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() {
tmp.push(nsamp.min(32767).max(-32768) as i16);
}
} else {
- tmp.truncate(0);
+ tmp.clear();
tmp.resize(src.len(), 0);
}
device.queue(&tmp);
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) {
tmp.push(nsamp.min(32767).max(-32768) as i16);
}
} else {
- tmp.truncate(0);
+ tmp.clear();
tmp.resize(src.len() / 2, 0);
}
device.queue(&tmp);
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);
}
}
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();