diff options
| author | Le Juez Victor <[email protected]> | 2023-09-18 18:50:22 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-09-18 18:50:22 +0200 |
| commit | 4d2906b0a5766823cbd9808431656140dae881b9 (patch) | |
| tree | ffcb7db0ff8a3e21fec8a8bd820370594e99d6a0 /src | |
| parent | 5c9cc3f9f77d64a9fe9cc0d374da8ed4741fcaa5 (diff) | |
| download | raylib-4d2906b0a5766823cbd9808431656140dae881b9.tar.gz raylib-4d2906b0a5766823cbd9808431656140dae881b9.zip | |
Move mutex initialization before `ma_device_start()` (#3325)
Diffstat (limited to 'src')
| -rw-r--r-- | src/raudio.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/raudio.c b/src/raudio.c index 4627cdf5..61e00a38 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -474,22 +474,22 @@ void InitAudioDevice(void) return; } - // Keep the device running the whole time. May want to consider doing something a bit smarter and only have the device running - // while there's at least one sound being played. - result = ma_device_start(&AUDIO.System.device); - if (result != MA_SUCCESS) + // Mixing happens on a separate thread which means we need to synchronize. I'm using a mutex here to make things simple, but may + // want to look at something a bit smarter later on to keep everything real-time, if that's necessary. + if (ma_mutex_init(&AUDIO.System.lock) != MA_SUCCESS) { - TRACELOG(LOG_WARNING, "AUDIO: Failed to start playback device"); + TRACELOG(LOG_WARNING, "AUDIO: Failed to create mutex for mixing"); ma_device_uninit(&AUDIO.System.device); ma_context_uninit(&AUDIO.System.context); return; } - // Mixing happens on a separate thread which means we need to synchronize. I'm using a mutex here to make things simple, but may - // want to look at something a bit smarter later on to keep everything real-time, if that's necessary. - if (ma_mutex_init(&AUDIO.System.lock) != MA_SUCCESS) + // Keep the device running the whole time. May want to consider doing something a bit smarter and only have the device running + // while there's at least one sound being played. + result = ma_device_start(&AUDIO.System.device); + if (result != MA_SUCCESS) { - TRACELOG(LOG_WARNING, "AUDIO: Failed to create mutex for mixing"); + TRACELOG(LOG_WARNING, "AUDIO: Failed to start playback device"); ma_device_uninit(&AUDIO.System.device); ma_context_uninit(&AUDIO.System.context); return; |
