summaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-01-14 10:39:54 -0800
committerChris Robinson <[email protected]>2008-01-14 10:39:54 -0800
commit29c6238b52e0733f7fbd19853f323ea9ee245064 (patch)
tree0e98d2d45c6a0b77687a85b2c47d57028ac669a3 /Alc
parent38db8eb64bad101e5c16133582c5c4e1a8716593 (diff)
Keep track of open devices
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 747a2456..6a4e27df 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -191,6 +191,9 @@ static ALCint alcEFXMinorVersion = 0;
///////////////////////////////////////////////////////
// Global Variables
+static ALCdevice *g_pDeviceList = NULL;
+static ALCuint g_ulDeviceCount = 0;
+
// Context List
static ALCcontext *g_pContextList = NULL;
static ALCuint g_ulContextCount = 0;
@@ -468,6 +471,12 @@ ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL
pDevice->Funcs = &BackendList[i].Funcs;
if(ALCdevice_OpenCapture(pDevice, deviceName, frequency, format, SampleSize))
{
+ SuspendContext(NULL);
+ pDevice->next = g_pDeviceList;
+ g_pDeviceList = pDevice;
+ g_ulDeviceCount++;
+ ProcessContext(NULL);
+
DeviceFound = ALC_TRUE;
break;
}
@@ -491,9 +500,21 @@ ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL
ALCAPI ALCboolean ALCAPIENTRY alcCaptureCloseDevice(ALCdevice *pDevice)
{
ALCboolean bReturn = ALC_FALSE;
+ ALCdevice **list;
if ((pDevice)&&(pDevice->IsCaptureDevice))
{
+ SuspendContext(NULL);
+
+ list = &g_pDeviceList;
+ while(*list != pDevice)
+ list = &(*list)->next;
+
+ *list = (*list)->next;
+ g_ulDeviceCount--;
+
+ ProcessContext(NULL);
+
ALCdevice_CloseCapture(pDevice);
free(pDevice);
@@ -1157,6 +1178,12 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
device->Funcs = &BackendList[i].Funcs;
if(ALCdevice_OpenPlayback(device, deviceName))
{
+ SuspendContext(NULL);
+ device->next = g_pDeviceList;
+ g_pDeviceList = device;
+ g_ulDeviceCount++;
+ ProcessContext(NULL);
+
bDeviceFound = AL_TRUE;
break;
}
@@ -1182,9 +1209,21 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
ALCAPI ALCboolean ALCAPIENTRY alcCloseDevice(ALCdevice *pDevice)
{
ALCboolean bReturn = ALC_FALSE;
+ ALCdevice **list;
if ((pDevice)&&(!pDevice->IsCaptureDevice))
{
+ SuspendContext(NULL);
+
+ list = &g_pDeviceList;
+ while(*list != pDevice)
+ list = &(*list)->next;
+
+ *list = (*list)->next;
+ g_ulDeviceCount--;
+
+ ProcessContext(NULL);
+
ALCdevice_ClosePlayback(pDevice);
//Release device structure