/* Handle for the PCM device */ 声明一个设备句柄.
snd_pcm_t *pcm_handle;
/* Playback stream */ 设置音频流的方向为播放
snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK;
/* This structure contains information about */声明一个硬件配置结构,用来配置相应的参数.
/* the hardware and can be used to specify the */
/* configuration to be used for the PCM stream. */
snd_pcm_hw_params_t *hwparams;
PCM设备在ALSA的接口有"plughw"和"hw",接口,不过我们这里使用默认的接口"default",char *pcm_name;//定义设备名称然后我们分配一个硬件配置结构体pcm_name = strdup("default");
/* Allocate the snd_pcm_hw_params_t structure on the stack. */
snd_pcm_hw_params_alloca(&hwparams); 现在我们可以打开设备了,
/* Open PCM. The last parameter of this function is the mode. */
/* If this is set to 0, the standard mode is used. Possible */
/* other values are SND_PCM_NONBLOCK and SND_PCM_ASYNC. */
/* If SND_PCM_NONBLOCK is used, read / write access to the */
/* PCM device will return immediately. If SND_PCM_ASYNC is */
/* specified, SIGIO will be emitted whenever a period has */
/
5541



被折叠的 条评论
为什么被折叠?



