]> git.nihav.org Git - nihav.git/commitdiff
core/frame: set correct duration for newly constructed audio buffer
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 5 Nov 2022 10:03:31 +0000 (11:03 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 5 Nov 2022 10:03:31 +0000 (11:03 +0100)
nihav-core/src/frame.rs

index c93a9216fcc9ee7218da0910b65129ae5a890d94..792bfb41953ee9915e9200a93e764ff51dc2b1c0 100644 (file)
@@ -271,7 +271,8 @@ impl<T: Clone> NAAudioBuffer<T> {
 impl NAAudioBuffer<u8> {
     /// Constructs a new `NAAudioBuffer` instance.
     pub fn new_from_buf(info: NAAudioInfo, data: NABufferRef<Vec<u8>>, chmap: NAChannelMap) -> Self {
-        let len = data.len();
+        let len = data.len() * 8 / chmap.num_channels() / (info.format.bits as usize);
+
         NAAudioBuffer { info, data, chmap, offs: Vec::new(), len, stride: 0, step: 0 }
     }
 }