I'm new to sound programming and ALSA. I'd like to create a little application, that for example prints out to the console when a frame of data is written to ALSA with snd_pcm_writei(...)
. Is that possible and if so, how? Currently I'm thinking of registering a callback to ALSA so when an application calls snd_pcm_writei(...)
the callback is executed. But I'm not sure that is how it works.
You can either use
snd_pcm_write*()
returns only when all the data has been written into the ring buffer (or when an error has occured), or SND_PCM_NONBLOCK
when opening, or snd_pcm_nonblock()
), in which you can use poll()
/ epoll()
etc. to get a notification. Using an ALSA async handler works only with certain devices, and has all the drawbacks of signal handlers; it is deprecated.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.