[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); } }
标签:capture,snd,架构,STREAM,err,app,PCM,pcm,ALSA 来源: https://blog.csdn.net/baidu_36250852/article/details/120622376