From: Kostya Shishkov Date: Fri, 25 Aug 2023 16:55:42 +0000 (+0200) Subject: wav: try to read as much PCM data as possible X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=f80d9ab996334eca46048c2ee25c51e52d7fef7f;p=nihav.git wav: try to read as much PCM data as possible Otherwise read_buf_some() may return random small buffer size that is not even aligned to the sample size. --- diff --git a/nihav-commonfmt/src/demuxers/wav.rs b/nihav-commonfmt/src/demuxers/wav.rs index 9019617..193623e 100644 --- a/nihav-commonfmt/src/demuxers/wav.rs +++ b/nihav-commonfmt/src/demuxers/wav.rs @@ -103,8 +103,14 @@ impl<'a> DemuxCore<'a> for WAVDemuxer<'a> { bsize }; let mut buf = vec![0; bsize]; - let size = self.src.read_buf_some(buf.as_mut_slice())?; - buf.truncate(size); + let mut tot_size = 0; + while let Ok(psize) = self.src.read_buf_some(&mut buf[tot_size..]) { + tot_size += psize; + if tot_size == buf.len() { + break; + } + } + buf.truncate(tot_size); Ok(NAPacket::new(stream, ts, true, buf)) } else { self.src.read_packet(stream, ts, true, self.block_size)