aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/dsound.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-05-28 23:00:59 -0700
committerChris Robinson <[email protected]>2010-05-28 23:00:59 -0700
commitebccfa93c3c1eca4b85e4cf6753bd44965350c5a (patch)
tree0ad08e67c936524d201ddb0d4eb87e78aadbf1f1 /Alc/dsound.c
parente9f4576d4d0340b4f4c090977ef48a56c619fd6d (diff)
Don't unload libs when they're not needed
Some libs don't really like being unloaded and reloaded all the time, and the benefits aren't that great
Diffstat (limited to 'Alc/dsound.c')
-rw-r--r--Alc/dsound.c33
1 files changed, 9 insertions, 24 deletions
diff --git a/Alc/dsound.c b/Alc/dsound.c
index 3ce45874..704fb909 100644
--- a/Alc/dsound.c
+++ b/Alc/dsound.c
@@ -71,12 +71,11 @@ typedef struct {
static const ALCchar dsDevice[] = "DirectSound Software";
static DevMap *DeviceList;
static ALuint NumDevices;
-static volatile ALuint load_count;
void *DSoundLoad(void)
{
- if(load_count == 0)
+ if(!ds_handle)
{
#ifdef _WIN32
ds_handle = LoadLibraryA("dsound.dll");
@@ -105,22 +104,9 @@ LOAD_FUNC(DirectSoundCreate);
LOAD_FUNC(DirectSoundEnumerateA);
#undef LOAD_FUNC
}
- ++load_count;
-
return ds_handle;
}
-void DSoundUnload(void)
-{
- if(load_count == 0 || --load_count > 0)
- return;
-
-#ifdef _WIN32
- FreeLibrary(ds_handle);
-#endif
- ds_handle = NULL;
-}
-
static BOOL CALLBACK DSoundEnumDevices(LPGUID guid, LPCSTR desc, LPCSTR drvname, LPVOID data)
{
@@ -259,10 +245,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
}
}
if(i == NumDevices)
- {
- DSoundUnload();
return ALC_FALSE;
- }
}
//Initialise requested device
@@ -270,7 +253,6 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
if(!pData)
{
alcSetError(device, ALC_OUT_OF_MEMORY);
- DSoundUnload();
return ALC_FALSE;
}
@@ -283,7 +265,6 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
if(pData->lpDS)
IDirectSound_Release(pData->lpDS);
free(pData);
- DSoundUnload();
return ALC_FALSE;
}
@@ -299,8 +280,6 @@ static void DSoundClosePlayback(ALCdevice *device)
IDirectSound_Release(pData->lpDS);
free(pData);
device->ExtraData = NULL;
-
- DSoundUnload();
}
static ALCboolean DSoundResetPlayback(ALCdevice *device)
@@ -560,6 +539,14 @@ void alcDSoundDeinit(void)
free(DeviceList);
DeviceList = NULL;
NumDevices = 0;
+
+ if(ds_handle)
+ {
+#ifdef _WIN32
+ FreeLibrary(ds_handle);
+#endif
+ ds_handle = NULL;
+ }
}
void alcDSoundProbe(int type)
@@ -588,6 +575,4 @@ void alcDSoundProbe(int type)
AppendAllDeviceList(DeviceList[i].name);
}
}
-
- DSoundUnload();
}