X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-core%2Fsrc%2Fframe.rs;h=f596dc95ad2b1d02b684c6563be6bd0492a4e5ec;hb=16cca4d3a7a7505ae31a7469b3547c52650fd194;hp=5499de1001b40b36446bec2cd8d99902bcf24d1e;hpb=6d240c6b3c031388c3bcc6b96f14de8d60e2b4ae;p=nihav.git diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs index 5499de1..f596dc9 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 { @@ -741,7 +752,7 @@ impl NAVideoBufferPool { } /// Clears the pool from all frames. pub fn reset(&mut self) { - self.pool.truncate(0); + self.pool.clear(); } }