Controlling a mixer group
The best way to control a mixer group is to use the read-modify-write technique. Using this technique, you can examine the group capabilities and ranges before adjusting the group.
The first step in reading the properties and settings of a mixer group is to identify the group. Every mixer group has a name, but because two groups may have the same name, a name alone isn't enough to identify a specific mixer group. In order to make groups unique, mixer groups are identified by the combination of name and index. The index is an integer that represents the instance number of the name. In most cases, the index is 0; in the case of two mixer groups with the same name, the first has an index of 0, and the second has an index of 1.
To read a mixer group, call the snd_mixer_group_read() function. The arguments to this function are the mixer handle and the group control structure. The group control structure is of type snd_mixer_group_t ; for details about its members, see the Audio Library chapter.
To read a particular group, you must set its name and index in the gid substructure (see snd_mixer_gid_t ) before making the call. If the call to snd_mixer_group_read() succeeds, the function fills in the structure with the group's capabilities and current settings.
Now that you have the group capabilities and current settings, you can modify them before you write them back to the mixer group.
To write the changes to the mixer group, call snd_mixer_group_write() , passing as arguments the mixer handle and the group control structure.