Receiving data from the PCM subchannel

The function that you call to receive data from the subchannel depends on whether or not you're using plugin converters.

snd_pcm_read()
The number of bytes read must be a multiple of the fragment size, or the read fails.
snd_pcm_plugin_read()
The plugin reads an entire fragment from the driver and then fulfills requests for partial reads from that buffer until another full fragment has to be read.

A full nonblocking read mode is supported if the application can't afford to be blocked on the PCM subchannel. You can enable nonblocking mode when you open the handle or by using the snd_pcm_nonblock_mode() API call.

Note: This approach results in a polled operation mode that isn't recommended.

Another method that your application can use to avoid blocking on the read is to use select() (see the QNX Neutrino C Library Reference) to wait until the PCM subchannel has more data. This is the technique that the waverec.c example uses. It allows the program to wait on user input while at the same time receiving the capture data from the PCM subchannel.

To get the file descriptor to pass to select(), call snd_pcm_file_descriptor().

Note: With this technique, select() returns when there are frag_size bytes in the subchannel. If your application tries to read more data than this, it may block on the call.