normal_blocks: u32,
last_blocks: u32,
truncated: bool,
+ duration: u64,
}
impl<'a> APEDemuxer<'a> {
normal_blocks: 0,
last_blocks: 0,
truncated: false,
+ duration: 0,
}
}
}
self.frames = Vec::with_capacity(nframes);
self.normal_blocks = blocksperframe;
self.last_blocks = finalblocks;
+ self.duration = (((nframes - 1) as u64) * u64::from(blocksperframe) + u64::from(finalblocks)) * 1000 / u64::from(srate);
seek_index.mode = SeekIndexMode::Present;
let first_off = src.peek_u32le()?;
let ahdr = NAAudioInfo::new(srate, channels as u8, SND_S16P_FORMAT, 1);
let ainfo = NACodecInfo::new("ape", NACodecTypeInfo::Audio(ahdr), Some(hdr));
- strmgr.add_stream(NAStream::new(StreamType::Audio, 0, ainfo, blocksperframe, srate)).unwrap();
+ strmgr.add_stream(NAStream::new(StreamType::Audio, 0, ainfo, blocksperframe, srate, nframes as u64)).unwrap();
self.cur_frame = 0;
Ok(())
}
+ fn get_duration(&self) -> u64 { self.duration }
}
impl<'a> NAOptionHandler for APEDemuxer<'a> {
#[test]
fn test_ape_demux() {
+ // sample: https://samples.mplayerhq.hu/A-codecs/lossless/luckynight.ape
let mut file = File::open("assets/LLaudio/ape/luckynight.ape").unwrap();
let mut fr = FileReader::new_read(&mut file);
let mut br = ByteReader::new(&mut fr);