The number of threads spawned by ma_engine_init(NULL, &engine); #798
-
Hello. I load bytes of an OGG file on my own and use the following code:
Will miniaudio by default create 2 threads in ma_engine_init(...)? One thread for a device and one for a resource manager? The above code is relatively fast. I have also used stb_vorbis_decode_memory(...) to create ma_audio_buffer and decode an OGG file, but it took a lot longer to finish loading. Does the above code decode an OGG file on a device thread? Is it possible (and OK) to entirely disable a resource manager in the code above? How to do it? Are the following functions safe to call on a new thread that I create (no other threads execute in parallel):
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
If you're playing multiple sounds, it's best to have a single It creates 1 thread for the resource manager, and at least 1 thread for the internal device backend, but it could be more depending on what the backend is doing behind the scenes (miniaudio has no control over any of that). You can disable the resource manager at compile time with the The functions you mentioned are thread safe. Since you're using |
Beta Was this translation helpful? Give feedback.
-
Thank you. I use the default configuration by calling ma_engine_init(NULL, &engine). On Android, I invoke the same ma_engine_init(...) on another variable while the first engine is still running. The first engine will be uninitialized soon after the second one starts. Is that OK? Is there any interference under the hood between two engines? |
Beta Was this translation helpful? Give feedback.
That should work, but it's something I would consider bad practice. The typical way to do it is have one
ma_engine
that you initialize once at application start up, and then uninitialize once at shutdown. Then for every sound you want to play, just initialize and uninitialize ama_sound
object. It should be onema_engine
to manyma_sounds
.Every time you initialize a
ma_engine
there's a lot of things going on like initializing a connection to the backend for playback, allocation of memory, starting threads, all that stuff. It's just unnecessary overhead.