mirror of
https://github.com/raysan5/raylib.git
synced 2025-11-19 16:51:07 +00:00
Move mutex initialization before ma_device_start() (#3325)
This commit is contained in:
20
src/raudio.c
20
src/raudio.c
@@ -474,6 +474,16 @@ void InitAudioDevice(void)
|
||||
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)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "AUDIO: Failed to create mutex for mixing");
|
||||
ma_device_uninit(&AUDIO.System.device);
|
||||
ma_context_uninit(&AUDIO.System.context);
|
||||
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);
|
||||
@@ -485,16 +495,6 @@ void InitAudioDevice(void)
|
||||
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)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "AUDIO: Failed to create mutex for mixing");
|
||||
ma_device_uninit(&AUDIO.System.device);
|
||||
ma_context_uninit(&AUDIO.System.context);
|
||||
return;
|
||||
}
|
||||
|
||||
TRACELOG(LOG_INFO, "AUDIO: Device initialized successfully");
|
||||
TRACELOG(LOG_INFO, " > Backend: miniaudio / %s", ma_get_backend_name(AUDIO.System.context.backend));
|
||||
TRACELOG(LOG_INFO, " > Format: %s -> %s", ma_get_format_name(AUDIO.System.device.playback.format), ma_get_format_name(AUDIO.System.device.playback.internalFormat));
|
||||
|
||||
Reference in New Issue
Block a user