diff options
author | Chris Robinson <[email protected]> | 2011-08-19 04:02:36 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-08-19 04:02:36 -0700 |
commit | 6b8475b4356918242bd6704855adce4b4a1f111d (patch) | |
tree | 60b664dbe474d422510ed8de25523bbefb1b9a8e | |
parent | e51295c79edffb7dd2bd4fe6211a193c08735b32 (diff) |
Add options to specify alternate ALSA device prefixes
-rw-r--r-- | Alc/alsa.c | 17 | ||||
-rw-r--r-- | alsoftrc.sample | 12 |
2 files changed, 24 insertions, 5 deletions
@@ -266,6 +266,9 @@ static ALuint numDevNames; static DevMap *allCaptureDevNameMap; static ALuint numCaptureDevNames; +static const char *device_prefix; +static const char *capture_prefix; + static DevMap *probe_devices(snd_pcm_stream_t stream, ALuint *count) { @@ -327,7 +330,7 @@ static DevMap *probe_devices(snd_pcm_stream_t stream, ALuint *count) DevList = temp; cname = snd_ctl_card_info_get_name(info); dname = snd_pcm_info_get_name(pcminfo); - snprintf(name, sizeof(name), "%s [%s] (hw:%d,%d)", + snprintf(name, sizeof(name), "%s, %s (CARD=%d,DEV=%d)", cname, dname, card, dev); DevList[idx].name = strdup(name); DevList[idx].card = card; @@ -516,7 +519,7 @@ static ALuint ALSANoMMapProc(ALvoid *ptr) static ALCboolean alsa_open_playback(ALCdevice *device, const ALCchar *deviceName) { alsa_data *data; - char driver[64]; + char driver[128]; int i; strncpy(driver, GetConfigValue("alsa", "device", "default"), sizeof(driver)-1); @@ -537,7 +540,8 @@ static ALCboolean alsa_open_playback(ALCdevice *device, const ALCchar *deviceNam strcmp(deviceName, allDevNameMap[idx].name) == 0) { if(idx > 0) - sprintf(driver, "hw:%d,%d", allDevNameMap[idx].card, allDevNameMap[idx].dev); + snprintf(driver, sizeof(driver), "%sCARD=%d,DEV=%d", device_prefix, + allDevNameMap[idx].card, allDevNameMap[idx].dev); break; } } @@ -795,7 +799,7 @@ static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam snd_pcm_format_t format; ALuint frameSize; alsa_data *data; - char driver[64]; + char driver[128]; char *err; int i; @@ -817,7 +821,8 @@ static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam strcmp(deviceName, allCaptureDevNameMap[idx].name) == 0) { if(idx > 0) - sprintf(driver, "plughw:%d,%d", allCaptureDevNameMap[idx].card, allCaptureDevNameMap[idx].dev); + snprintf(driver, sizeof(driver), "%sCARD=%d,DEV=%d", capture_prefix, + allCaptureDevNameMap[idx].card, allCaptureDevNameMap[idx].dev); break; } } @@ -1050,6 +1055,8 @@ 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; } diff --git a/alsoftrc.sample b/alsoftrc.sample index 9ea4af15..53645f2c 100644 --- a/alsoftrc.sample +++ b/alsoftrc.sample @@ -177,10 +177,22 @@ # Sets the device name for the default playback device. #device = default +## device-prefix: +# Sets the prefix used by the discovered (non-default) playback devices. This +# will be appended with "CARD=c,DEV=d", where c is the card number and d is +# the device number for the requested device name. +#device-prefix = plughw: + ## capture: # Sets the device name for the default capture device. #capture = default +## capture-prefix: +# Sets the prefix used by the discovered (non-default) capture devices. This +# will be appended with "CARD=c,DEV=d", where c is the card number and d is +# the device number for the requested device name. +#capture-prefix = plughw: + ## mmap: # Sets whether to try using mmap mode (helps reduce latencies and CPU # consumption). If mmap isn't available, it will automatically fall back to |