#define SND_PCM_ASYNC |
Async notification (flag for open mode)
#define SND_PCM_DLSYM_VERSION _dlsym_pcm_001 |
dlsym version for interface entry callback
#define SND_PCM_NONBLOCK |
Non blocking mode (flag for open mode)
typedef struct _snd_pcm_access_mask snd_pcm_access_mask_t |
PCM access types mask
typedef enum _snd_pcm_access snd_pcm_access_t |
PCM access type
typedef struct _snd_pcm_channel_area snd_pcm_channel_area_t |
PCM area specification
typedef enum _snd_pcm_class snd_pcm_class_t |
PCM class
typedef struct _snd_pcm_format_mask snd_pcm_format_mask_t |
PCM formats mask
typedef enum _snd_pcm_format snd_pcm_format_t |
PCM sample format
typedef struct _snd_pcm_hw_params snd_pcm_hw_params_t |
PCM hardware configuration space container
typedef struct _snd_pcm_info snd_pcm_info_t |
PCM generic info container
typedef struct _snd_pcm_scope snd_pcm_scope_t |
SND_PCM_TYPE_METER scope handle
typedef long snd_pcm_sframes_t |
Signed frames quantity
typedef enum _snd_pcm_start snd_pcm_start_t |
PCM start mode
typedef enum _snd_pcm_state snd_pcm_state_t |
PCM state
typedef struct _snd_pcm_status snd_pcm_status_t |
PCM status container
typedef enum _snd_pcm_stream snd_pcm_stream_t |
PCM stream (direction)
typedef enum _snd_pcm_subclass snd_pcm_subclass_t |
PCM subclass
typedef struct _snd_pcm_subformat_mask snd_pcm_subformat_mask_t |
PCM subformats mask
typedef enum _snd_pcm_subformat snd_pcm_subformat_t |
PCM sample subformat
typedef struct _snd_pcm_sw_params snd_pcm_sw_params_t |
PCM software configuration container
typedef union _snd_pcm_sync_id snd_pcm_sync_id_t |
PCM synchronization ID
typedef struct _snd_pcm snd_pcm_t |
PCM handle
typedef enum _snd_pcm_tstamp snd_pcm_tstamp_t |
PCM timestamp mode
typedef enum _snd_pcm_type snd_pcm_type_t |
PCM type
typedef unsigned long snd_pcm_uframes_t |
Unsigned frames quantity
typedef enum _snd_pcm_xrun snd_pcm_xrun_t |
PCM xrun mode
enum _snd_pcm_access |
PCM access type
enum _snd_pcm_class |
enum _snd_pcm_format |
PCM sample format
enum _snd_pcm_start |
enum _snd_pcm_state |
PCM state
enum _snd_pcm_stream |
enum _snd_pcm_subclass |
enum _snd_pcm_subformat |
enum _snd_pcm_tstamp |
enum _snd_pcm_type |
PCM type
enum _snd_pcm_xrun |
int snd_async_add_pcm_handler | ( | snd_async_handler_t ** | handler, | |
snd_pcm_t * | pcm, | |||
snd_async_callback_t | callback, | |||
void * | private_data | |||
) |
Add an async handler for a PCM.
handler | Returned handler handle | |
pcm | PCM handle | |
callback | Callback function | |
private_data | Callback private data |
snd_pcm_t* snd_async_handler_get_pcm | ( | snd_async_handler_t * | handler | ) |
Return PCM handle related to an async handler.
handler | Async handler handle |
snd_pcm_sframes_t snd_pcm_avail_update | ( | snd_pcm_t * | pcm | ) |
Return number of frames ready to be read/written.
pcm | PCM handle |
Using of this function is useless for the standard read/write operations. Use it only for mmap access. See to snd_pcm_delay.
int snd_pcm_close | ( | snd_pcm_t * | pcm | ) |
close PCM handle
pcm | PCM handle |
int snd_pcm_delay | ( | snd_pcm_t * | pcm, | |
snd_pcm_sframes_t * | delayp | |||
) |
Obtain delay for a running PCM handle.
pcm | PCM handle | |
delayp | Returned delay in frames |
Note this function does not update the actual r/w pointer for applications. The function snd_pcm_avail_update() have to be called before any begin+commit operation.
int snd_pcm_drain | ( | snd_pcm_t * | pcm | ) |
Stop a PCM preserving pending frames.
pcm | PCM handle |
-ESTRPIPE | a suspend event occurred |
For stopping the PCM stream immediately, use ::snd_pcm_drop() instead.
int snd_pcm_drop | ( | snd_pcm_t * | pcm | ) |
Stop a PCM dropping pending frames.
pcm | PCM handle |
For processing all pending samples, use ::snd_pcm_drain() instead.
snd_pcm_sframes_t snd_pcm_forward | ( | snd_pcm_t * | pcm, | |
snd_pcm_uframes_t | frames | |||
) |
Move application frame position forward.
pcm | PCM handle | |
frames | wanted skip in frames |
0 | means no action |
int snd_pcm_get_params | ( | snd_pcm_t * | pcm, | |
snd_pcm_uframes_t * | buffer_size, | |||
snd_pcm_uframes_t * | period_size | |||
) |
Get the transfer size parameters in a simple way.
pcm | PCM handle | |
buffer_size | PCM ring buffer size in frames | |
period_size | PCM period size in frames |
int snd_pcm_hw_free | ( | snd_pcm_t * | pcm | ) |
Remove PCM hardware configuration and free associated resources.
pcm | PCM handle |
int snd_pcm_hw_params | ( | snd_pcm_t * | pcm, | |
snd_pcm_hw_params_t * | params | |||
) |
Install one PCM hardware configuration chosen from a configuration space and snd_pcm_prepare it.
pcm | PCM handle | |
params | Configuration space definition container |
After this call, snd_pcm_prepare() is called automatically and the stream is brought to SND_PCM_STATE_PREPARED
state.
The hardware parameters cannot be changed when the stream is running (active). The software parameters can be changed at any time.
int snd_pcm_hw_params_current | ( | snd_pcm_t * | pcm, | |
snd_pcm_hw_params_t * | params | |||
) |
Retreive current PCM hardware configuration chosen with snd_pcm_hw_params.
pcm | PCM handle | |
params | Configuration space definition container |
int snd_pcm_hwsync | ( | snd_pcm_t * | pcm | ) |
Synchronize stream position with hardware.
pcm | PCM handle |
int snd_pcm_info | ( | snd_pcm_t * | pcm, | |
snd_pcm_info_t * | info | |||
) |
Obtain general (static) information for PCM handle.
pcm | PCM handle | |
info | Information container |
Link two PCMs.
pcm1 | first PCM handle | |
pcm2 | first PCM handle |
const char* snd_pcm_name | ( | snd_pcm_t * | pcm | ) |
get identifier of PCM handle
pcm | PCM handle |
int snd_pcm_nonblock | ( | snd_pcm_t * | pcm, | |
int | nonblock | |||
) |
set nonblock mode
pcm | PCM handle | |
nonblock | 0 = block, 1 = nonblock mode |
int snd_pcm_open | ( | snd_pcm_t ** | pcmp, | |
const char * | name, | |||
snd_pcm_stream_t | stream, | |||
int | mode | |||
) |
Opens a PCM.
pcmp | Returned PCM handle | |
name | ASCII identifier of the PCM handle | |
stream | Wanted stream | |
mode | Open mode (see SND_PCM_NONBLOCK, SND_PCM_ASYNC) |
int snd_pcm_open_lconf | ( | snd_pcm_t ** | pcmp, | |
const char * | name, | |||
snd_pcm_stream_t | stream, | |||
int | mode, | |||
snd_config_t * | lconf | |||
) |
Opens a PCM using local configuration.
pcmp | Returned PCM handle | |
name | ASCII identifier of the PCM handle | |
stream | Wanted stream | |
mode | Open mode (see SND_PCM_NONBLOCK, SND_PCM_ASYNC) | |
lconf | Local configuration |
int snd_pcm_pause | ( | snd_pcm_t * | pcm, | |
int | enable | |||
) |
Pause/resume PCM.
pcm | PCM handle | |
enable | 0 = resume, 1 = pause |
int snd_pcm_poll_descriptors | ( | snd_pcm_t * | pcm, | |
struct pollfd * | pfds, | |||
unsigned int | space | |||
) |
get poll descriptors
pcm | PCM handle | |
pfds | array of poll descriptors | |
space | space in the poll descriptor array |
The result is intended for direct use with the poll() syscall.
For reading the returned events of poll descriptor after poll() system call, use ::snd_pcm_poll_descriptors_revents() function. The field values in pollfd structs may be bogus regarding the stream direction from the application perspective (POLLIN might not imply read direction and POLLOUT might not imply write), but the ::snd_pcm_poll_descriptors_revents() function does the right "demangling".
You can use output from this function as arguments for the select() syscall, too.
int snd_pcm_poll_descriptors_count | ( | snd_pcm_t * | pcm | ) |
get count of poll descriptors for PCM handle
pcm | PCM handle |
int snd_pcm_poll_descriptors_revents | ( | snd_pcm_t * | pcm, | |
struct pollfd * | pfds, | |||
unsigned int | nfds, | |||
unsigned short * | revents | |||
) |
get returned events from poll descriptors
pcm | PCM handle | |
pfds | array of poll descriptors | |
nfds | count of poll descriptors | |
revents | returned events |
Note: The null event also exists. Even if poll() or select() syscall returned that some events are waiting, this function might return empty set of events. In this case, application should do next event waiting using poll() or select().
int snd_pcm_prepare | ( | snd_pcm_t * | pcm | ) |
Prepare PCM for use.
pcm | PCM handle |
snd_pcm_sframes_t snd_pcm_readi | ( | snd_pcm_t * | pcm, | |
void * | buffer, | |||
snd_pcm_uframes_t | size | |||
) |
Read interleaved frames from a PCM.
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_readn | ( | snd_pcm_t * | pcm, | |
void ** | bufs, | |||
snd_pcm_uframes_t | size | |||
) |
Read non interleaved frames to a PCM.
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.
int snd_pcm_recover | ( | snd_pcm_t * | pcm, | |
int | err, | |||
int | silent | |||
) |
Recover the stream state from an error or suspend.
pcm | PCM handle | |
err | error number | |
silent | do not print error reason |
Note that this function returs the original error code when it is not handled inside this function (for example -EAGAIN is returned back).
int snd_pcm_reset | ( | snd_pcm_t * | pcm | ) |
Reset PCM position.
pcm | PCM handle |
int snd_pcm_resume | ( | snd_pcm_t * | pcm | ) |
Resume from suspend, no samples are lost.
pcm | PCM handle |
-EAGAIN | resume can't be proceed immediately (audio hardware is probably still suspended) | |
-ENOSYS | hardware doesn't support this feature |
snd_pcm_sframes_t snd_pcm_rewind | ( | snd_pcm_t * | pcm, | |
snd_pcm_uframes_t | frames | |||
) |
Move application frame position backward.
pcm | PCM handle | |
frames | wanted displacement in frames |
int snd_pcm_set_params | ( | snd_pcm_t * | pcm, | |
snd_pcm_format_t | format, | |||
snd_pcm_access_t | access, | |||
unsigned int | channels, | |||
unsigned int | rate, | |||
int | soft_resample, | |||
unsigned int | latency | |||
) |
Set the hardware and software parameters in a simple way.
pcm | PCM handle | |
format | required PCM format | |
access | required PCM access | |
channels | required PCM channels | |
rate | required sample rate in Hz | |
soft_resample | 0 = disallow alsa-lib resample stream, 1 = allow resampling | |
latency | required overall latency in us (0 = optimum latency for players) |
int snd_pcm_start | ( | snd_pcm_t * | pcm | ) |
Start a PCM.
pcm | PCM handle |
snd_pcm_state_t snd_pcm_state | ( | snd_pcm_t * | pcm | ) |
Return PCM state.
pcm | PCM handle |
int snd_pcm_status | ( | snd_pcm_t * | pcm, | |
snd_pcm_status_t * | status | |||
) |
Obtain status (runtime) information for PCM handle.
pcm | PCM handle | |
status | Status container |
snd_pcm_stream_t snd_pcm_stream | ( | snd_pcm_t * | pcm | ) |
get stream for a PCM handle
pcm | PCM handle |
int snd_pcm_sw_params | ( | snd_pcm_t * | pcm, | |
snd_pcm_sw_params_t * | params | |||
) |
Install PCM software configuration defined by params.
pcm | PCM handle | |
params | Configuration container |
int snd_pcm_sw_params_current | ( | snd_pcm_t * | pcm, | |
snd_pcm_sw_params_t * | params | |||
) |
Return current software configuration for a PCM.
pcm | PCM handle | |
params | Software configuration container |
snd_pcm_type_t snd_pcm_type | ( | snd_pcm_t * | pcm | ) |
get type of PCM handle
pcm | PCM handle |
int snd_pcm_unlink | ( | snd_pcm_t * | pcm | ) |
Remove a PCM from a linked group.
pcm | PCM handle |
int snd_pcm_wait | ( | snd_pcm_t * | pcm, | |
int | timeout | |||
) |
Wait for a PCM to become ready.
pcm | PCM handle | |
timeout | maximum time in milliseconds to wait, a negative value means infinity |
0 | timeout occurred | |
1 | PCM stream is ready for I/O |
snd_pcm_sframes_t snd_pcm_writei | ( | snd_pcm_t * | pcm, | |
const void * | buffer, | |||
snd_pcm_uframes_t | size | |||
) |
Write interleaved frames to a PCM.
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_writen | ( | snd_pcm_t * | pcm, | |
void ** | bufs, | |||
snd_pcm_uframes_t | size | |||
) |
Write non interleaved frames to a PCM.
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.