From e45ba7e6440b631f91ea0e9f2b794869b5015d94 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 27 Jul 2006 11:02:00 +0200 Subject: [PATCH] amixer - show dB values for simple mixer interface (which is default) --- alsamixer/go | 6 +++--- amixer/amixer.c | 35 +++++++++++++++++++++++++++++++++-- amixer/go | 6 +++--- 3 files changed, 39 insertions(+), 8 deletions(-) mode change 100644 => 100755 alsamixer/go mode change 100644 => 100755 amixer/go diff --git a/alsamixer/go b/alsamixer/go old mode 100644 new mode 100755 index f432345..2a4059a --- a/alsamixer/go +++ b/alsamixer/go @@ -2,7 +2,7 @@ #DBG="gdb --args" -ALSA_MIXER_SIMPLE_MODULES="$HOME/alsa/alsa-lib/src/mixer/simple/.libs" \ -ALSA_MIXER_SIMPLE="$HOME/alsa/alsa-lib/src/conf/smixer.conf" \ -LD_PRELOAD="$HOME/alsa/alsa-lib/src/.libs/libasound.so" \ +ALSA_MIXER_SIMPLE_MODULES="$HOME/hg/alsa-lib/src/mixer/simple/.libs" \ +ALSA_MIXER_SIMPLE="$HOME/hg/alsa-lib/src/conf/smixer.conf" \ +LD_PRELOAD="$HOME/hg/alsa-lib/src/.libs/libasound.so" \ exec $DBG ./alsamixer "$@" diff --git a/amixer/amixer.c b/amixer/amixer.c index 4ba6df3..921a5e0 100644 --- a/amixer/amixer.c +++ b/amixer/amixer.c @@ -387,9 +387,9 @@ static void print_spaces(unsigned int spaces) putc(' ', stdout); } -static void print_dB(int dB) +static void print_dB(long dB) { - printf("%i.%02idB", dB / 100, (dB < 0 ? -dB : dB) % 100); + printf("%li.%02lidB", dB / 100, (dB < 0 ? -dB : dB) % 100); } static void decode_tlv(unsigned int spaces, unsigned int *tlv, unsigned int tlv_size) @@ -594,6 +594,7 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char long pvol, cvol; int psw, csw; int pmono, cmono, mono_ok = 0; + long db; snd_mixer_elem_t *elem; elem = snd_mixer_find_selem(handle, id); @@ -740,6 +741,11 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char if (snd_mixer_selem_has_common_volume(elem)) { snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, &pvol); printf(" %s", get_percent(pvol, pmin, pmax)); + if (!snd_mixer_selem_get_playback_dB(elem, SND_MIXER_SCHN_MONO, &db)) { + printf(" ["); + print_dB(db); + printf("]"); + } } if (snd_mixer_selem_has_common_switch(elem)) { snd_mixer_selem_get_playback_switch(elem, SND_MIXER_SCHN_MONO, &psw); @@ -758,6 +764,11 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char title = 1; snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, &pvol); printf(" %s", get_percent(pvol, pmin, pmax)); + if (!snd_mixer_selem_get_playback_dB(elem, SND_MIXER_SCHN_MONO, &db)) { + printf(" ["); + print_dB(db); + printf("]"); + } } } if (!snd_mixer_selem_has_common_switch(elem)) { @@ -781,6 +792,11 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char title = 1; snd_mixer_selem_get_capture_volume(elem, SND_MIXER_SCHN_MONO, &cvol); printf(" %s", get_percent(cvol, cmin, cmax)); + if (!snd_mixer_selem_get_capture_dB(elem, SND_MIXER_SCHN_MONO, &db)) { + printf(" ["); + print_dB(db); + printf("]"); + } } } if (!snd_mixer_selem_has_common_switch(elem)) { @@ -803,6 +819,11 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char if (!pmono && !cmono && snd_mixer_selem_has_common_volume(elem)) { snd_mixer_selem_get_playback_volume(elem, chn, &pvol); printf(" %s", get_percent(pvol, pmin, pmax)); + if (!snd_mixer_selem_get_playback_dB(elem, chn, &db)) { + printf(" ["); + print_dB(db); + printf("]"); + } } if (!pmono && !cmono && snd_mixer_selem_has_common_switch(elem)) { snd_mixer_selem_get_playback_switch(elem, chn, &psw); @@ -816,6 +837,11 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char title = 1; snd_mixer_selem_get_playback_volume(elem, chn, &pvol); printf(" %s", get_percent(pvol, pmin, pmax)); + if (!snd_mixer_selem_get_playback_dB(elem, chn, &db)) { + printf(" ["); + print_dB(db); + printf("]"); + } } } if (!snd_mixer_selem_has_common_switch(elem)) { @@ -835,6 +861,11 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char title = 1; snd_mixer_selem_get_capture_volume(elem, chn, &cvol); printf(" %s", get_percent(cvol, cmin, cmax)); + if (!snd_mixer_selem_get_capture_dB(elem, chn, &db)) { + printf(" ["); + print_dB(db); + printf("]"); + } } } if (!snd_mixer_selem_has_common_switch(elem)) { diff --git a/amixer/go b/amixer/go old mode 100644 new mode 100755 index 346982c..109c7a9 --- a/amixer/go +++ b/amixer/go @@ -1,6 +1,6 @@ #!/bin/bash -ALSA_MIXER_SIMPLE_MODULES="$HOME/alsa/alsa-lib/src/mixer/simple/.libs" \ -ALSA_MIXER_SIMPLE="$HOME/alsa/alsa-lib/src/conf/smixer.conf" \ -LD_PRELOAD="$HOME/alsa/alsa-lib/src/.libs/libasound.so" \ +ALSA_MIXER_SIMPLE_MODULES="$HOME/hg/alsa-lib/src/mixer/simple/.libs" \ +ALSA_MIXER_SIMPLE="$HOME/hg/alsa-lib/src/conf/smixer.conf" \ +LD_PRELOAD="$HOME/hg/alsa-lib/src/.libs/libasound.so" \ exec ./amixer "$@"