aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-03-01 04:58:28 -0800
committerChris Robinson <[email protected]>2012-03-01 04:58:28 -0800
commit55556f0e6c3d6f6ae374e0513bf92ba0b8caaef3 (patch)
tree9ba65c2bdce51a1e93a44ef71404319aa2d5d9b1 /Alc/backends
parent7d9cabebff8e1871dff847f6f7c807ab0f08d028 (diff)
Avoid enumerating when opening the default ALSA device
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/alsa.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c
index cf0fd378..7ea3478b 100644
--- a/Alc/backends/alsa.c
+++ b/Alc/backends/alsa.c
@@ -579,18 +579,13 @@ static ALCenum alsa_open_playback(ALCdevice *device, const ALCchar *deviceName)
alsa_data *data;
int err;
- if(!allDevNameMap)
- allDevNameMap = probe_devices(SND_PCM_STREAM_PLAYBACK, &numDevNames);
-
- if(!deviceName && numDevNames > 0)
- {
- deviceName = allDevNameMap[0].name;
- driver = allDevNameMap[0].device;
- }
- else
+ if(deviceName)
{
size_t idx;
+ if(!allDevNameMap)
+ allDevNameMap = probe_devices(SND_PCM_STREAM_PLAYBACK, &numDevNames);
+
for(idx = 0;idx < numDevNames;idx++)
{
if(strcmp(deviceName, allDevNameMap[idx].name) == 0)
@@ -602,6 +597,11 @@ static ALCenum alsa_open_playback(ALCdevice *device, const ALCchar *deviceName)
if(idx == numDevNames)
return ALC_INVALID_VALUE;
}
+ else
+ {
+ deviceName = alsaDevice;
+ driver = GetConfigValue("alsa", "device", "default");
+ }
data = (alsa_data*)calloc(1, sizeof(alsa_data));
@@ -846,18 +846,13 @@ static ALCenum alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceName)
alsa_data *data;
int err;
- if(!allCaptureDevNameMap)
- allCaptureDevNameMap = probe_devices(SND_PCM_STREAM_CAPTURE, &numCaptureDevNames);
-
- if(!deviceName && numCaptureDevNames > 0)
- {
- deviceName = allCaptureDevNameMap[0].name;
- driver = allCaptureDevNameMap[0].device;
- }
- else
+ if(deviceName)
{
size_t idx;
+ if(!allCaptureDevNameMap)
+ allCaptureDevNameMap = probe_devices(SND_PCM_STREAM_CAPTURE, &numCaptureDevNames);
+
for(idx = 0;idx < numCaptureDevNames;idx++)
{
if(strcmp(deviceName, allCaptureDevNameMap[idx].name) == 0)
@@ -869,6 +864,11 @@ static ALCenum alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceName)
if(idx == numCaptureDevNames)
return ALC_INVALID_VALUE;
}
+ else
+ {
+ deviceName = alsaDevice;
+ driver = GetConfigValue("alsa", "capture", "default");
+ }
data = (alsa_data*)calloc(1, sizeof(alsa_data));