mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-11-10 06:34:18 +00:00
FLAC: Add more logging
This commit is contained in:
parent
73663a7346
commit
14cd3e81df
3 changed files with 19 additions and 0 deletions
|
@ -32,6 +32,7 @@ impl Block {
|
|||
let ty = byte & 0x7F;
|
||||
|
||||
let size = data.read_u24::<BigEndian>()?;
|
||||
log::trace!("Reading FLAC block, type: {ty}, size: {size}");
|
||||
|
||||
let mut content = try_vec![0; size as usize];
|
||||
data.read_exact(&mut content)?;
|
||||
|
|
|
@ -32,6 +32,7 @@ where
|
|||
decode_err!(@BAIL Flac, "File missing mandatory STREAMINFO block");
|
||||
}
|
||||
|
||||
log::debug!("File verified to be FLAC");
|
||||
Ok(block)
|
||||
}
|
||||
|
||||
|
@ -48,6 +49,8 @@ where
|
|||
|
||||
// It is possible for a FLAC file to contain an ID3v2 tag
|
||||
if let ID3FindResults(Some(header), Some(content)) = find_id3v2(data, true)? {
|
||||
log::warn!("Encountered an ID3v2 tag. This tag cannot be rewritten to the FLAC file!");
|
||||
|
||||
let reader = &mut &*content;
|
||||
|
||||
let id3v2 = parse_id3v2(reader, header, parse_options.parsing_mode)?;
|
||||
|
@ -74,6 +77,8 @@ where
|
|||
}
|
||||
|
||||
if block.ty == BLOCK_ID_VORBIS_COMMENTS {
|
||||
log::debug!("Encountered a Vorbis Comments block, parsing");
|
||||
|
||||
// NOTE: According to the spec
|
||||
//
|
||||
// <https://xiph.org/flac/format.html#def_VORBIS_COMMENT>:
|
||||
|
@ -100,6 +105,8 @@ where
|
|||
}
|
||||
|
||||
if block.ty == BLOCK_ID_PICTURE {
|
||||
log::debug!("Encountered a FLAC picture block, parsing");
|
||||
|
||||
match Picture::from_flac_bytes(&block.content, false, parse_options.parsing_mode) {
|
||||
Ok(picture) => flac_file.pictures.push(picture),
|
||||
Err(e) => {
|
||||
|
|
|
@ -82,6 +82,8 @@ where
|
|||
let mut file_bytes = cursor.into_inner();
|
||||
|
||||
if !padding {
|
||||
log::warn!("File is missing a PADDING block. Adding one");
|
||||
|
||||
let mut first_byte = 0_u8;
|
||||
first_byte |= last_block_info.0 & 0x7F;
|
||||
|
||||
|
@ -167,6 +169,12 @@ fn create_comment_block(
|
|||
writer
|
||||
.get_mut()
|
||||
.splice(1..1, len.to_be_bytes()[1..].to_vec());
|
||||
|
||||
// size = block type + vendor length + vendor + item count + items
|
||||
log::trace!(
|
||||
"Wrote a comment block, size: {}",
|
||||
1 + 4 + vendor.len() + 4 + (len as usize)
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -191,6 +199,9 @@ fn create_picture_blocks(
|
|||
|
||||
writer.write_all(&pic_len.to_be_bytes()[1..])?;
|
||||
writer.write_all(pic_bytes.as_slice())?;
|
||||
|
||||
// size = block type + block length + data
|
||||
log::trace!("Wrote a picture block, size: {}", 1 + 3 + pic_len);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue