aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/winmm.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-08-27 01:47:41 -0700
committerChris Robinson <[email protected]>2009-08-27 01:47:41 -0700
commit45dc8048193162edbb886921cfcf2955c5232626 (patch)
treed99e7a4cb49400b5395be15c69c34d3ad59c989e /Alc/winmm.c
parent81db01ebf1d6b608339b5288785f3c514dbcff27 (diff)
Store copies of the device names in the individual backends
Diffstat (limited to 'Alc/winmm.c')
-rw-r--r--Alc/winmm.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/Alc/winmm.c b/Alc/winmm.c
index 9b16b9eb..3b226f29 100644
--- a/Alc/winmm.c
+++ b/Alc/winmm.c
@@ -50,7 +50,8 @@ typedef struct {
} WinMMData;
-static ALCchar *CaptureDeviceList[16];
+static ALCchar **CaptureDeviceList;
+static ALuint NumCaptureDevices;
/*
WaveInProc
@@ -181,12 +182,12 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
WinMMData *pData = NULL;
ALint lDeviceID = 0;
ALint lBufferSize;
- ALint i;
+ ALuint i;
// Find the Device ID matching the deviceName if valid
if (deviceName)
{
- for(i = 0;CaptureDeviceList[i];i++)
+ for(i = 0;i < NumCaptureDevices;i++)
{
if (!strcmp(deviceName, CaptureDeviceList[i]))
{
@@ -194,7 +195,7 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
break;
}
}
- if(!CaptureDeviceList[i])
+ if(i == NumCaptureDevices)
return ALC_FALSE;
}
pDevice->szDeviceName = CaptureDeviceList[lDeviceID];
@@ -423,24 +424,35 @@ BackendFuncs WinMMFuncs = {
void alcWinMMInit(BackendFuncs *FuncList)
{
- ALint lNumDevs;
- ALint lLoop;
+ ALuint lLoop;
*FuncList = WinMMFuncs;
- lNumDevs = waveInGetNumDevs();
- for (lLoop = 0; lLoop < lNumDevs; lLoop++)
+ NumCaptureDevices = waveInGetNumDevs();
+ CaptureDeviceList = malloc(sizeof(ALCchar*) * NumCaptureDevices);
+ for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++)
{
WAVEINCAPS WaveInCaps;
+
+ CaptureDeviceList[lLoop] = strdup("");
if(waveInGetDevCaps(lLoop, &WaveInCaps, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR)
{
char name[128];
snprintf(name, sizeof(name), "WaveIn on %s", WaveInCaps.szPname);
- CaptureDeviceList[lLoop] = AppendCaptureDeviceList(name);
+ AppendCaptureDeviceList(name);
+ CaptureDeviceList[lLoop] = strdup(name);
}
}
}
void alcWinMMDeinit()
{
+ ALuint lLoop;
+
+ for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++)
+ free(CaptureDeviceList[lLoop]);
+ free(CaptureDeviceList);
+ CaptureDeviceList = NULL;
+
+ NumCaptureDevices = 0;
}