mirror of
https://github.com/RustAudio/rodio
synced 2024-11-10 06:04:16 +00:00
commit to save work on vorbis try_seek
This commit is contained in:
parent
1c821362fd
commit
5562241f39
2 changed files with 3 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue