X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-core%2Fsrc%2Ftest%2Fwavwriter.rs;fp=nihav-core%2Fsrc%2Ftest%2Fwavwriter.rs;h=50b194945c1dfe535d8bdb14d32d0c572f22da43;hb=fb8e31774f738353e3ada384a0751cea63936c15;hp=0c324302f0d3e0863edaedd0bd8878178b2b6aad;hpb=30d57e4ad95e8401984313afe509031f392d908a;p=nihav.git diff --git a/nihav-core/src/test/wavwriter.rs b/nihav-core/src/test/wavwriter.rs index 0c32430..50b1949 100644 --- a/nihav-core/src/test/wavwriter.rs +++ b/nihav-core/src/test/wavwriter.rs @@ -1,7 +1,9 @@ +//! Audio output in WAV format. use crate::io::byteio::*; use crate::frame::*; use std::io::SeekFrom; +/// WAVE output writer. pub struct WavWriter<'a> { io: &'a mut ByteWriter<'a>, data_pos: u64, @@ -46,9 +48,13 @@ macro_rules! write_data { } impl<'a> WavWriter<'a> { + /// Constructs a new `WavWriter` instance. pub fn new(io: &'a mut ByteWriter<'a>) -> Self { WavWriter { io, data_pos: 0 } } + /// Writes audio format information to the file header. + /// + /// This function should be called exactly once before writing actual audio data. pub fn write_header(&mut self, ainfo: NAAudioInfo) -> ByteIOResult<()> { let bits = ainfo.get_format().get_bits() as usize; @@ -78,6 +84,7 @@ impl<'a> WavWriter<'a> { self.data_pos = self.io.tell(); Ok(()) } + /// Writes audio data. pub fn write_frame(&mut self, abuf: NABufferType) -> ByteIOResult<()> { match abuf { NABufferType::AudioU8(ref buf) => {