germangb / minimp3-rs

minimp3 rust bindings + wrapper
MIT License
66 stars 22 forks source link

Make it build for wasm32-unknown-unknown #7

Open icefoxen opened 5 years ago

icefoxen commented 5 years ago

With clang building the C parts of it, this should be possible, right? ...right?

The main blocker I hit was the slice_deque library, which uses Virtual Memory Tricks to give you a cheap ring buffer that's always linear. Webassembly doesn't have virtual memory, so you can't do that; see https://github.com/gnzlbg/slice_deque/issues/60 for discussion.

So I was thinking the best solution would be to wrap the SliceDeque that this library uses in a type that presents the same API but does copying under the hood when necessary on platforms that slice_deque doesn't support. If you're willing I'll gladly contribute the changes.

Thanks so much!

germangb commented 5 years ago

With clang building the C parts of it, this should be possible, right? ...right?

My knowledge of wasm is limited atm,

I think (might be completely wrong) minimp3 (the original C) would need to be built into a wasm module (I haven't checked if it is possible), then remove the ffi interface from this crate, and replace it with glue code to interoperate with the wasm module from Rust..

So I was thinking the best solution would be to wrap the SliceDeque

I'm not sure if the implementation belongs in this crate (we don't event have test. I need fix this someday). How about a fork with the changes you suggest in your issue?

icefoxen commented 5 years ago

Sounds good to me, I'll try it out.

Moxinilian commented 3 years ago

Any progress on this front?

germangb commented 3 years ago

Not from my side

As an experiment, maybe it would be worth trying to write wasm-bindgen bindings for this repo: https://github.com/bashi/minimp3-wasm (I just found out about it and haven't tried it myself)