aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2021-10-29 14:07:55 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2021-10-29 14:07:55 +0200
commita1298b7a5dcf1656dfc9bdbf3d6c80df89a70fc8 (patch)
treee3d7885a77eaad550ebaeeb519c87e4ac7c3fa7d
parentc11ad64e877fcf2e47c7bbb04bfb8d7764465dab (diff)
downloadnihav-a1298b7a5dcf1656dfc9bdbf3d6c80df89a70fc8.tar.gz
core/frame: add proper function for audio frame truncation
-rw-r--r--nihav-core/src/frame.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs
index 5499de1..31cf8e8 100644
--- a/nihav-core/src/frame.rs
+++ b/nihav-core/src/frame.rs
@@ -390,6 +390,17 @@ impl NABufferType {
_ => 0,
}
}
+ /// Truncates audio frame duration if possible.
+ pub fn truncate_audio(&mut self, len: usize) {
+ match *self {
+ NABufferType::AudioU8(ref mut ab) => ab.truncate(len),
+ NABufferType::AudioI16(ref mut ab) => ab.truncate(len),
+ NABufferType::AudioI32(ref mut ab) => ab.truncate(len),
+ NABufferType::AudioF32(ref mut ab) => ab.truncate(len),
+ NABufferType::AudioPacked(ref mut ab) => ab.truncate(len),
+ _ => {},
+ };
+ }
/// Returns the distance between starts of two channels.
pub fn get_audio_stride(&self) -> usize {
match *self {