mackron / miniaudio

Audio playback and capture library written in C, in a single source file.
https://miniaud.io
Other
4.07k stars 361 forks source link

Help or guide on building as a shared library, specifically for use with managed languages like C#, especially on WASM #737

Closed smaybius closed 1 year ago

smaybius commented 1 year ago

I'm meaning to use miniaudio with my cross-platform .NET project that also targets the web, by writing dllimport bindings. How could I build the library itself for WASM? Emscripten is my only choice that supports pthreads, but the .wasm file that comes out is only a few hundred KBs.

mackron commented 1 year ago

I don't officially support building miniaudio as a DLL. You're on your own if you want to do that, but you can configure the MA_API macro to whatever you like. You could define that to the necessary value for exporting from a DLL. Note that miniaudio uses transparent structures and I don't guarantee ABI compatibility between any version, even minor bug fix releases.

Regarding web, Emscripten is the only compiler I've tested on that front. However, I didn't think the Emscripten build ever used pthreads. If it is, that needs to be addressed. How have you determined that pthreads is being used by the Emscripten build?

but the .wasm file that comes out is only a few hundred KBs.

What do you mean by this exactly? Why are you expecting it to be bigger? What's unusual about it being a few hundred KBs?