diff options
author | Takashi Iwai <tiwai@suse.de> | 2006-08-25 12:39:34 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2006-08-25 12:39:34 +0200 |
commit | cb9cb724665cfe664f1de2d06f3e019c2b65ace9 (patch) | |
tree | 1c2aad5a176688635769c4adbc4fc1c3a7485318 /alsamixer | |
parent | ae9ddeb63443cc2c46e0f0b915466cca0f800372 (diff) |
Show the mute dB state correctly
Show the mute dB state correctly as 'mute' in the status line.
Diffstat (limited to 'alsamixer')
-rw-r--r-- | alsamixer/alsamixer.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/alsamixer/alsamixer.c b/alsamixer/alsamixer.c index e281923..cfa2e04 100644 --- a/alsamixer/alsamixer.c +++ b/alsamixer/alsamixer.c @@ -895,6 +895,18 @@ static void draw_capture_switch(int x, int y, int elem_index, int swl, int swr) mvaddch (y - 1, x + 6, swr ? 'R' : ' '); } +#ifndef SND_CTL_TLV_DB_GAIN_MUTE +#define SND_CTL_TLV_DB_GAIN_MUTE -9999999 +#endif + +static void dB_value(char *s, long val) +{ + if (val <= SND_CTL_TLV_DB_GAIN_MUTE) + strcpy(s, "mute"); + else + snprintf(s, 10, "%3.2f", (float)val / 100); +} + static void mixer_update_cbar (int elem_index) { @@ -989,16 +1001,14 @@ mixer_update_cbar (int elem_index) long vdbleft, vdbright; unsigned int length; if (!snd_mixer_selem_get_playback_dB(elem, chn_left, &vdbleft)) { + char tmpl[10], tmpr[10]; + dB_value(tmpl, 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); + dB_value(tmpr, vdbright); + snprintf(tmp, 48, " [dB gain=%s, %s]", tmpl, tmpr); } else { - float dbvol1; - dbvol1=(float)vdbleft/100; - snprintf(tmp, 48, " [dB gain=%3.2f]",dbvol1); + snprintf(tmp, 48, " [dB gain=%s]", tmpl); } tmp[sizeof(tmp)-2] = 0; length=strlen(tmp); @@ -1010,16 +1020,14 @@ mixer_update_cbar (int elem_index) long vdbleft, vdbright; unsigned int length; if (!snd_mixer_selem_get_capture_dB(elem, chn_left, &vdbleft)) { + char tmpl[10], tmpr[10]; + dB_value(tmpl, 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); + dB_value(tmpr, vdbright); + snprintf(tmp, 48, " [dB gain=%s, %s]", tmpl, tmpr); } else { - float dbvol1; - dbvol1=(float)vdbleft/100; - snprintf(tmp, 48, " [dB gain=%3.2f]",dbvol1); + snprintf(tmp, 48, " [dB gain=%s]", tmpl); } tmp[sizeof(tmp)-2] = 0; length=strlen(tmp); |