diff options
author | Chris Robinson <[email protected]> | 2017-07-01 15:25:11 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-07-01 15:25:11 -0700 |
commit | af626fdded7b3dd7dec40e2cb52bb4b6aaa4556e (patch) | |
tree | 505453335d5c273ec8890b814d2652faad12154e /router | |
parent | 7daefd4e77cb7d61fd386691a0a53643c0db0533 (diff) |
Initialize ALC resources in the file they're used in
Diffstat (limited to 'router')
-rw-r--r-- | router/alc.c | 12 | ||||
-rw-r--r-- | router/router.c | 9 | ||||
-rw-r--r-- | router/router.h | 4 |
3 files changed, 15 insertions, 10 deletions
diff --git a/router/alc.c b/router/alc.c index c4536cce..a8b9c2b2 100644 --- a/router/alc.c +++ b/router/alc.c @@ -241,6 +241,9 @@ static const ALCint alcMajorVersion = 1; static const ALCint alcMinorVersion = 1; +static almtx_t EnumerationLock; +static almtx_t ContextSwitchLock; + static ATOMIC(ALCenum) LastError = ATOMIC_INIT_STATIC(ALC_NO_ERROR); static PtrIntMap DeviceIfaceMap = PTRINTMAP_STATIC_INITIALIZE; static PtrIntMap ContextIfaceMap = PTRINTMAP_STATIC_INITIALIZE; @@ -320,6 +323,12 @@ static ALint GetDriverIndexForName(const EnumeratedList *list, const ALCchar *na return -1; } +void InitALC(void) +{ + almtx_init(&EnumerationLock, almtx_recursive); + almtx_init(&ContextSwitchLock, almtx_plain); +} + void ReleaseALC(void) { ClearDeviceList(&DevicesList); @@ -328,6 +337,9 @@ void ReleaseALC(void) ResetPtrIntMap(&ContextIfaceMap); ResetPtrIntMap(&DeviceIfaceMap); + + almtx_destroy(&ContextSwitchLock); + almtx_destroy(&EnumerationLock); } diff --git a/router/router.c b/router/router.c index 53229aca..54f82245 100644 --- a/router/router.c +++ b/router/router.c @@ -16,9 +16,6 @@ DriverIface *DriverList = NULL; int DriverListSize = 0; static int DriverListSizeMax = 0; -almtx_t EnumerationLock; -almtx_t ContextSwitchLock; - enum LogLevel LogLevel = LogLevel_Error; FILE *LogFile; @@ -56,8 +53,8 @@ BOOL APIENTRY DllMain(HINSTANCE UNUSED(module), DWORD reason, void* UNUSED(reser LogLevel = l; } LoadDriverList(); - almtx_init(&EnumerationLock, almtx_recursive); - almtx_init(&ContextSwitchLock, almtx_plain); + + InitALC(); break; case DLL_THREAD_ATTACH: @@ -67,8 +64,6 @@ BOOL APIENTRY DllMain(HINSTANCE UNUSED(module), DWORD reason, void* UNUSED(reser case DLL_PROCESS_DETACH: ReleaseALC(); - almtx_destroy(&ContextSwitchLock); - almtx_destroy(&EnumerationLock); for(i = 0;i < DriverListSize;i++) { if(DriverList[i].Module) diff --git a/router/router.h b/router/router.h index 7cc94399..6d34cadd 100644 --- a/router/router.h +++ b/router/router.h @@ -153,9 +153,7 @@ ALint RemovePtrIntMapKey(PtrIntMap *map, ALvoid *key); ALint LookupPtrIntMapKey(PtrIntMap *map, ALvoid *key); -extern almtx_t EnumerationLock; -extern almtx_t ContextSwitchLock; - +void InitALC(void); void ReleaseALC(void); |