mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Remove lewton decoder
This commit is contained in:
parent
096269c1d0
commit
f3a66d4b99
1 changed files with 0 additions and 46 deletions
|
@ -1,46 +0,0 @@
|
||||||
use super::{AudioDecoder, AudioPacket, DecoderError, DecoderResult};
|
|
||||||
|
|
||||||
use lewton::audio::AudioReadError::AudioIsHeader;
|
|
||||||
use lewton::inside_ogg::OggStreamReader;
|
|
||||||
use lewton::samples::InterleavedSamples;
|
|
||||||
use lewton::OggReadError::NoCapturePatternFound;
|
|
||||||
use lewton::VorbisError::{BadAudio, OggError};
|
|
||||||
|
|
||||||
use std::io::{Read, Seek};
|
|
||||||
|
|
||||||
pub struct VorbisDecoder<R: Read + Seek>(OggStreamReader<R>);
|
|
||||||
|
|
||||||
impl<R> VorbisDecoder<R>
|
|
||||||
where
|
|
||||||
R: Read + Seek,
|
|
||||||
{
|
|
||||||
pub fn new(input: R) -> DecoderResult<VorbisDecoder<R>> {
|
|
||||||
let reader =
|
|
||||||
OggStreamReader::new(input).map_err(|e| DecoderError::LewtonDecoder(e.to_string()))?;
|
|
||||||
Ok(VorbisDecoder(reader))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<R> AudioDecoder for VorbisDecoder<R>
|
|
||||||
where
|
|
||||||
R: Read + Seek,
|
|
||||||
{
|
|
||||||
fn seek(&mut self, absgp: u64) -> Result<u64, DecoderError> {
|
|
||||||
self.0
|
|
||||||
.seek_absgp_pg(absgp)
|
|
||||||
.map_err(|e| DecoderError::LewtonDecoder(e.to_string()))?;
|
|
||||||
Ok(absgp)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn next_packet(&mut self) -> DecoderResult<Option<AudioPacket>> {
|
|
||||||
loop {
|
|
||||||
match self.0.read_dec_packet_generic::<InterleavedSamples<f32>>() {
|
|
||||||
Ok(Some(packet)) => return Ok(Some(AudioPacket::samples_from_f32(packet.samples))),
|
|
||||||
Ok(None) => return Ok(None),
|
|
||||||
Err(BadAudio(AudioIsHeader)) => (),
|
|
||||||
Err(OggError(NoCapturePatternFound)) => (),
|
|
||||||
Err(e) => return Err(DecoderError::LewtonDecoder(e.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue