[audio] fix: id3v2 parsing

This commit is contained in:
鲁树人 2024-09-15 00:27:25 +01:00
parent f3b9075a82
commit 9c12d2384c
3 changed files with 13 additions and 1 deletions

Binary file not shown.

View File

@ -129,3 +129,15 @@ pub fn detect_audio_type(buffer: &[u8]) -> Result<AudioType, AudioError> {
Ok(AudioType::Unknown)
}
#[cfg(test)]
mod tests {
use crate::{detect_audio_type, AudioType};
#[test]
fn test_mp3() {
let mp3_data = include_bytes!("__fixtures__/mp3_with_id3v2.bin");
let result = detect_audio_type(mp3_data).expect("failed to parse mp3");
assert_eq!(result, AudioType::MP3);
}
}

View File

@ -67,7 +67,7 @@ fn get_ape_v2_size(buffer: &[u8], offset: usize) -> Result<usize, AudioError> {
pub fn get_header_metadata_size(buffer: &[u8], offset: usize) -> Result<usize, AudioError> {
let len = get_id3_header_size(buffer, offset)?;
if len == 0 {
if len != 0 {
Ok(len)
} else {
get_ape_v2_size(buffer, offset)