snd_mixer_element_info()

Updated: May 06, 2022

Get information about a mixer element

Synopsis:

#include <sys/asoundlib.h>

int snd_mixer_element_info(
       snd_mixer_t *mixer, 
       snd_mixer_element_info_t *info );

Arguments:

mixer
The handle for the mixer device. This must have been created by snd_mixer_open().
info
A pointer to a snd_mixer_element_info_t.

Library:

libasound.so

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

Description:

The snd_mixer_element_info() function gets information about a mixer element.

The caller must fill in the element ID member (eid) of the information structure to target the information request at a specific mixer element.

The data member of the information structure is a union of specific information structures for the various element types. It is dependent on the element type for which information is being requested. The caller must provide adequate buffering for the element information but its size can vary. If the required buffering varies, the mixer element information data structure includes a *_size variable, an *_over variable, and a buffer pointer. The *_size variable specifies the client-provided buffer size that the buffer pointer points to, and the *_over variable is used by the server to communicate back to the call if additional buffer space is required. If additional space is required, the buffer can be resized and the call can be made a second time to read the full element information.

The snd_mixer_element_info_build() function performs the same task as snd_mixer_element_info(), but it also allocates the extra buffering that a caller must provide to hold the full element information.

Returns:

EOK on success, a negative errno upon failure.

Errors:

-EINVAL
NULL mixer or info argument, or invalid element type.
-ENXIO
The element wasn't found.
-EIO
No element information available.

Examples:

The io element contains a variable-sized channel map based on the number of voices the element supports.

/* Size info request for 2 voices by default */
element->data.io.voices_size = 2;
bufsize = sizeof(snd_pcm_chmap_t) + (element->data.io.voices_size * sizeof (snd_pcm_chmap_position_t));
element->data.io.chmap = malloc (bufsize);
if (element->data.io.chmap == NULL)
    return ENOMEM;
if ((err = snd_mixer_element_info (handle, element)) < 0)
    return -err;
/* Check voices_over to determine if initial buffer was insufficient to hold all of the element information */
if (element->data.io.voices_over != 0) 
{
    element->data.io.voices_size += element->data.io.voices_over;
    /* Re-allocate the chmap based on the updated size */
    free(element->data.io.chmap);
    bufsize = sizeof(snd_pcm_chmap_t) + (element->data.io.voices_size * sizeof (snd_pcm_chmap_position_t));
    element->data.io.chmap = malloc (bufsize);
    if (element->data.io.chmap == NULL)
        return ENOMEM;
    if ((err = snd_mixer_element_info (handle, element)) < 0) 
        return -err;
 }

Classification:

QNX Neutrino

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