summaryrefslogtreecommitdiff
path: root/alsamixer
diff options
context:
space:
mode:
authorJames Courtier-Dutton <James@superbug.co.uk>2005-09-10 13:56:57 +0000
committerJames Courtier-Dutton <James@superbug.co.uk>2005-09-10 13:56:57 +0000
commitbd7a1e98479330b74ca7ed8d919c45fc9374e83b (patch)
treed979aacda634f2a9fcf06b52ba150abe76a06d9e /alsamixer
parent0c4dfcaa97ff8db5265569afc6a80fbde29d51e8 (diff)
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.
Diffstat (limited to 'alsamixer')
-rw-r--r--alsamixer/alsamixer.c42
1 files changed, 42 insertions, 0 deletions
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);
}