[ALSA架构][ASOC架构][第七话]如何写ALSA app 程序

简单粗暴,直接上图:

[ALSA架构][ASOC架构][第七话]如何写ALSA app 程序

如果是capture的话,只需要修改:

a.  SND_PCM_STREAM_PLAYBACK      ->       SND_PCM_STREAM_CAPTURE

		if ((err = snd_pcm_open (&capture_handle, argv[1], SND_PCM_STREAM_CAPTURE, 0)) < 0) {
			fprintf (stderr, "cannot open audio device %s (%s)\n", 
				 argv[1],
				 snd_strerror (err));
			exit (1);
		}

 b.  snd_pcm_writei       ->      snd_pcm_readi

		for (i = 0; i < 10; ++i) {
			if ((err = snd_pcm_readi (capture_handle, buf, 128)) != 128) {
				fprintf (stderr, "read from audio interface failed (%s)\n",
					 snd_strerror (err));
				exit (1);
			}
		}

 

上一篇:封装组件的时候报错Unknown custom element: router-view make sure to provide the name option.


下一篇:OpenCV-Python 图像分割与Watershed算法 | 三十四