Functions | |
int | snd_pcm_mmap_begin (snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames) |
Application request to access a portion of direct (mmap) area. | |
snd_pcm_sframes_t | snd_pcm_mmap_commit (snd_pcm_t *pcm, snd_pcm_uframes_t offset, snd_pcm_uframes_t frames) |
Application has completed the access to area requested with snd_pcm_mmap_begin. | |
snd_pcm_sframes_t | snd_pcm_mmap_writei (snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size) |
Write interleaved frames to a PCM using direct buffer (mmap). | |
snd_pcm_sframes_t | snd_pcm_mmap_readi (snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size) |
Read interleaved frames from a PCM using direct buffer (mmap). | |
snd_pcm_sframes_t | snd_pcm_mmap_writen (snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size) |
Write non interleaved frames to a PCM using direct buffer (mmap). | |
snd_pcm_sframes_t | snd_pcm_mmap_readn (snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size) |
Read non interleaved frames to a PCM using direct buffer (mmap). |
int snd_pcm_mmap_begin | ( | snd_pcm_t * | pcm, | |
const snd_pcm_channel_area_t ** | areas, | |||
snd_pcm_uframes_t * | offset, | |||
snd_pcm_uframes_t * | frames | |||
) |
Application request to access a portion of direct (mmap) area.
pcm | PCM handle | |
areas | Returned mmap channel areas | |
offset | Returned mmap area offset in area steps (== frames) | |
frames | mmap area portion size in frames (wanted on entry, contiguous available on exit) |
The function should be called before a sample-direct area can be accessed. The resulting size parameter is always less or equal to the input count of frames and can be zero, if no frames can be processed (the ring buffer is full).
See the snd_pcm_mmap_commit() function to finish the frame processing in the direct areas.
snd_pcm_sframes_t snd_pcm_mmap_commit | ( | snd_pcm_t * | pcm, | |
snd_pcm_uframes_t | offset, | |||
snd_pcm_uframes_t | frames | |||
) |
Application has completed the access to area requested with snd_pcm_mmap_begin.
pcm | PCM handle | |
offset | area offset in area steps (== frames) | |
frames | area portion size in frames |
Example:
double phase = 0; const snd_pcm_area_t *areas; snd_pcm_sframes_t avail, size, commitres; snd_pcm_uframes_t offset, frames; int err; avail = snd_pcm_avail_update(pcm); if (avail < 0) error(avail); // at this point, we can transfer at least 'avail' frames // we want to process frames in chunks (period_size) if (avail < period_size) goto _skip; size = period_size; // it is possible that contiguous areas are smaller, thus we use a loop while (size > 0) { frames = size; err = snd_pcm_mmap_begin(pcm_handle, &areas, &offset, &frames); if (err < 0) error(err); // this function fills the areas from offset with count of frames generate_sine(areas, offset, frames, &phase); commitres = snd_pcm_mmap_commit(pcm_handle, offset, frames); if (commitres < 0 || commitres != frames) error(commitres >= 0 ? -EPIPE : commitres); size -= frames; } _skip:
Look to the Sine-wave generator example for more details about the generate_sine function.
snd_pcm_sframes_t snd_pcm_mmap_readi | ( | snd_pcm_t * | pcm, | |
void * | buffer, | |||
snd_pcm_uframes_t | size | |||
) |
Read interleaved frames from a PCM using direct buffer (mmap).
pcm | PCM handle | |
buffer | frames containing buffer | |
size | frames to be written |
-EBADFD | PCM is not in the right state (SND_PCM_STATE_PREPARED or SND_PCM_STATE_RUNNING) | |
-EPIPE | an overrun occurred | |
-ESTRPIPE | a suspend event occurred (stream is suspended and waiting for an application recovery) |
If the non-blocking behaviour is selected, then routine doesn't wait at all.
snd_pcm_sframes_t snd_pcm_mmap_readn | ( | snd_pcm_t * | pcm, | |
void ** | bufs, | |||
snd_pcm_uframes_t | size | |||
) |
Read non interleaved frames to a PCM using direct buffer (mmap).
pcm | PCM handle | |
bufs | frames containing buffers (one for each channel) | |
size | frames to be written |
-EBADFD | PCM is not in the right state (SND_PCM_STATE_PREPARED or SND_PCM_STATE_RUNNING) | |
-EPIPE | an overrun occurred | |
-ESTRPIPE | a suspend event occurred (stream is suspended and waiting for an application recovery) |
If the non-blocking behaviour is selected, then routine doesn't wait at all.
snd_pcm_sframes_t snd_pcm_mmap_writei | ( | snd_pcm_t * | pcm, | |
const void * | buffer, | |||
snd_pcm_uframes_t | size | |||
) |
Write interleaved frames to a PCM using direct buffer (mmap).
pcm | PCM handle | |
buffer | frames containing buffer | |
size | frames to be written |
-EBADFD | PCM is not in the right state (SND_PCM_STATE_PREPARED or SND_PCM_STATE_RUNNING) | |
-EPIPE | an underrun occurred | |
-ESTRPIPE | a suspend event occurred (stream is suspended and waiting for an application recovery) |
If the non-blocking behaviour is selected, then routine doesn't wait at all.
snd_pcm_sframes_t snd_pcm_mmap_writen | ( | snd_pcm_t * | pcm, | |
void ** | bufs, | |||
snd_pcm_uframes_t | size | |||
) |
Write non interleaved frames to a PCM using direct buffer (mmap).
pcm | PCM handle | |
bufs | frames containing buffers (one for each channel) | |
size | frames to be written |
-EBADFD | PCM is not in the right state (SND_PCM_STATE_PREPARED or SND_PCM_STATE_RUNNING) | |
-EPIPE | an underrun occurred | |
-ESTRPIPE | a suspend event occurred (stream is suspended and waiting for an application recovery) |
If the non-blocking behaviour is selected, then routine doesn't wait at all.