mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-14 14:42:33 +00:00
Don't error on missing Xing/VBRI header
This commit is contained in:
parent
6bb0427c84
commit
f9be2c8b8c
2 changed files with 7 additions and 11 deletions
|
@ -195,12 +195,12 @@ impl Header {
|
|||
}
|
||||
|
||||
pub(crate) struct XingHeader {
|
||||
pub frames: u32,
|
||||
pub size: u32,
|
||||
pub(crate) frames: u32,
|
||||
pub(crate) size: u32,
|
||||
}
|
||||
|
||||
impl XingHeader {
|
||||
pub(crate) fn read(reader: &mut &[u8]) -> Result<Self> {
|
||||
pub(crate) fn read(reader: &mut &[u8]) -> Result<Option<Self>> {
|
||||
let reader_len = reader.len();
|
||||
|
||||
let mut header = [0; 4];
|
||||
|
@ -230,7 +230,7 @@ impl XingHeader {
|
|||
let frames = reader.read_u32::<BigEndian>()?;
|
||||
let size = reader.read_u32::<BigEndian>()?;
|
||||
|
||||
Ok(Self { frames, size })
|
||||
Ok(Some(Self { frames, size }))
|
||||
},
|
||||
b"VBRI" => {
|
||||
if reader_len < 32 {
|
||||
|
@ -250,13 +250,9 @@ impl XingHeader {
|
|||
let size = reader.read_u32::<BigEndian>()?;
|
||||
let frames = reader.read_u32::<BigEndian>()?;
|
||||
|
||||
Ok(Self { frames, size })
|
||||
Ok(Some(Self { frames, size }))
|
||||
},
|
||||
_ => Err(FileDecodingError::new(
|
||||
FileType::MP3,
|
||||
"No Xing, LAME, or VBRI header located",
|
||||
)
|
||||
.into()),
|
||||
_ => Ok(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ where
|
|||
let mut xing_reader = [0; 32];
|
||||
reader.read_exact(&mut xing_reader)?;
|
||||
|
||||
let xing_header = XingHeader::read(&mut &xing_reader[..]).ok();
|
||||
let xing_header = XingHeader::read(&mut &xing_reader[..])?;
|
||||
|
||||
super::properties::read_properties(
|
||||
(first_frame_header, first_frame_offset),
|
||||
|
|
Loading…
Reference in a new issue