[Previous] [Contents] [Next]

snd_pcm_channel_params()

Set PCM communication parameters

Synopsis:

#include <sys/asoundlib.h>

int snd_pcm_channel_params( 
                    snd_pcm_t * handle, 
                    snd_pcm_channel_params_t * params );

Library:

libasound.so

Description:

The snd_pcm_channel_params() function sets up the transfer parameters according to the params structure. All members are write-only.

The function may be called in SND_PCM_STATUS_NOTREADY (initial) and SND_PCM_STATUS_READY states; otherwise, -EBADFD is returned. If the parameters are valid (zero is returned), then the driver state is changed to SND_PCM_STATUS_READY.

typedef struct snd_pcm_format {
    int interleave: 1;   /* data are interleaved */
    int format;          /* SND_PCM_SFMT_XXXX */
    int rate;            /* rate in Hz */
    int voices;          /* voices */
    int special;         /* special (custom) description of format */
    char reserved[124];  /* must be filled with zero */
} snd_pcm_format_t;

where:

interleave
If set, stream contains interleaved samples.
format
Format number (SND_PCM_SFMT_* constants).
rate
Requested rate in Hz.
voices
Number of voices (1-N).
special
Special (custom) description of format. Use when SND_PCM_SFMT_SPECIAL is specified.
typedef struct snd_pcm_channel_params
{
    int32_t             channel;
    int32_t             mode;
    snd_pcm_sync_t      sync;               /* hardware synchronization ID */
    snd_pcm_format_t    format;
    snd_pcm_digital_t   digital;
    int32_t             start_mode;
    int32_t             stop_mode;
    int32_t             time:1, ust_time:1;
    uint32_t            why_failed;         /* SND_PCM_PARAMS_BAD_??? */
    union
    {
        struct
        {
            int32_t     queue_size;
            int32_t     fill;
            int32_t     max_fill;
            uint8_t     reserved[124];      /* must be filled with zero */
        }       stream;
        struct
        {
            int32_t     frag_size;
            int32_t     frags_min;
            int32_t     frags_max;
            uint8_t     reserved[124];      /* must be filled with zero */
        }       block;
        uint8_t     reserved[128];      /* must be filled with zero */
    }       buf;
    uint8_t     reserved[128];      /* must be filled with zero */
}       snd_pcm_channel_params_t;

where:

channel
Specified channel direction. One of SND_PCM_CHANNEL_PLAYBACK or SND_PCM_CHANNEL_CAPTURE.
mode
Specifies channel mode. One of SND_PCM_MODE_STREAM or SND_PCM_MODE_BLOCK.
format
Specifies data format.
digital
Specifies digital setup.
start_mode
Specifies start mode (SND_PCM_START_* constants.
stop_mode
Specifies stop mode (SND_PCM_STOP_* constants).
time
If set, the driver offers the time in the status structure, when the transfer begun. The time is in gettimeofday format.
ust_time
If set, the driver offers the time in the status structure, when the transfer begun. The time is in UST format.
sync
Specifies the synchronization group.
queue_size
Specifies queue size in bytes for the stream mode. The queue size may specify the final transfer latency.
fill
Specifies the fill mode (SND_PCM_FILL_* constants).
max_fill
Specifies the count of bytes to be filled ahead with silence.
frag_size
Specifies the size of fragment in bytes.
frags_min
Capture: Specifies the minimum filled fragments to allow wakeup (usually one). Playback: Specifies the minimum free fragments to allow wakeup (usually one).
frags_max
Playback: Specifies the maximum filled fragments to allow wakeup. Value also specifies the maximum used fragments plus one.
Value (start condition) Description
SND_PCM_START_DATA Start when some data are written (playback) or requested (capture).
SND_PCM_START_FULL Start when whole queue is filled (playback).
SND_PCM_START_GO Start on the go command.
Value (stop condition) Description
SND_PCM_STOP_STOP Stop when underrun/overrun occurs.
SND_PCM_STOP_ERASE Stop and erase whole buffer when overrun (capture only).
SND_PCM_STOP_ROLLOVER Rollover when overrun/underrun occurs.
Value (file mode) Description
SND_PCM_FILL_NONE Don't fill the buffer with silence samples.
SND_PCM_FILL_SILENCE_WHOLE Fill the whole buffer with silence.
SND_PCM_FILL_SILENCE Fill the partial buffer with silence.

Returns:

Zero on success, or a negative value on error.

Errors:

-EINVAL
Invalid handle or params

Examples:

See the example in Configuring the Audio channel in the Playing Audio Data chapter This call is used identically to snd_pcm_plugin_params().

Classification:

ALSA

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

snd_pcm_plugin_params()


[Previous] [Contents] [Next]