From 2a998d8fb46273ffbf62a7e909ad8228c089f1d0 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 5 Nov 2022 11:03:31 +0100 Subject: [PATCH] core/frame: set correct duration for newly constructed audio buffer --- nihav-core/src/frame.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 NAAudioBuffer { impl NAAudioBuffer { /// Constructs a new `NAAudioBuffer` instance. pub fn new_from_buf(info: NAAudioInfo, data: NABufferRef>, 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 } } } -- 2.30.2