ALSA project - the C library reference
|
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. More... | |
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. More... | |
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) More... | |
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) More... | |
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) More... | |
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) More... | |
See the PCM (digital audio) interface page for more details.
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) |
It is necessary to call the snd_pcm_avail_update() function directly before this call. Otherwise, this function can return a wrong count of available frames.
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.
The function is thread-safe when built with the proper option.
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 |
You should pass this function the offset value that snd_pcm_mmap_begin() returned. The frames parameter should hold the number of frames you have written or read to/from the audio buffer. The frames parameter must never exceed the contiguous frames count that snd_pcm_mmap_begin() returned. Each call to snd_pcm_mmap_begin() must be followed by a call to snd_pcm_mmap_commit().
Example:
Look to the Sine-wave generator example for more details about the generate_sine function.
The function is thread-safe when built with the proper option.
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 read |
-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 blocking behaviour was selected, then routine waits until all requested bytes are filled. The count of bytes can be less only if a signal or underrun occurred.
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 blocking behaviour was selected, then routine waits until all requested bytes are filled. The count of bytes can be less only if a signal or underrun occurred.
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 blocking behaviour is selected, then routine waits until all requested bytes are played or put to the playback ring buffer. The count of bytes can be less only if a signal or underrun occurred.
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 blocking behaviour is selected, then routine waits until all requested bytes are played or put to the playback ring buffer. The count of bytes can be less only if a signal or underrun occurred.
If the non-blocking behaviour is selected, then routine doesn't wait at all.