Compare commits

...

2 Commits

Author SHA1 Message Date
2809f9e495 [wasm] chore: bump version to alpha.8 2024-09-15 00:27:53 +01:00
9c12d2384c [audio] fix: id3v2 parsing 2024-09-15 00:27:25 +01:00
4 changed files with 14 additions and 2 deletions

Binary file not shown.

View File

@ -129,3 +129,15 @@ pub fn detect_audio_type(buffer: &[u8]) -> Result<AudioType, AudioError> {
Ok(AudioType::Unknown) 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> { pub fn get_header_metadata_size(buffer: &[u8], offset: usize) -> Result<usize, AudioError> {
let len = get_id3_header_size(buffer, offset)?; let len = get_id3_header_size(buffer, offset)?;
if len == 0 { if len != 0 {
Ok(len) Ok(len)
} else { } else {
get_ape_v2_size(buffer, offset) get_ape_v2_size(buffer, offset)

View File

@ -1,6 +1,6 @@
{ {
"name": "@unlock-music/crypto", "name": "@unlock-music/crypto",
"version": "0.0.0-alpha.7", "version": "0.0.0-alpha.8",
"description": "Project Unlock Music: 加解密支持库", "description": "Project Unlock Music: 加解密支持库",
"scripts": { "scripts": {
"build": "node build.js", "build": "node build.js",