From: Kostya Shishkov 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/?p=nihav.git;a=commitdiff_plain;h=2a998d8fb46273ffbf62a7e909ad8228c089f1d0 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 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 } } }