我正在寻找使用ALSA API确定设备是否为默认值的示例。
检查是否为此格式的字符串:
const *char device = "hw:1,0"
我想使用ALSA API创建一个函数,如果设置为“默认”ALSA设备则返回1,否则返回0
static int alsa_is_default_device (const *char device)
{
/* ALSA API */
}
也许正在使用
snd_config_search( snd_config, "defaults.ctl.card", &config )
欢迎任何帮助
我使用自定义alsa模块控制音频设备:
err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0);
我试图将'device'的'hw:0,0'传递给此函数并返回错误:
Failed to set a supported rate. Operation not permitted.
如果我为设备传递“默认”,那就可以了。
我需要对未设置为ALSA DEFAULT DEVICE(例如hw:1,0)的设备使用'hw:x,x'形式,对于ALSA DEFAULT DEVICE使用'default',因为大多数默认设置设备(plughw,默认等)支持自动转换,因此接受所有格式。 hw设备没有。我需要相同的声音设备来协商采样率转换,
aplay -L输出示例:
null
Discard all samples (playback) or generate zero samples (capture)
pulse
PulseAudio Sound Server
default
Playback/recording through the PulseAudio sound server
sysdefault:CARD=ICH5
Intel ICH5, Intel ICH5
Default Audio Device
front:CARD=ICH5,DEV=0
Intel ICH5, Intel ICH5
Front speakers
surround40:CARD=ICH5,DEV=0
Intel ICH5, Intel ICH5
4.0 Surround output to Front and Rear speakers
surround41:CARD=ICH5,DEV=0
Intel ICH5, Intel ICH5
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=ICH5,DEV=0
Intel ICH5, Intel ICH5
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=ICH5,DEV=0
Intel ICH5, Intel ICH5
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
iec958:CARD=ICH5,DEV=0
Intel ICH5, Intel ICH5 - IEC958
IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=ICH5,DEV=0
Intel ICH5, Intel ICH5
Direct sample mixing device
dmix:CARD=ICH5,DEV=4
Intel ICH5, Intel ICH5 - IEC958
Direct sample mixing device
dsnoop:CARD=ICH5,DEV=0
Intel ICH5, Intel ICH5
Direct sample snooping device
dsnoop:CARD=ICH5,DEV=4
Intel ICH5, Intel ICH5 - IEC958
Direct sample snooping device
hw:CARD=ICH5,DEV=0
Intel ICH5, Intel ICH5
Direct hardware device without any conversions
hw:CARD=ICH5,DEV=4
Intel ICH5, Intel ICH5 - IEC958
Direct hardware device without any conversions
plughw:CARD=ICH5,DEV=0
Intel ICH5, Intel ICH5
Hardware device with all software conversions
plughw:CARD=ICH5,DEV=4
Intel ICH5, Intel ICH5 - IEC958
Hardware device with all software conversions