X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-llaudio%2Fsrc%2Fdemuxers%2Fape.rs;h=c58915bb14d1c01b699454f4a2aac444af4fe0aa;hb=886cde4847280b96e10d240c2f2d76abec121dc8;hp=10ebc07a3648fd61525e725488a41e35ae297bc1;hpb=a480a0de101483d802a11e72d758dae00fa4860a;p=nihav.git diff --git a/nihav-llaudio/src/demuxers/ape.rs b/nihav-llaudio/src/demuxers/ape.rs index 10ebc07..c58915b 100644 --- a/nihav-llaudio/src/demuxers/ape.rs +++ b/nihav-llaudio/src/demuxers/ape.rs @@ -15,6 +15,7 @@ struct APEDemuxer<'a> { normal_blocks: u32, last_blocks: u32, truncated: bool, + duration: u64, } impl<'a> APEDemuxer<'a> { @@ -26,6 +27,7 @@ impl<'a> APEDemuxer<'a> { normal_blocks: 0, last_blocks: 0, truncated: false, + duration: 0, } } } @@ -119,6 +121,7 @@ impl<'a> DemuxCore<'a> for APEDemuxer<'a> { 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()?; @@ -223,7 +226,7 @@ impl<'a> DemuxCore<'a> for APEDemuxer<'a> { Ok(()) } - fn get_duration(&self) -> u64 { 0 } + fn get_duration(&self) -> u64 { self.duration } } impl<'a> NAOptionHandler for APEDemuxer<'a> { @@ -248,6 +251,7 @@ mod test { #[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);