ALSA is based on the familiar UNIX paradigm "everything is a file"; so to handle multiple devices, you should use poll(3).
There are ALSA plugins that are implemented on top of multiple files, so there might be more than one handle per PCM device.
Call snd_pcm_poll_descriptors_count for each device to know how many pollfd
structures you need, then call snd_pcm_poll_descriptors to get the file handles and the respective event
bits.
In your loop, after calling poll
, you must not read the vales in the pollfd
structures directly but call snd_pcm_poll_descriptors_revents to translate them back.
To ensure that multiple devices start at the same time, call snd_pcm_link. However, this does not guarantee that the devices will run at the same speed.