snd_pcm_access_name((snd_pcm_access_t)val)); printf("\nPCM formats:\n"); for (val = 0; val <= SND_PCM_FORMAT_LAST; val++) if (snd_pcm_format_name((snd_pcm_format_t)val) != NULL) printf(" %s (%s)\n", snd_pcm_format_name((snd_pcm_format_t)val), snd_pcm_format_de...
snd_pcm_format_description((snd_pcm_format_t)val)); } } printf("\nPCM subformats:\n;); for (val = 0; val <= SND_PCM_SUBFORMAT_LAST; val++) { printf(" %s (%s)\n", snd_pcm_subformat_name((snd_pcm_subformat_t)val), snd_pcm_subformat_description((snd_pcm_subformat_t)val...
int (*prepare)(struct snd_pcm_substream *substream); int (*trigger)(struct snd_pcm_substream *substream, int cmd); snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *substream); int (*copy)(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, void __u...
AlsaCapture类的构造函数 intAlsaCapture::capture(){while(1){interr;if((frames_readed=snd_pcm_readi(handle,output_buffer,frames))<0){// Overrun happenedif(frames_readed==-EPIPE){snd_pcm_prepare(handle);continue;}return-1;}else{returnframes_readed;}}} 1. 2. 3. 4. 5. 6. 7. 8. 9....
1, open, 这个和 oss 相同,对应于 alsa 就是 snd_pcm_open ; 2, param 设置,这个就是 snd_pcm_hw_params; 3, 上层的 alsa 在设置 param 的成功以后或者出错的时候恢复都需要调用 snd_pcm_prepare; 4, write 函数; 现在一个个的来看; 4.1.1 open 过程介绍 ...
snd_strerror (err)); exit (1); } //释放硬件参数设置 snd_pcm_hw_params_free (hw_params); //如果发生xrun故障,从该故障中恢复过来 if ((err = snd_pcm_prepare (capture_handle)) <0) { fprintf (stderr, "cannot prepareaudio interface for use (%s)\n", ...
.open = pxa2xx_ac97_pcm_open, .close = pxa2xx_ac97_pcm_close, .hw_params = pxa2xx_pcm_hw_params, .prepare = pxa2xx_ac97_pcm_prepare, .trigger = pxa2xx_pcm_trigger, .pointer = pxa2xx_pcm_pointer, }; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pxa2xx_ac97_pcm_ops...
snd_pcm_pause(pcm_handle,0);/* 1:暂停 0:播放 */for(snd_pcm_uframes_ti=0;i<data_size;){intrc=-1;/* 播放 */rc=snd_pcm_writei(pcm_handle,data+i,frame_num);goto_error_if_fail(rc>=0||rc==-EPIPE);if(rc==-EPIPE){/* 让音频设备准备好接收pcm数据 */snd_pcm_prepare(handle)...
(snd_pcm_uframes_t i=0;i<data_size;){intrc=-1;/* 播放 */rc=snd_pcm_writei(pcm_handle,data+i,frame_num);goto_error_if_fail(rc>=0||rc==-EPIPE);if(rc==-EPIPE){/* 让音频设备准备好接收pcm数据 */snd_pcm_prepare(handle);}else{i+=frame_num*frame_size;}}return0;error:...
需要注意的是,这两个函数需要使用前先调用snd_pcm_prepare() 函数进行准备操作。同时,要在读取完成或...