X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=sndplay%2Fsrc%2Fmain.rs;h=618c2271b14c9950d8d6429a93ce0d542baf0ec6;hb=b5053bfc25fb327776886269e615c2e5dd63fa08;hp=a5fc6ff29b2648b44a69442d883d91e5c81fc82f;hpb=5a92ee55d90571333184392ebb240581c990d18e;p=nihav-player.git diff --git a/sndplay/src/main.rs b/sndplay/src/main.rs index a5fc6ff..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, 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, 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, src: &[i16], mute: b fn output_vol_u8(device: &AudioDevice, tmp: &mut Vec, 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, 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); @@ -147,6 +147,9 @@ impl<'a> Decoder<'a> { match self.decoder.decode(&mut self.dsupp, &pkt) { Ok(frm) => { let buf = frm.get_buffer(); + if let NABufferType::None = buf { + return false; + } if let Some(pts) = frm.ts.get_pts() { self.samplepos = NATimeInfo::ts_to_time(pts, u64::from(self.arate), frm.ts.tb_num, frm.ts.tb_den); }