snd_pcm_writev

Name

snd_pcm_writev -- send PCM stream to playback (using I/O vector)

Synopsis

ssize_t snd_pcm_writev(snd_pcm_t *handle, const struct iovec *vector, int count);

Description

Writes samples to the device which must be in the proper format specified by snd_pcm_channel_prepare function. The multiple buffers may be passed via the vector parameter. Function returns positive value if playback was successful (value represents count of bytes which were successfully written to device) or an error value if an error occurred. If the subdevice has the queue full, -EAGAIN result code is returned. Function will suspend process if block behaviour (see to snd_pcm_nonblock_mode) is active.

When the interleaved format is chosen, then the operation is same as with standard writevfunction. In the block mode, the all buffers must be with same size as the fragment size. In the stream mode, the buffers must be aligned to samples.

The streams which contain non-interleaved samples are handled differently. The samples for single voices are assigned to the vector numbers. For example, the vector number zero corresponds to the first voice and so on (voice = vector number modulo count of voices, thus more buffers may be processed like when the interleaved is used). In the block mode, the vector must point to the buffer with samples for one voice. This buffers must be fragment size divide used voices long. In the stream mode, the vector buffer must be aligned to samples and each buffers for one chunk ('used voices' vectors) must contain same sample count. If the vector points to NULL, then the silence is used.