Information about a mixer's switch
#include <sys/asound_common.h> typedef struct snd_switch { int32_t iface; int32_t device; int32_t channel; char name[36]; uint32_t type; uint32_t subtype; uint32_t zero[2]; union { uint32_t enable:1; struct { uint8_t data; uint8_t low; uint8_t high; } byte; struct { uint16_t data; uint16_t low; uint16_t high; } word; struct { uint32_t data; uint32_t low; uint32_t high; } dword; struct { uint32_t data; uint32_t items[30]; uint32_t items_cnt; } list; struct { struct { uint16_t input[15]; uint16_t output[15]; uint16_t cnt; /* Read-only (configured by driver); defines the number of concurrent routes supported through the switch */ } active; /* The below items are read-only (configured by driver) to communicate the inputs and outputs connected to the switch */ uint16_t inputs[15]; uint16_t inputs_cnt; uint16_t outputs[15]; uint16_t outputs_cnt; } routing_list; struct { uint16_t selected_items[30]; uint16_t selected_items_cnt; uint16_t items[30]; uint16_t items_cnt; } multi_selection_list; struct { uint8_t selection; char strings[11][11]; uint8_t strings_cnt; } string_11; uint8_t raw[32]; uint8_t reserved[128]; /* must be filled with zeroes */ } value; uint8_t reserved[128]; /* must be filled with zeroes */ } snd_switch_t;
The snd_switch_t structure describes the switches for a mixer. You can fill this structure by calling snd_ctl_mixer_switch_read().
The members include:
Type | Union member | Description |
---|---|---|
SND_SW_TYPE_BOOLEAN | enable | A simple on and off switch |
SND_SW_TYPE_BYTE | byte | An 8-bit value constrained between a minimum and maximum setting |
SND_SW_TYPE_DWORD | dword | A 32-bit value constrained between a minimum and maximum setting |
SND_SW_TYPE_LIST | list | A 32-bit value selected from a list of values. The items_cnt argument is the number of valid items in the array. |
SND_SW_TYPE_MULTI_SEL_LIST | multi_selection_list | A multiselection list switch; see below. |
SND_SW_TYPE_ROUTING_LIST | routing_list | A routing list switch; see below. |
SND_SW_TYPE_STRING_11 | string_11 | An array of string selections with a maximum length of 11 bytes. The strings_cnt argument is the number of valid strings in the array. The selection argument is the index of the selected string. |
SND_SW_TYPE_WORD | word | A 16-bit value constrained between a minimum and maximum setting |
SND_SW_TYPE_ROUTING_LIST and SND_SW_TYPE_MULTI_SEL_LIST are similar:
This allows the client application to know what it can and can't do with any specific instance of the switch. It also makes it easy to query which inputs and outputs are currently selected/active. Since each instance of this switch type is coded with a specific set of inputs and output identifiers, it also makes it easy for the driver code to validate the client app's switch configuration request and to apply the client's switch configuration.
The active.cnt is read-only and is set by the driver code. It describes the number of concurrent routes supported by the particular instance of the switch. The client and driver should use an index only up to active.cnt – 1 when reading or writing to the active structure of the routing_list switch.
This also makes it easy for the driver to do error checking on the client's configuration requests. This switch type allows the client to select multiple inputs (there's an array of available inputs/items and an array of selected inputs/items) to be routed to a single output (i.e., hardware mixing).
QNX Neutrino