commit to save work on vorbis try_seek

This commit is contained in:
dvdsk 2024-04-03 13:02:30 +02:00
parent 1c821362fd
commit 5562241f39
No known key found for this signature in database
GPG key ID: 6CF9D20C5709A836
2 changed files with 3 additions and 1 deletions

View file

@ -78,7 +78,7 @@ where
#[inline]
fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> {
let samples = pos.as_secs_f32() * self.sample_rate() as f32 * self.channels() as f32;
let samples = pos.as_secs_f32() * self.sample_rate() as f32;
self.stream_reader.seek_absgp_pg(samples as u64)?;
// first few frames (packets) sometimes fail to decode, if

View file

@ -8,6 +8,7 @@ fn time_remaining(decoder: Decoder<impl Read + Seek>) -> Duration {
let rate = decoder.sample_rate() as f64;
let n_channels = decoder.channels() as f64;
let n_samples = decoder.into_iter().count() as f64;
dbg!(n_samples);
Duration::from_secs_f64(n_samples / rate / n_channels)
}
@ -84,6 +85,7 @@ fn seek_results_in_correct_remaining_playtime() {
let decoder = get_decoder(format);
let total_duration = time_remaining(decoder);
dbg!(total_duration);
const SEEK_BEFORE_END: Duration = Duration::from_secs(5);
let mut decoder = get_decoder(format);