我想在播放器中控制音量,通过下面的方法在Ubuntu pc机上没有问题,但是在arm板上调用snd_mixer_first_elem总是返回NULL,找了很久也没有找到原因,求救,
snd_mixer_open(&handle,0);
snd_mixer_attach(handle,"default");
snd_mixer_selem_register(handle,NULL,NULL);
snd_mixer_load(handle);
//elem = snd_mixer_find_selem(handle,sid);
elem = snd_mixer_first_elem(handle);
if(elem == NULL)
{
fprintf(stderr, "Error snd_mixer_first_elem\n");
return -1;}else{
snd_mixer_selem_set_playback_volume_range(elem,0,100);
// snd_mixer_selem_set_playback_switch_all(elem,1);
ret = snd_mixer_selem_set_playback_volume_all(elem,value);
if(ret < 0)
{
fprintf(stderr, "Error snd_mixer_selem_set_playback_volume_all [%d]\n",ret);
return -1;
}
}
snd_mixer_close(handle); |