aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/alsa.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-02-11 09:36:40 -0800
committerChris Robinson <[email protected]>2012-02-11 09:36:40 -0800
commitb375b130babf7dd08bb666abb46c035807ee4549 (patch)
treeed4f53ec96b307db2bc74d40a898583c91beded3 /Alc/backends/alsa.c
parent3fb63512125057504d5e06768a08cb0250b8a90f (diff)
Add config options for card- and device-specific prefixes in ALSA device names
Diffstat (limited to 'Alc/backends/alsa.c')
-rw-r--r--Alc/backends/alsa.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c
index 7d1797f4..fa059e44 100644
--- a/Alc/backends/alsa.c
+++ b/Alc/backends/alsa.c
@@ -281,9 +281,12 @@ static ALuint numDevNames;
static DevMap *allCaptureDevNameMap;
static ALuint numCaptureDevNames;
-static const char *device_prefix;
-static const char *capture_prefix;
+static const char *prefix_name(snd_pcm_stream_t stream)
+{
+ assert(stream == SND_PCM_STREAM_PLAYBACK || stream == SND_PCM_STREAM_CAPTURE);
+ return (stream==SND_PCM_STREAM_PLAYBACK) ? "device-prefix" : "capture-prefix";
+}
static DevMap *probe_devices(snd_pcm_stream_t stream, ALuint *count)
{
@@ -292,7 +295,6 @@ static DevMap *probe_devices(snd_pcm_stream_t stream, ALuint *count)
snd_ctl_card_info_t *info;
snd_pcm_info_t *pcminfo;
DevMap *DevList;
- char name[256];
snd_ctl_card_info_malloc(&info);
snd_pcm_info_malloc(&pcminfo);
@@ -307,6 +309,8 @@ static DevMap *probe_devices(snd_pcm_stream_t stream, ALuint *count)
idx = 1;
while(card >= 0)
{
+ char name[256];
+
sprintf(name, "hw:%d", card);
if((err = snd_ctl_open(&handle, name, 0)) < 0)
{
@@ -343,6 +347,7 @@ static DevMap *probe_devices(snd_pcm_stream_t stream, ALuint *count)
temp = realloc(DevList, sizeof(DevMap) * (idx+1));
if(temp)
{
+ const char *prefix = "plughw:";
char devname[128];
DevList = temp;
@@ -350,11 +355,18 @@ static DevMap *probe_devices(snd_pcm_stream_t stream, ALuint *count)
dname = snd_pcm_info_get_name(pcminfo);
cid = snd_ctl_card_info_get_id(info);
+ snprintf(devname, sizeof(devname), "%s-%s-%d", prefix_name(stream), cid, dev);
+ if(!ConfigValueStr("alsa", devname, &prefix))
+ {
+ snprintf(devname, sizeof(devname), "%s-%s", prefix_name(stream), cid);
+ if(!ConfigValueStr("alsa", devname, &prefix))
+ ConfigValueStr("alsa", prefix_name(stream), &prefix);
+ }
+
snprintf(name, sizeof(name), "%s, %s (CARD=%s,DEV=%d)",
cname, dname, cid, dev);
snprintf(devname, sizeof(devname), "%sCARD=%s,DEV=%d",
- ((stream==SND_PCM_STREAM_PLAYBACK) ? device_prefix : capture_prefix),
- cid, dev);
+ prefix, cid, dev);
DevList[idx].name = strdup(name);
DevList[idx].device = strdup(devname);
@@ -1094,8 +1106,6 @@ ALCboolean alc_alsa_init(BackendFuncs *func_list)
{
if(!alsa_load())
return ALC_FALSE;
- device_prefix = GetConfigValue("alsa", "device-prefix", "plughw:");
- capture_prefix = GetConfigValue("alsa", "capture-prefix", "plughw:");
*func_list = alsa_funcs;
return ALC_TRUE;
}