From e5374f60c9fef1ccbeba86e7e9120519a5964c50 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 24 Oct 2011 08:23:41 -0700 Subject: Don't close devices that are left open on lib shutdown --- Alc/ALc.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/Alc/ALc.c b/Alc/ALc.c index b548e6bf..ea25be79 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -404,7 +404,7 @@ static pthread_once_t alc_config_once = PTHREAD_ONCE_INIT; /////////////////////////////////////////////////////// // ALC Related helper functions -static void ReleaseALC(ALCboolean doclose); +static void ReleaseALC(void); static void ReleaseThreadCtx(void *ptr); static void alc_initconfig(void); @@ -520,7 +520,7 @@ static void alc_init(void) static void alc_deinit_safe(void) { - ReleaseALC(ALC_FALSE); + ReleaseALC(); FreeHrtf(); FreeALConfig(); @@ -538,7 +538,7 @@ static void alc_deinit(void) { int i; - ReleaseALC(ALC_TRUE); + ReleaseALC(); memset(&PlaybackBackend, 0, sizeof(PlaybackBackend)); memset(&CaptureBackend, 0, sizeof(CaptureBackend)); @@ -2649,8 +2649,10 @@ ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffe } -static void ReleaseALC(ALCboolean doclose) +static void ReleaseALC(void) { + ALCdevice *dev; + free(alcDeviceList); alcDeviceList = NULL; alcDeviceListSize = 0; free(alcAllDeviceList); alcAllDeviceList = NULL; @@ -2665,27 +2667,13 @@ static void ReleaseALC(ALCboolean doclose) free(alcCaptureDefaultDeviceSpecifier); alcCaptureDefaultDeviceSpecifier = NULL; - if(doclose) - { - ALCdevice *dev; - while((dev=DeviceList) != NULL) - { - WARN("Closing device %p\n", dev); - if(!dev->IsCaptureDevice) alcCloseDevice(dev); - else alcCaptureCloseDevice(dev); - } - } - else + if((dev=ExchangePtr((void**)&DeviceList, NULL)) != NULL) { - ALCdevice *dev; - if((dev=DeviceList) != NULL) - { - ALCuint num = 0; - do { - num++; - } while((dev=dev->next) != NULL); - WARN("%u device%s not closed\n", num, (num>1)?"s":""); - } + ALCuint num = 0; + do { + num++; + } while((dev=dev->next) != NULL); + ERR("%u device%s not closed\n", num, (num>1)?"s":""); } } -- cgit v1.2.3