From 2b39d27aaf6630decdab12bb48793f2816a11cf2 Mon Sep 17 00:00:00 2001 From: dvdsk Date: Tue, 10 Oct 2023 02:25:34 +0200 Subject: [PATCH] adds total_duration() impl to SymphoniaDecoder, makes seek saturating at source end if total_duration known --- src/decoder/mp3.rs | 1 + src/decoder/symphonia.rs | 20 +++++++++++-- src/decoder/wav.rs | 5 +++- src/source/mod.rs | 5 +++- tests/seek.rs | 64 ++++++++++++++++++++++++++-------------- 5 files changed, 69 insertions(+), 26 deletions(-) diff --git a/src/decoder/mp3.rs b/src/decoder/mp3.rs index 78f19e8..1ee4c06 100644 --- a/src/decoder/mp3.rs +++ b/src/decoder/mp3.rs @@ -74,6 +74,7 @@ where // as the seek only takes effect after the current frame is done self.decoder.seek_samples(pos)?; Ok(()) + } } impl Iterator for Mp3Decoder diff --git a/src/decoder/symphonia.rs b/src/decoder/symphonia.rs index 7d69c31..6eef152 100644 --- a/src/decoder/symphonia.rs +++ b/src/decoder/symphonia.rs @@ -26,6 +26,7 @@ pub struct SymphoniaDecoder { decoder: Box, current_frame_offset: usize, format: Box, + total_duration: Option