snd_pcm_t*open_pcm(char*pcm_name) {snd_pcm_t*playback_handle;snd_pcm_hw_params_t*hw_params;snd_pcm_sw_params_t*sw_params;if(snd_pcm_open (&playback_handle, pcm_name, SND_PCM_STREAM_PLAYBACK,0) <0) {fprintf(stderr,"cannot open audio device %s\n", pcm_name);exit(1); } ...
Mixer Interface:提供了关于混音器相关的一系列操作接口。 sound设备节点 在Linux内核设备驱动层,基于ALSA音频驱动框架注册的sound设备会在/dev/snd目录下生成相应的设备节点文件。会有如下设备文件: controlC0:用于声卡控制的设备节点,譬如通道选择、混音器、麦克风的控制等,C0表示声卡0(card0); pcmC0D0p:用于播放(或...
snd_pcm_sw_params_t*swparams,constchar*id) {interr;snd_pcm_uframes_tval;if((err = snd_pcm_hw_params(handle, params)) <0) {printf("Unable to set hw params for %s: %s\n", id, snd_strerror(err));returnerr;
{intchn;snd_mixer_t*handle;snd_mixer_elem_t*e;constchar*file = sd->file ? sd->file : DEFAULT_ALSA_SOUND_DEVICE;if(snd_mixer_open (&handle,0) >=0) {if(snd_mixer_attach (handle, file) >=0&& snd_mixer_load (handle) >=0&& snd_mixer_selem_register (handle,NULL,NULL) >=0)f...