From: James Courtier-Dutton Date: Sat, 10 Sep 2005 13:56:57 +0000 (+0000) Subject: Implement dB gain level display. X-Git-Tag: v1.0.10rc2~6 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=bd7a1e98479330b74ca7ed8d919c45fc9374e83b;p=alsa-utils.git Implement dB gain level display. DONE: If alsa-lib and alsa-driver support it, alsamixer now displays dB gain levels for all mixer controls. TODO: Implement alsa-lib and alsa-driver parts. --- diff --git a/alsamixer/alsamixer.c b/alsamixer/alsamixer.c index 210040d..3f34fdd 100644 --- a/alsamixer/alsamixer.c +++ b/alsamixer/alsamixer.c @@ -985,6 +985,48 @@ mixer_update_cbar (int elem_index) extra_info = tmp; } } + if (type != MIXER_ELEM_CAPTURE && snd_mixer_selem_has_playback_volume(elem)) { + long vdbleft, vdbright; + unsigned int length; + if (!snd_mixer_selem_get_playback_dB(elem, chn_left, &vdbleft)) { + if ((chn_right != SND_MIXER_SCHN_UNKNOWN) && + (!snd_mixer_selem_get_playback_dB(elem, chn_right, &vdbright))) { + float dbvol1, dbvol2; + dbvol1=(float)vdbleft/100; + dbvol2=(float)vdbright/100; + snprintf(tmp, 48, " [dB gain=%3.2f, %3.2f]",dbvol1, dbvol2); + } else { + float dbvol1; + dbvol1=(float)vdbleft/100; + snprintf(tmp, 48, " [dB gain=%3.2f]",dbvol1); + } + tmp[sizeof(tmp)-2] = 0; + length=strlen(tmp); + tmp[length+1]=0; + extra_info = tmp; + } + } + if (type == MIXER_ELEM_CAPTURE && snd_mixer_selem_has_capture_volume(elem)) { + long vdbleft, vdbright; + unsigned int length; + if (!snd_mixer_selem_get_capture_dB(elem, chn_left, &vdbleft)) { + if ((chn_right != SND_MIXER_SCHN_UNKNOWN) && + (!snd_mixer_selem_get_capture_dB(elem, chn_right, &vdbright))) { + float dbvol1, dbvol2; + dbvol1=(float)vdbleft/100; + dbvol2=(float)vdbright/100; + snprintf(tmp, 48, " [dB gain=%3.2f, %3.2f]",dbvol1, dbvol2); + } else { + float dbvol1; + dbvol1=(float)vdbleft/100; + snprintf(tmp, 48, " [dB gain=%3.2f]",dbvol1); + } + tmp[sizeof(tmp)-2] = 0; + length=strlen(tmp); + tmp[length+1]=0; + extra_info = tmp; + } + } display_item_info(elem_index, sid, extra_info); }