From: Kostya Shishkov <kostya.shishkov@gmail.com>
Date: Sat, 5 Nov 2022 10:03:31 +0000 (+0100)
Subject: core/frame: set correct duration for newly constructed audio buffer
X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=2a998d8fb46273ffbf62a7e909ad8228c089f1d0;p=nihav.git

core/frame: set correct duration for newly constructed audio buffer
---

diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs
index c93a921..792bfb4 100644
--- a/nihav-core/src/frame.rs
+++ b/nihav-core/src/frame.rs
@@ -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 }
     }
 }