Sending data to the PCM subchannel

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

The number of bytes written must be a multiple of the fragment size, or the write will fail.
The plugin accumulates partial writes until a complete fragment can be sent to the driver.

A full nonblocking write 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 calling snd_pcm_nonblock_mode().

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 write is to call select() (see the QNX Neutrino C Library Reference) to wait until the PCM subchannel can accept more data. This is the technique that the wave.c example uses. It allows the program to wait on user input while at the same time sending the playback data to 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's space for frag_size bytes in the subchannel. If your application tries to write more data than this, it may block on the call.