aboutsummaryrefslogtreecommitdiffstats
path: root/nihav-llaudio
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2020-10-07 14:09:03 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2020-10-07 14:09:03 +0200
commit42fa9a844c4b8e46189ffaf9e5f803b3c03e7042 (patch)
tree99b95d2e03fcfcce329fde76b378e624a8ad88f3 /nihav-llaudio
parent87c44b3b802b7b6fc8d21f598cb6d9034504e0a3 (diff)
downloadnihav-42fa9a844c4b8e46189ffaf9e5f803b3c03e7042.tar.gz
ape: report sample-based duration
Diffstat (limited to 'nihav-llaudio')
-rw-r--r--nihav-llaudio/src/demuxers/ape.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/nihav-llaudio/src/demuxers/ape.rs b/nihav-llaudio/src/demuxers/ape.rs
index 10ebc07..bae9416 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> {