Skip to content

Commit

Permalink
0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
twlite committed Nov 4, 2023
1 parent 7356d09 commit d811e5d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mediaplex",
"version": "0.0.8",
"version": "0.0.9",
"main": "index.js",
"types": "index.d.ts",
"napi": {
Expand Down
10 changes: 8 additions & 2 deletions src/opus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,15 @@ impl JsOpusEncoder {
));
}

let out_vec = unsafe { std::mem::transmute::<&mut [i16], &mut [u8]>(&mut out.as_mut()) };
// the following outputs weird output
// let out_vec = unsafe { std::mem::transmute::<&mut [i16], &mut [u8]>(&mut out.as_mut()) };

Ok(out_vec.to_vec().into())
let out = unsafe {
let ptr = out.as_ptr() as *const u8;
std::slice::from_raw_parts(ptr, decoded_samples as usize * 4)
};

Ok(out.to_vec().into())
}

#[napi(catch_unwind)]
Expand Down

0 comments on commit d811e5d

Please sign in to comment.