From: Kostya Shishkov Date: Fri, 29 Oct 2021 12:49:09 +0000 (+0200) Subject: use proper audio buffer truncation function X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=2d1e0773a5c845db33041796ea74d8ca12710ced;p=nihav.git use proper audio buffer truncation function --- diff --git a/nihav-llaudio/src/codecs/tta.rs b/nihav-llaudio/src/codecs/tta.rs index 03eb515..e88793e 100644 --- a/nihav-llaudio/src/codecs/tta.rs +++ b/nihav-llaudio/src/codecs/tta.rs @@ -289,7 +289,6 @@ impl NADecoder for TTADecoder { if not_last { self.framelen } else { - adata.truncate((self.nsamples % self.framelen) as usize); self.nsamples % self.framelen } }, @@ -300,12 +299,12 @@ impl NADecoder for TTADecoder { if not_last { self.framelen } else { - adata.truncate((self.nsamples % self.framelen) as usize); self.nsamples % self.framelen } }, _ => unreachable!(), }; + abuf.truncate_audio(duration as usize); let mut frm = NAFrame::new_from_pkt(pkt, info, abuf); frm.set_duration(Some(u64::from(duration))); diff --git a/nihav-qt/src/codecs/alac.rs b/nihav-qt/src/codecs/alac.rs index bdcdad7..b29e9a2 100644 --- a/nihav-qt/src/codecs/alac.rs +++ b/nihav-qt/src/codecs/alac.rs @@ -356,7 +356,7 @@ impl NADecoder for ALACDecoder { if let NACodecTypeInfo::Audio(_) = info.get_properties() { let src = pkt.get_buffer(); let channels = self.chmap.num_channels(); - let abuf = alloc_audio_buffer(self.ainfo, self.frame_len, self.chmap.clone())?; + let mut abuf = alloc_audio_buffer(self.ainfo, self.frame_len, self.chmap.clone())?; let mut br = BitReader::new(&src, BitReaderMode::BE); @@ -390,7 +390,6 @@ impl NADecoder for ALACDecoder { _ => return Err(DecoderError::InvalidData), }; } - adata.truncate(self.cur_len); } else if let Some(mut adata) = abuf.get_abuf_i32() { let shift = 32 - self.bits; let stride = adata.get_stride(); @@ -420,10 +419,10 @@ impl NADecoder for ALACDecoder { _ => return Err(DecoderError::InvalidData), }; } - adata.truncate(self.cur_len); } else { return Err(DecoderError::Bug); } + abuf.truncate_audio(self.cur_len); let mut frm = NAFrame::new_from_pkt(pkt, info.replace_info(NACodecTypeInfo::Audio(self.ainfo)), abuf); frm.set_duration(Some(self.cur_len as u64));