Set PCM communication parameters
#include <sys/asoundlib.h>
int snd_pcm_channel_params(
snd_pcm_t * handle,
snd_pcm_channel_params_t * params );
libasound.so
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:
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:
| 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. |
Zero on success, or a negative value on error.
See the example in Configuring the Audio channel in the Playing Audio Data chapter This call is used identically to snd_pcm_plugin_params().
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |