aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/winmm.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-03-09 05:44:18 -0800
committerChris Robinson <[email protected]>2010-03-09 05:44:18 -0800
commit2ba3a88ace65803393c7f4bdb1b9e158a644d05e (patch)
tree01df5f2c360f9f9f900f91720033827f5fa9c91a /Alc/winmm.c
parent1f10195c47f9747dcd262879c84e614ae3d33cab (diff)
Probe physical devices separately from appending them to the device list
Diffstat (limited to 'Alc/winmm.c')
-rw-r--r--Alc/winmm.c66
1 files changed, 44 insertions, 22 deletions
diff --git a/Alc/winmm.c b/Alc/winmm.c
index 6dd88191..54ec2f30 100644
--- a/Alc/winmm.c
+++ b/Alc/winmm.c
@@ -53,6 +53,29 @@ typedef struct {
static ALCchar **CaptureDeviceList;
static ALuint NumCaptureDevices;
+static void ProbeDevices(void)
+{
+ ALuint i;
+
+ for(i = 0;i < NumCaptureDevices;i++)
+ free(CaptureDeviceList[i]);
+
+ NumCaptureDevices = waveInGetNumDevs();
+ CaptureDeviceList = realloc(CaptureDeviceList, sizeof(ALCchar*) * NumCaptureDevices);
+ for(i = 0;i < NumCaptureDevices;i++)
+ {
+ WAVEINCAPS WaveInCaps;
+
+ CaptureDeviceList[i] = NULL;
+ if(waveInGetDevCaps(i, &WaveInCaps, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR)
+ {
+ char name[128];
+ snprintf(name, sizeof(name), "WaveIn on %s", WaveInCaps.szPname);
+ CaptureDeviceList[i] = strdup(name);
+ }
+ }
+}
+
/*
WaveInProc
@@ -185,19 +208,31 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
ALuint i;
// Find the Device ID matching the deviceName if valid
- if (deviceName)
+ if(deviceName)
+ {
+ for(i = 0;i < NumCaptureDevices;i++)
+ {
+ if(CaptureDeviceList[i] &&
+ strcmp(deviceName, CaptureDeviceList[i]) == 0)
+ {
+ lDeviceID = i;
+ break;
+ }
+ }
+ }
+ else
{
for(i = 0;i < NumCaptureDevices;i++)
{
- if (!strcmp(deviceName, CaptureDeviceList[i]))
+ if(CaptureDeviceList[i])
{
lDeviceID = i;
break;
}
}
- if(i == NumCaptureDevices)
- return ALC_FALSE;
}
+ if(i == NumCaptureDevices)
+ return ALC_FALSE;
pData = calloc(1, sizeof(*pData));
if(!pData)
@@ -443,28 +478,15 @@ void alcWinMMDeinit()
void alcWinMMProbe(int type)
{
- ALuint lLoop;
+ ALuint i;
if(type != CAPTURE_DEVICE_PROBE)
return;
- for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++)
- free(CaptureDeviceList[lLoop]);
-
- NumCaptureDevices = waveInGetNumDevs();
- CaptureDeviceList = realloc(CaptureDeviceList, sizeof(ALCchar*) * NumCaptureDevices);
- for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++)
+ ProbeDevices();
+ for(i = 0;i < NumCaptureDevices;i++)
{
- WAVEINCAPS WaveInCaps;
-
- if(waveInGetDevCaps(lLoop, &WaveInCaps, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR)
- {
- char name[128];
- snprintf(name, sizeof(name), "WaveIn on %s", WaveInCaps.szPname);
- AppendCaptureDeviceList(name);
- CaptureDeviceList[lLoop] = strdup(name);
- }
- else
- CaptureDeviceList[lLoop] = strdup("");
+ if(CaptureDeviceList[i])
+ AppendCaptureDeviceList(CaptureDeviceList[i]);
}
}