Skip to content

Commit

Permalink
Update ogg to 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed May 30, 2017
1 parent b87af26 commit 0866df9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ nightly = []

[dependencies]
byteorder = "1.0"
ogg = { version = "0.4", optional = true }
ogg = { version = "0.5", optional = true }
ieee754 = { version = "0.2", optional = true }

[dev-dependencies]
ogg = "0.4"
ogg = "0.5"
alto = "1.1"
rand = "0.3"
30 changes: 11 additions & 19 deletions src/inside_ogg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ use ::audio::{PreviousWindowRight, read_audio_packet};
/// and use the `HeadersReader` struct instead.
pub fn read_headers<'a, T: Read + Seek + 'a>(rdr: &mut PacketReader<T>) ->
Result<(IdentHeader, CommentHeader, SetupHeader), VorbisError> {
let pck :Packet = try!(rdr.read_packet());
let pck :Packet = try!(rdr.read_packet_expected());
let ident_hdr = try!(read_header_ident(&pck.data));

let pck :Packet = try!(rdr.read_packet());
let pck :Packet = try!(rdr.read_packet_expected());
let comment_hdr = try!(read_header_comment(&pck.data));

let pck :Packet = try!(rdr.read_packet());
let pck :Packet = try!(rdr.read_packet_expected());
let setup_hdr = try!(read_header_setup(&pck.data, ident_hdr.audio_channels,
(ident_hdr.blocksize_0, ident_hdr.blocksize_1)));

Expand Down Expand Up @@ -61,8 +61,6 @@ pub struct OggStreamReader<T: Read + Seek> {
pub setup_hdr :SetupHeader,

absgp_of_last_read :Option<u64>,

last_packet_was_last_ever :bool,
}

impl<T: Read + Seek> OggStreamReader<T> {
Expand Down Expand Up @@ -92,7 +90,6 @@ impl<T: Read + Seek> OggStreamReader<T> {
ident_hdr : ident_hdr,
comment_hdr : comment_hdr,
setup_hdr : setup_hdr,
last_packet_was_last_ever : false,
absgp_of_last_read : None,
});
}
Expand All @@ -108,12 +105,10 @@ impl<T: Read + Seek> OggStreamReader<T> {
/// with the data of the decompressed packet.
pub fn read_dec_packet(&mut self) ->
Result<Option<Vec<Vec<i16>>>, VorbisError> {
if self.last_packet_was_last_ever {
// We've reached the end of the stream
return Ok(None);
}
let pck = try!(self.rdr.read_packet());
self.last_packet_was_last_ever = pck.last_packet;
let pck = match try!(self.rdr.read_packet()) {
Some(p) => p,
None => return Ok(None),
};
let decoded_pck = try!(read_audio_packet(&self.ident_hdr,
&self.setup_hdr, &pck.data, &mut self.pwr));
self.absgp_of_last_read = Some(pck.absgp_page);
Expand All @@ -131,12 +126,10 @@ impl<T: Read + Seek> OggStreamReader<T> {
/// interleaved samples.
pub fn read_dec_packet_itl(&mut self) ->
Result<Option<Vec<i16>>, VorbisError> {
if self.last_packet_was_last_ever {
// We've reached the end of the stream
return Ok(None);
}
let pck = try!(self.rdr.read_packet());
self.last_packet_was_last_ever = pck.last_packet;
let pck = match try!(self.rdr.read_packet()) {
Some(p) => p,
None => return Ok(None),
};
let decoded_pck = try!(read_audio_packet(&self.ident_hdr,
&self.setup_hdr, &pck.data, &mut self.pwr));
self.absgp_of_last_read = Some(pck.absgp_page);
Expand Down Expand Up @@ -245,7 +238,6 @@ mod async_utils {
ident_hdr : self.ident_hdr.unwrap(),
comment_hdr : self.comment_hdr.unwrap(),
setup_hdr : self.setup_hdr.unwrap(),
last_packet_was_last_ever : false,
absgp_of_last_read : None,
};
}
Expand Down

0 comments on commit 0866df9

Please sign in to comment.