The best mixer group with respect to your PCM subchannel

In a typical mixer, there are many playback mixer group controls, and possibly several that will control the volume and mute of the stream your application is playing.

For example, consider the Sound Blaster Live playing a wave file. Three playback mixer controls adjust the volume of the playback: Master, PCM, and PCM Subchannel. Although each of these groups can control the volume of our playback, some aren't specific to just our stream, and thus have more side effects.

As an example, consider what happens if you increase your wave file volume by using the Master group. If you do this, any other streams—such a CD playback—are affected as well. So clearly, the best group to use is the PCM subchannel, as it affects only your stream. However, on some cards, a subchannel group might not exist, so you need a better method to find the best group.

The best way to figure out which is the best group for a PCM subchannel is to let the driver (i.e., the driver author) do it. You can obtain the identity of the best mixer group for a PCM subchannel by calling snd_pcm_channel_setup() or snd_pcm_plugin_setup(), as shown below:

memset (&setup, 0, sizeof (setup));
memset (&group, 0, sizeof (group));
setup.channel = SND_PCM_CHANNEL_PLAYBACK;
setup.mixer_gid = &group.gid;
if ((rtn = snd_pcm_plugin_setup (pcm_handle, &setup)) < 0)
{
    return -1;
}
Note: You must initialize the setup structure to zero and then set the mixer_gid pointer to a storage location for the group identifier.

One thing to note is that the best group may change, depending on the state of the PCM subchannel. Remember that the PCM subchannels aren't allocated to a client until the parameters of the channel are established. Similarly, the subchannel mixer group isn't available until the subchannel is allocated. Using the example of the Sound Blaster Live, the best mixer group before the subchannel is allocated is the PCM group and, after allocation, the PCM Subchannel group.