aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-08-03 09:37:58 -0700
committerChris Robinson <[email protected]>2011-08-03 09:37:58 -0700
commitb5092a62125620a0f6f61f4baf821f2c5b379c60 (patch)
tree37d309766f6b386a30142298470fe30bb0e08596
parent81d401eab55792ece0c664db96f0390d9d0cbded (diff)
Delay reading the config file on Windows, too
-rw-r--r--Alc/ALc.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index e778c95e..935c687a 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -509,10 +509,6 @@ static void alc_init(void)
tls_create(&LocalContext);
InitializeCriticalSection(&ListLock);
ALTHUNK_INIT();
-
-#ifdef _WIN32
- alc_initconfig();
-#endif
}
static void alc_deinit(void)
@@ -665,11 +661,23 @@ static void alc_initconfig(void)
}
}
-#ifndef _WIN32
+#ifdef _WIN32
+static struct once_control {
+ LONG canpass;
+ LONG hasrun;
+} once_control = { TRUE, FALSE };
+static void call_once(struct once_control *once, void (*callback)(void))
+{
+ while(InterlockedExchange(&once->canpass, FALSE) == FALSE)
+ Sleep(0);
+ if(InterlockedExchange(&once->hasrun, TRUE) == FALSE)
+ callback();
+ InterlockedExchange(&once->canpass, TRUE);
+}
+#define DO_INITCONFIG() call_once(&once_control, alc_initconfig)
+#else
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
#define DO_INITCONFIG() pthread_once(&once_control, alc_initconfig)
-#else
-#define DO_INITCONFIG()
#endif
static void ProbeList(ALCchar **list, size_t *listsize, int type)