Skip to content

Commit

Permalink
kay, let's test against the minimp3 crate!
Browse files Browse the repository at this point in the history
  • Loading branch information
icefoxen committed Sep 7, 2018
1 parent d637adb commit 9e48b56
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 150 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ categories = []
maintenance = { status = "experimental" }

[dependencies]
structopt = "0.2"
structopt = "0.2"
minimp3 = "0.3"
24 changes: 2 additions & 22 deletions src/bin/minimp3_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,6 @@ unsafe fn mp3dec_skip_id3v2(buf: *const u8, buf_size: usize) -> usize {
0usize
}
}

/// Returns usize but I think the max length an ID3
/// tag can have is 32 bits?
fn mp3dec_skip_id3v2_slice(buf: &[u8]) -> usize {
if buf.len() > 10 && buf[..3] == b"ID3\0"[..3] {
(((buf[6] & 0x7F) as usize) << 21
| ((buf[7] & 0x7F) as usize) << 14
| ((buf[8] & 0x7F) as usize) << 7
| ((buf[9] & 0x7F) as usize) + 10)
} else {
0
}
}

#[no_mangle]
pub unsafe fn mp3dec_load_buf(
dec: *mut Mp3Dec,
mut buf: *const u8,
Expand Down Expand Up @@ -240,7 +225,6 @@ pub unsafe fn mp3dec_load_buf(
}
}

#[no_mangle]
pub unsafe fn mp3dec_iterate_buf(
mut buf: *const u8,
mut buf_size: usize,
Expand Down Expand Up @@ -335,7 +319,6 @@ impl Clone for Mp3decEx {
}
}

#[no_mangle]
pub unsafe fn mp3dec_ex_open_buf(
dec: *mut Mp3decEx,
buf: *const u8,
Expand Down Expand Up @@ -450,7 +433,6 @@ unsafe fn mp3dec_close_file(map_info: *mut Mp3decMapInfo) {
(*map_info).size = 0usize;
}

#[no_mangle]
pub unsafe fn mp3dec_load(
dec: *mut Mp3Dec,
file_name: *const u8,
Expand Down Expand Up @@ -480,7 +462,6 @@ pub unsafe fn mp3dec_load(
}
}

#[no_mangle]
pub unsafe fn mp3dec_iterate(
file_name: *const u8,
callback: unsafe fn(*mut ::std::os::raw::c_void, *const u8, i32, usize, *mut FrameInfo) -> i32,
Expand All @@ -501,7 +482,6 @@ pub unsafe fn mp3dec_iterate(
}
}

#[no_mangle]
pub unsafe fn mp3dec_ex_close(dec: *mut Mp3decEx) {
if (*dec).is_file != 0 {
mp3dec_close_file(&mut (*dec).file as (*mut Mp3decMapInfo));
Expand All @@ -515,7 +495,6 @@ pub unsafe fn mp3dec_ex_close(dec: *mut Mp3decEx) {
);
}

#[no_mangle]
pub unsafe fn mp3dec_ex_open(dec: *mut Mp3decEx, file_name: *const u8, seek_method: i32) -> i32 {
let ret: i32;
memset(
Expand Down Expand Up @@ -698,6 +677,7 @@ fn main() {
*/

return;
/*
use std::os::unix::ffi::OsStringExt;
let mut argv_storage = ::std::env::args_os()
.map(|str| {
Expand All @@ -713,6 +693,7 @@ fn main() {
.collect::<Vec<_>>();
let ret = unsafe { _c_main(argv_storage.len() as (i32), argv.as_mut_ptr()) };
::std::process::exit(ret);
*/
}

unsafe fn preload(file: *mut IoFile, data_size: *mut i32) -> *mut u8 {
Expand Down Expand Up @@ -889,7 +870,6 @@ unsafe fn decode_file(
}
}

#[no_mangle]
pub unsafe fn _c_main(argc: i32, argv: *mut *mut u8) -> i32 {
let mut wave_out: i32 = 0i32;
let mut ref_size: i32 = 0;
Expand Down
Loading

0 comments on commit 9e48b56

Please sign in to comment.