mirror of
https://github.com/RustAudio/rodio
synced 2024-12-13 21:52:38 +00:00
removes seeking from vorbis decoder, can not be implemented
This commit is contained in:
parent
5562241f39
commit
80add81532
2 changed files with 9 additions and 37 deletions
|
@ -76,38 +76,16 @@ where
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// vorbis decoder only supports seeking to a number of samples
|
||||||
|
/// from the start. Since the samplerate can change in between frames
|
||||||
|
/// we can not reliably and efficiently calculate where to seek to.
|
||||||
|
///
|
||||||
|
/// recommendation: use symphonia if you want seeking in ogg files
|
||||||
#[inline]
|
#[inline]
|
||||||
fn try_seek(&mut self, pos: Duration) -> Result<(), SeekError> {
|
fn try_seek(&mut self, _: Duration) -> Result<(), SeekError> {
|
||||||
let samples = pos.as_secs_f32() * self.sample_rate() as f32;
|
Err(SeekError::NotSupported {
|
||||||
self.stream_reader.seek_absgp_pg(samples as u64)?;
|
underlying_source: std::any::type_name::<Self>(),
|
||||||
|
})
|
||||||
// first few frames (packets) sometimes fail to decode, if
|
|
||||||
// that happens just retry a few times.
|
|
||||||
let mut last_err = None;
|
|
||||||
for _ in 0..10 {
|
|
||||||
// 10 seemed to work best in testing
|
|
||||||
let res = self.stream_reader.read_dec_packet_itl();
|
|
||||||
match res {
|
|
||||||
Ok(data) => {
|
|
||||||
match data {
|
|
||||||
Some(d) => self.current_data = d,
|
|
||||||
None => self.current_data = Vec::new(),
|
|
||||||
}
|
|
||||||
// make sure the next seek returns the
|
|
||||||
// sample for the correct speaker
|
|
||||||
let to_skip = self.next % self.channels() as usize;
|
|
||||||
for _ in 0..to_skip {
|
|
||||||
self.next();
|
|
||||||
}
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
Err(e) => last_err = Some(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Err(SeekError::LewtonDecoder(
|
|
||||||
last_err.expect("is set if we get out of the for loop"),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -415,12 +415,6 @@ pub enum SeekError {
|
||||||
#[cfg(all(feature = "wav", not(feature = "symphonia-wav")))]
|
#[cfg(all(feature = "wav", not(feature = "symphonia-wav")))]
|
||||||
#[error("Error seeking in wav source: {0}")]
|
#[error("Error seeking in wav source: {0}")]
|
||||||
HoundDecoder(std::io::Error),
|
HoundDecoder(std::io::Error),
|
||||||
#[cfg(all(feature = "vorbis", not(feature = "symphonia-vorbis")))]
|
|
||||||
#[error("Error seeking in ogg source: {0}")]
|
|
||||||
LewtonDecoder(#[from] lewton::VorbisError),
|
|
||||||
#[cfg(all(feature = "minimp3", not(feature = "symphonia-mp3")))]
|
|
||||||
#[error("Error seeking in mp3 source: {0}")]
|
|
||||||
Minimp3Decoder(#[from] minimp3_fixed::Error),
|
|
||||||
#[error("An error occurred")]
|
#[error("An error occurred")]
|
||||||
Other(Box<dyn std::error::Error + Send>),
|
Other(Box<dyn std::error::Error + Send>),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue