mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2025-01-08 22:25:37 +00:00
work around InitOnceExecuteOnce being completely broken
runs on Windows now
This commit is contained in:
parent
15b801c820
commit
f57f691068
21
src/os.cpp
21
src/os.cpp
|
@ -536,18 +536,21 @@ static void internal_init(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SOUNDIO_OS_WINDOWS)
|
|
||||||
static BOOL CALLBACK win32_init_once_cb(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContext) {
|
|
||||||
internal_init();
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void soundio_os_init(void) {
|
void soundio_os_init(void) {
|
||||||
#if defined(SOUNDIO_OS_WINDOWS)
|
#if defined(SOUNDIO_OS_WINDOWS)
|
||||||
PVOID lpContext;
|
PVOID lpContext;
|
||||||
if (!InitOnceExecuteOnce(&win32_init_once, win32_init_once_cb, NULL, &lpContext))
|
BOOL pending;
|
||||||
win32_panic("unable to initialize: %s");
|
|
||||||
|
if (!InitOnceBeginInitialize(&win32_init_once, INIT_ONCE_ASYNC, &pending, &lpContext))
|
||||||
|
win32_panic("InitOnceBeginInitialize failed: %s");
|
||||||
|
|
||||||
|
if (!pending)
|
||||||
|
return;
|
||||||
|
|
||||||
|
internal_init();
|
||||||
|
|
||||||
|
if (!InitOnceComplete(&win32_init_once, INIT_ONCE_ASYNC, nullptr))
|
||||||
|
win32_panic("InitOnceComplete failed: %s");
|
||||||
#else
|
#else
|
||||||
if (initialized.load())
|
if (initialized.load())
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue