diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2023-08-25 18:55:42 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2023-08-25 18:55:42 +0200 |
commit | f80d9ab996334eca46048c2ee25c51e52d7fef7f (patch) | |
tree | 938b353ca116bd18301bd5f1e40a5ff6d99b73f9 | |
parent | 34219db3e2b43a690418e3d157b59a9f052ad343 (diff) | |
download | nihav-f80d9ab996334eca46048c2ee25c51e52d7fef7f.tar.gz |
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.
-rw-r--r-- | nihav-commonfmt/src/demuxers/wav.rs | 10 |
1 files changed, 8 insertions, 2 deletions
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) |