ALSA project - the C library reference: Software Parameters

ALSA project - the C library reference

Loading...
Searching...
No Matches
Macros | Functions
Software Parameters
PCM Interface

## Macros
#define | snd_pcm_sw_params_alloca(ptr)
| allocate an invalid snd_pcm_sw_params_t using standard alloca More...

## Functions
size_t | snd_pcm_sw_params_sizeof (void)
| get size of snd_pcm_sw_params_t More...
int | snd_pcm_sw_params_malloc (snd_pcm_sw_params_t **ptr)
| allocate an invalid snd_pcm_sw_params_t using standard malloc More...
void | snd_pcm_sw_params_free (snd_pcm_sw_params_t *obj)
| frees a previously allocated snd_pcm_sw_params_t More...
void | snd_pcm_sw_params_copy (snd_pcm_sw_params_t *dst, const snd_pcm_sw_params_t *src)
| copy one snd_pcm_sw_params_t to another More...
int | snd_pcm_sw_params_get_boundary (const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val)
| Get boundary for ring pointers from a software configuration container. More...
int | snd_pcm_sw_params_set_tstamp_mode (snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_tstamp_t val)
| Set timestamp mode inside a software configuration container. More...
int | snd_pcm_sw_params_get_tstamp_mode (const snd_pcm_sw_params_t *params, snd_pcm_tstamp_t *val)
| Get timestamp mode from a software configuration container. More...
int | snd_pcm_sw_params_set_tstamp_type (snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_tstamp_type_t val)
| Set timestamp type inside a software configuration container. More...
int | snd_pcm_sw_params_get_tstamp_type (const snd_pcm_sw_params_t *params, snd_pcm_tstamp_type_t *val)
| Get timestamp type from a software configuration container. More...
int | snd_pcm_sw_params_set_avail_min (snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
| Set avail min inside a software configuration container. More...
int | snd_pcm_sw_params_get_avail_min (const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val)
| Get avail min from a software configuration container. More...
int | snd_pcm_sw_params_set_period_event (snd_pcm_t *pcm, snd_pcm_sw_params_t *params, int val)
| Set period event inside a software configuration container. More...
int | snd_pcm_sw_params_get_period_event (const snd_pcm_sw_params_t *params, int *val)
| Get period event from a software configuration container. More...
int | snd_pcm_sw_params_set_start_threshold (snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
| Set start threshold inside a software configuration container. More...
int | snd_pcm_sw_params_get_start_threshold (const snd_pcm_sw_params_t *paramsm, snd_pcm_uframes_t *val)
| Get start threshold from a software configuration container. More...
int | snd_pcm_sw_params_set_stop_threshold (snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
| Set stop threshold inside a software configuration container. More...
int | snd_pcm_sw_params_get_stop_threshold (const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val)
| Get stop threshold from a software configuration container. More...
int | snd_pcm_sw_params_set_silence_threshold (snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
| Set silence threshold inside a software configuration container. More...
int | snd_pcm_sw_params_get_silence_threshold (const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val)
| Get silence threshold from a software configuration container. More...
int | snd_pcm_sw_params_set_silence_size (snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
| Set silence size inside a software configuration container. More...
int | snd_pcm_sw_params_get_silence_size (const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val)
| Get silence size from a software configuration container. More...

## Detailed Description

See the PCM (digital audio) interface page for more details.

## Macro Definition Documentation

## ◆ snd_pcm_sw_params_alloca

#define snd_pcm_sw_params_alloca | ( |  | ptr | ) |

allocate an invalid snd_pcm_sw_params_t using standard alloca

Parameters

  ptr | returned pointer

Examples
  /test/latency.c, and /test/pcm.c.

## Function Documentation

## ◆ snd_pcm_sw_params_copy()

void snd_pcm_sw_params_copy | ( | snd_pcm_sw_params_t * | dst,
|  | const snd_pcm_sw_params_t * | src
| ) |  |

copy one snd_pcm_sw_params_t to another

Parameters

  dst | pointer to destination
  src | pointer to source

## ◆ snd_pcm_sw_params_free()

void snd_pcm_sw_params_free | ( | snd_pcm_sw_params_t * | obj | ) |

frees a previously allocated snd_pcm_sw_params_t

Parameters

  obj | pointer to object to free

## ◆ snd_pcm_sw_params_get_avail_min()

int snd_pcm_sw_params_get_avail_min | ( | const snd_pcm_sw_params_t * | params,
|  | snd_pcm_uframes_t * | val
| ) |  |

Get avail min from a software configuration container.

Parameters

  params | Software configuration container
  val | returned minimum available frames to consider PCM ready

Returns
  0 otherwise a negative error code

This is a threshold value when the PCM stream is considered as ready for another read/write operation or poll event.

## ◆ snd_pcm_sw_params_get_boundary()

int snd_pcm_sw_params_get_boundary | ( | const snd_pcm_sw_params_t * | params,
|  | snd_pcm_uframes_t * | val
| ) |  |

Get boundary for ring pointers from a software configuration container.

Parameters

  params | Software configuration container
  val | Returned boundary in frames

Returns
  0 otherwise a negative error code

## ◆ snd_pcm_sw_params_get_period_event()

int snd_pcm_sw_params_get_period_event | ( | const snd_pcm_sw_params_t * | params,
|  | int * | val
| ) |  |

Get period event from a software configuration container.

Parameters

  params | Software configuration container
  val | returned period event state

Returns
  0 otherwise a negative error code

## ◆ snd_pcm_sw_params_get_silence_size()

int snd_pcm_sw_params_get_silence_size | ( | const snd_pcm_sw_params_t * | params,
|  | snd_pcm_uframes_t * | val
| ) |  |

Get silence size from a software configuration container.

Parameters

  params | Software configuration container
  val | Returned silence size in frames (0 for disabled)

Returns
  0 otherwise a negative error code

A portion of playback buffer is overwritten with silence when playback underrun is nearer than silence threshold (see snd_pcm_sw_params_set_silence_threshold)

## ◆ snd_pcm_sw_params_get_silence_threshold()

int snd_pcm_sw_params_get_silence_threshold | ( | const snd_pcm_sw_params_t * | params,
|  | snd_pcm_uframes_t * | val
| ) |  |

Get silence threshold from a software configuration container.

Parameters

  params | Software configuration container
  val | Returned silence threshold in frames

Returns
  0 otherwise a negative error value

A portion of playback buffer is overwritten with silence (see snd_pcm_sw_params_set_silence_size) when playback underrun is nearer than silence threshold.

## ◆ snd_pcm_sw_params_get_start_threshold()

int snd_pcm_sw_params_get_start_threshold | ( | const snd_pcm_sw_params_t * | params,
|  | snd_pcm_uframes_t * | val
| ) |  |

Get start threshold from a software configuration container.

Parameters

  params | Software configuration container
  val | Returned start threshold in frames

Returns
  0 otherwise a negative error code

PCM is automatically started when playback frames available to PCM are >= threshold or when requested capture frames are >= threshold

## ◆ snd_pcm_sw_params_get_stop_threshold()

int snd_pcm_sw_params_get_stop_threshold | ( | const snd_pcm_sw_params_t * | params,
|  | snd_pcm_uframes_t * | val
| ) |  |

Get stop threshold from a software configuration container.

Parameters

  params | Software configuration container
  val | Returned stop threshold in frames

Returns
  0 otherwise a negative error code

PCM is automatically stopped in SND_PCM_STATE_XRUN state when available frames is >= threshold. If the stop threshold is equal to boundary (also software parameter - sw_param) then automatic stop will be disabled (thus device will do the endless loop in the ring buffer).

## ◆ snd_pcm_sw_params_get_tstamp_mode()

int snd_pcm_sw_params_get_tstamp_mode | ( | const snd_pcm_sw_params_t * | params,
|  | snd_pcm_tstamp_t * | val
| ) |  |

Get timestamp mode from a software configuration container.

Parameters

  params | Software configuration container
  val | Returned timestamp

Returns
  0 otherwise a negative error code

## ◆ snd_pcm_sw_params_get_tstamp_type()

int snd_pcm_sw_params_get_tstamp_type | ( | const snd_pcm_sw_params_t * | params,
|  | snd_pcm_tstamp_type_t * | val
| ) |  |

Get timestamp type from a software configuration container.

Parameters

  params | Software configuration container
  val | Returned timestamp type

Returns
  0 otherwise a negative error code

## ◆ snd_pcm_sw_params_malloc()

int snd_pcm_sw_params_malloc | ( | snd_pcm_sw_params_t ** | ptr | ) |

allocate an invalid snd_pcm_sw_params_t using standard malloc

Parameters

  ptr | returned pointer

Returns
  0 on success otherwise negative error code

## ◆ snd_pcm_sw_params_set_avail_min()

int snd_pcm_sw_params_set_avail_min | ( | snd_pcm_t * | pcm,
|  | snd_pcm_sw_params_t * | params,
|  | snd_pcm_uframes_t | val
| ) |  |

Set avail min inside a software configuration container.

Parameters

  pcm | PCM handle
  params | Software configuration container
  val | Minimum avail frames to consider PCM ready

Returns
  0 otherwise a negative error code

Note: This is similar to setting an OSS wakeup point. The valid values for 'val' are determined by the specific hardware. Most PC sound cards can only accept power of 2 frame counts (i.e. 512, 1024, 2048). You cannot use this as a high resolution timer - it is limited to how often the sound card hardware raises an interrupt.

Examples
  /test/latency.c, and /test/pcm.c.

## ◆ snd_pcm_sw_params_set_period_event()

int snd_pcm_sw_params_set_period_event | ( | snd_pcm_t * | pcm,
|  | snd_pcm_sw_params_t * | params,
|  | int | val
| ) |  |

Set period event inside a software configuration container.

Parameters

  pcm | PCM handle
  params | Software configuration container
  val | 0 = disable period event, 1 = enable period event

Returns
  0 otherwise a negative error code

An poll (select) wakeup event is raised if enabled.

Examples
  /test/pcm.c.

## ◆ snd_pcm_sw_params_set_silence_size()

int snd_pcm_sw_params_set_silence_size | ( | snd_pcm_t * | pcm,
|  | snd_pcm_sw_params_t * | params,
|  | snd_pcm_uframes_t | val
| ) |  |

Set silence size inside a software configuration container.

Parameters

  pcm | PCM handle
  params | Software configuration container
  val | Silence size in frames (0 for disabled)

Returns
  0 otherwise a negative error code

A portion of playback buffer is overwritten with silence when playback underrun is nearer than silence threshold (see snd_pcm_sw_params_set_silence_threshold)

The special case is when silence size value is equal or greater than boundary. The unused portion of the ring buffer (initial written samples are untouched) is filled with silence at start. Later, only just processed sample area is filled with silence. Note: silence_threshold must be set to zero.

## ◆ snd_pcm_sw_params_set_silence_threshold()

int snd_pcm_sw_params_set_silence_threshold | ( | snd_pcm_t * | pcm,
|  | snd_pcm_sw_params_t * | params,
|  | snd_pcm_uframes_t | val
| ) |  |

Set silence threshold inside a software configuration container.

Parameters

  pcm | PCM handle
  params | Software configuration container
  val | Silence threshold in frames

Returns
  0 otherwise a negative error code

A portion of playback buffer is overwritten with silence (see snd_pcm_sw_params_set_silence_size) when playback underrun is nearer than silence threshold.

## ◆ snd_pcm_sw_params_set_start_threshold()

int snd_pcm_sw_params_set_start_threshold | ( | snd_pcm_t * | pcm,
|  | snd_pcm_sw_params_t * | params,
|  | snd_pcm_uframes_t | val
| ) |  |

Set start threshold inside a software configuration container.

Parameters

  pcm | PCM handle
  params | Software configuration container
  val | Start threshold in frames

Returns
  0 otherwise a negative error code

PCM is automatically started when playback frames available to PCM are >= threshold or when requested capture frames are >= threshold

Examples
  /test/latency.c, and /test/pcm.c.

## ◆ snd_pcm_sw_params_set_stop_threshold()

int snd_pcm_sw_params_set_stop_threshold | ( | snd_pcm_t * | pcm,
|  | snd_pcm_sw_params_t * | params,
|  | snd_pcm_uframes_t | val
| ) |  |

Set stop threshold inside a software configuration container.

Parameters

  pcm | PCM handle
  params | Software configuration container
  val | Stop threshold in frames

Returns
  0 otherwise a negative error code

PCM is automatically stopped in SND_PCM_STATE_XRUN state when available frames is >= threshold. If the stop threshold is equal to boundary (also software parameter - sw_param) then automatic stop will be disabled (thus device will do the endless loop in the ring buffer).

## ◆ snd_pcm_sw_params_set_tstamp_mode()

int snd_pcm_sw_params_set_tstamp_mode | ( | snd_pcm_t * | pcm,
|  | snd_pcm_sw_params_t * | params,
|  | snd_pcm_tstamp_t | val
| ) |  |

Set timestamp mode inside a software configuration container.

Parameters

  pcm | PCM handle
  params | Software configuration container
  val | Timestamp mode

Returns
  0 otherwise a negative error code

## ◆ snd_pcm_sw_params_set_tstamp_type()

int snd_pcm_sw_params_set_tstamp_type | ( | snd_pcm_t * | pcm,
|  | snd_pcm_sw_params_t * | params,
|  | snd_pcm_tstamp_type_t | val
| ) |  |

Set timestamp type inside a software configuration container.

Parameters

  pcm | PCM handle
  params | Software configuration container
  val | Timestamp type

Returns
  0 otherwise a negative error code

## ◆ snd_pcm_sw_params_sizeof()

size_t snd_pcm_sw_params_sizeof | ( | void |  | ) |

get size of snd_pcm_sw_params_t

Returns
  size in bytes