snd_pcm_get_chmap()

Updated: April 19, 2023

Get the current channel mapping, accounting for voice conversion on the capture path

Synopsis:

#include <sys/asoundlib.h>

snd_pcm_chmap_t * snd_pcm_get_chmap( snd_pcm_t *pcm );

Arguments:

pcm
The handle for the PCM device, which you must have opened by calling snd_pcm_open_name(), snd_pcm_open(), or snd_pcm_open_preferred().

Library:

libasound.so

Use the -l asound option with qcc to link against this library.

Description:

The snd_pcm_get_chmap() function gets the current channel mapping for a PCM stream, accounting for voice conversion on the capture path.

Returns:

A pointer to a snd_pcm_chmap_t structure that describes the mapping, or NULL if there isn't a mapping or an error occurred (errno is set). You must free this structure when you're done with it.

Errors:

EINVAL
The value of pcm is NULL.
ENOMEM
Not enough memory was available.

Examples:

snd_pcm_chmap_t *chmap;
int i;

printf("Get channel map using snd_pcm_get_chmap()...\n");
if ((chmap = snd_pcm_get_chmap(pcm_handle)) == NULL )
{
    fprintf(stderr, "snd_pcm_get_chmap failed: %s\n", snd_strerror(errno));
    return -1;
}

printf("Number of channels = %d\n", chmap->channels);
for(i = 0; i < chmap->channels; i++)
    printf("\tchmap.pos[%d] = %d\n", i, chmap->pos[i]);

free (chmap);

Classification:

QNX Neutrino

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Read the Caveats

Caveats:

This function isn't thread-safe if pcm (snd_pcm_t) is used across multiple threads.