]> git.nihav.org Git - nihav.git/commitdiff
use proper audio buffer truncation function
authorKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 29 Oct 2021 12:49:09 +0000 (14:49 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 29 Oct 2021 12:49:09 +0000 (14:49 +0200)
nihav-llaudio/src/codecs/tta.rs
nihav-qt/src/codecs/alac.rs

index 03eb515777023657c03dd545b4c7b7d3780e0a5c..e88793eddf508c820a8dd5deff860d9e5c9e15f3 100644 (file)
@@ -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)));
index bdcdad700e9cbe0fa28e7bb0b8707c1c8ac0babf..b29e9a2d206cd5fc2b844790c219c66566068f02 100644 (file)
@@ -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));