Transfer PCM data to playback channel
#include <sys/asoundlib.h> ssize_t snd_pcm_write( snd_pcm_t *handle, const void *buffer, size_t size );
Use the -l asound option to qcc to link against this library.
This function may suspend a process if blocking behavior is active (see snd_pcm_nonblock_mode()) and no space is available in the device's buffers.
When the subdevice is in block mode (SND_PCM_MODE_BLOCK), then the number of written bytes must fulfill the N × fragment-size expression, where N > 0.
If the stream format is noninterleaved (the interleave member of the snd_pcm_format_t structure isn't set), then the driver expects that data in one fragment is separated to single voice blocks. For example, imagine that you have two voices, and the fragment size is 512 bytes. The number of bytes per one voice is 256. The driver expects that the first 256 bytes contain samples for the first voice and the second 256 bytes from fragment contain samples for the second voice.
A positive value that represents the number of bytes that were successfully written to the device if the playback was successful, or an error value if an error occurred.
- Try again later. The subchannel is opened nonblock.
- One of the following:
- The handle is invalid.
- The buffer argument is NULL, but the size is greater than zero.
- The size is negative.
- An invalid state change occurred. You can call snd_pcm_plugin_status() to check if the state change was invalid.
- One of:
- The channel isn't in the prepared or running state.
- In SND_PCM_MODE_BLOCK mode, the size isn't an even multiple of the frag_size member of the snd_pcm_channel_setup_t structure.
- The write would have blocked (nonblocking write).
|Thread||Read the Caveats|
This function is not thread safe if handle (snd_pcm_t) is used across multiple threads.
Last modified: 2014-06-24