snd_mixer_elem_t* elem = NULL;
snd_mixer_t* mixer;
snd_mixer_open(&mixer, 0);
snd_mixer_attach(mixer, "default");
snd_mixer_selem_register(mixer, NULL, NULL);
snd_mixer_load(mixer);
for(elem=snd_mixer_first_elem(mixer);elem;elem=snd_mixer_elem_next(elem))
{
if(!strcmp(snd_mixer_selem_get_name(elem), "Master"))
break;
}
snd_mixer_selem_set_playback_volume_range(elem, 0, 100); // range : 0 ~ 100
snd_mixer_selem_set_playback_switch_all(elem, 1);
下面的程式碼則是找出錄音來源的控制項並將它切換到編號一所對應的選項。這種控制項和上面的音量控制不同,它沒有百分比計和靜音開關,只能從幾個 options 中挑一個來用。
snd_mixer_elem_t* elem = NULL;
snd_mixer_t* mixer;
snd_mixer_open(&mixer, 0);
snd_mixer_attach(mixer, "default");
snd_mixer_selem_register(mixer, NULL, NULL);
snd_mixer_load(mixer);
for(elem=snd_mixer_first_elem(mixer);elem;elem=snd_mixer_elem_next(elem))
{
if(!strcmp(snd_mixer_selem_get_name(elem), "Input Source"))
break;
}
snd_mixer_selem_set_enum_item(elem, SND_MIXER_SCHN_MONO, 1);
沒有留言:
張貼留言