WAV now rereads properly

Signed-off-by: Serial <69764315+Serial-ATA@users.noreply.github.com>
This commit is contained in:
Serial 2021-04-18 13:45:53 -04:00
parent 3df43317fd
commit 48e6182e3a
4 changed files with 18 additions and 8 deletions

View file

@ -9,7 +9,7 @@ pub const IART: [u8; 4] = [73, 65, 82, 84];
pub const ICMT: [u8; 4] = [73, 67, 77, 84];
pub const ICRD: [u8; 4] = [73, 67, 82, 68];
pub const INAM: [u8; 4] = [73, 78, 65, 77];
pub const IPRD: [u8; 4] = [49, 50, 52, 44]; // Represents album title
pub const IPRD: [u8; 4] = [73, 80, 82, 68]; // Represents album title
// Non-standard
pub const ITRK: [u8; 4] = [73, 84, 82, 75]; // Can represent track number

View file

@ -72,7 +72,8 @@ where
Err(_) => continue,
}
},
None => cursor.set_position(cursor.position() + u64::from(size)),
#[allow(clippy::cast_lossless)]
None => cursor.set_position(cursor.position() + size as u64),
}
// Skip null byte

View file

@ -60,6 +60,12 @@ where
let (mut list_pos, mut list_len): (Option<u32>, Option<u32>) = (None, None);
if chunk.id() != riff::RIFF_ID {
return Err(Error::Wav(
"This file does not contain a RIFF chunk".to_string(),
));
}
for child in chunk.iter(&mut data) {
if child.id() == riff::LIST_ID {
list_pos = Some(child.offset() as u32);
@ -72,10 +78,13 @@ where
let mut content = Vec::new();
std::io::copy(&mut data, &mut content)?;
if let (Some(pos), Some(len)) = (list_pos, list_len) {
let end = (pos + len) as usize;
if let (Some(list_pos), Some(list_len)) = (list_pos, list_len) {
let list_end = (list_pos + list_len) as usize;
let _ = content.splice(pos as usize..end, packet);
let _ = content.splice(list_pos as usize..list_end, packet);
let total_size = (content.len() - 8) as u32;
let _ = content.splice(4..8, total_size.to_le_bytes().to_vec());
Ok(content)
} else {

View file

@ -139,7 +139,7 @@ impl AudioTagEdit for WavTag {
self.set_value("Artist", artist)
}
fn add_artist(&mut self, artist: &str) {
fn add_artist(&mut self, _artist: &str) {
todo!()
}
@ -187,7 +187,7 @@ impl AudioTagEdit for WavTag {
self.set_value("AlbumArtist", artists)
}
fn add_album_artist(&mut self, artist: &str) {
fn add_album_artist(&mut self, _artist: &str) {
todo!()
}
@ -199,7 +199,7 @@ impl AudioTagEdit for WavTag {
todo!()
}
fn set_album_cover(&mut self, cover: Picture<'a>) {
fn set_album_cover(&mut self, _cover: Picture) {
todo!()
}