我需要在运行时控制音频输出设备:
1) Main Speaker only
2) Headphone Only
3) Headphone + Main Speaker both together
我的应用程序需要运行时决定在上述组合之间切换。我应该将ALSA API用于上述目的。
(我使用Linux 3.0,ALSA,C,TI tlv320aic3x,ARM)。
答案 0 :(得分:2)
你可以用这个:
int snd_mixer_selem_set_playback_volume(snd_mixer_elem_t *elem,
snd_mixer_selem_channel_id_t channel, long value)
which sets value of playback volume control of a mixer simple element.
这是一个source code example:
/* Set new volume */
if (snd_mixer_selem_set_playback_volume(elem,
SND_MIXER_SCHN_FRONT_LEFT, left_volume) != 0)
return (-1);
if (snd_mixer_selem_set_playback_volume(elem,
SND_MIXER_SCHN_FRONT_RIGHT, right_volume) != 0)
return (-1);