mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 00:35:42 +01:00
amixer - show dB values for simple mixer interface (which is default)
This commit is contained in:
parent
dedc292efa
commit
e45ba7e644
3 changed files with 39 additions and 8 deletions
6
alsamixer/go
Normal file → Executable file
6
alsamixer/go
Normal file → Executable file
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#DBG="gdb --args"
|
#DBG="gdb --args"
|
||||||
|
|
||||||
ALSA_MIXER_SIMPLE_MODULES="$HOME/alsa/alsa-lib/src/mixer/simple/.libs" \
|
ALSA_MIXER_SIMPLE_MODULES="$HOME/hg/alsa-lib/src/mixer/simple/.libs" \
|
||||||
ALSA_MIXER_SIMPLE="$HOME/alsa/alsa-lib/src/conf/smixer.conf" \
|
ALSA_MIXER_SIMPLE="$HOME/hg/alsa-lib/src/conf/smixer.conf" \
|
||||||
LD_PRELOAD="$HOME/alsa/alsa-lib/src/.libs/libasound.so" \
|
LD_PRELOAD="$HOME/hg/alsa-lib/src/.libs/libasound.so" \
|
||||||
exec $DBG ./alsamixer "$@"
|
exec $DBG ./alsamixer "$@"
|
||||||
|
|
|
@ -387,9 +387,9 @@ static void print_spaces(unsigned int spaces)
|
||||||
putc(' ', stdout);
|
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)
|
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;
|
long pvol, cvol;
|
||||||
int psw, csw;
|
int psw, csw;
|
||||||
int pmono, cmono, mono_ok = 0;
|
int pmono, cmono, mono_ok = 0;
|
||||||
|
long db;
|
||||||
snd_mixer_elem_t *elem;
|
snd_mixer_elem_t *elem;
|
||||||
|
|
||||||
elem = snd_mixer_find_selem(handle, id);
|
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)) {
|
if (snd_mixer_selem_has_common_volume(elem)) {
|
||||||
snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, &pvol);
|
snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, &pvol);
|
||||||
printf(" %s", get_percent(pvol, pmin, pmax));
|
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)) {
|
if (snd_mixer_selem_has_common_switch(elem)) {
|
||||||
snd_mixer_selem_get_playback_switch(elem, SND_MIXER_SCHN_MONO, &psw);
|
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;
|
title = 1;
|
||||||
snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, &pvol);
|
snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, &pvol);
|
||||||
printf(" %s", get_percent(pvol, pmin, pmax));
|
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)) {
|
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;
|
title = 1;
|
||||||
snd_mixer_selem_get_capture_volume(elem, SND_MIXER_SCHN_MONO, &cvol);
|
snd_mixer_selem_get_capture_volume(elem, SND_MIXER_SCHN_MONO, &cvol);
|
||||||
printf(" %s", get_percent(cvol, cmin, cmax));
|
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)) {
|
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)) {
|
if (!pmono && !cmono && snd_mixer_selem_has_common_volume(elem)) {
|
||||||
snd_mixer_selem_get_playback_volume(elem, chn, &pvol);
|
snd_mixer_selem_get_playback_volume(elem, chn, &pvol);
|
||||||
printf(" %s", get_percent(pvol, pmin, pmax));
|
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)) {
|
if (!pmono && !cmono && snd_mixer_selem_has_common_switch(elem)) {
|
||||||
snd_mixer_selem_get_playback_switch(elem, chn, &psw);
|
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;
|
title = 1;
|
||||||
snd_mixer_selem_get_playback_volume(elem, chn, &pvol);
|
snd_mixer_selem_get_playback_volume(elem, chn, &pvol);
|
||||||
printf(" %s", get_percent(pvol, pmin, pmax));
|
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)) {
|
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;
|
title = 1;
|
||||||
snd_mixer_selem_get_capture_volume(elem, chn, &cvol);
|
snd_mixer_selem_get_capture_volume(elem, chn, &cvol);
|
||||||
printf(" %s", get_percent(cvol, cmin, cmax));
|
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)) {
|
if (!snd_mixer_selem_has_common_switch(elem)) {
|
||||||
|
|
6
amixer/go
Normal file → Executable file
6
amixer/go
Normal file → Executable file
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ALSA_MIXER_SIMPLE_MODULES="$HOME/alsa/alsa-lib/src/mixer/simple/.libs" \
|
ALSA_MIXER_SIMPLE_MODULES="$HOME/hg/alsa-lib/src/mixer/simple/.libs" \
|
||||||
ALSA_MIXER_SIMPLE="$HOME/alsa/alsa-lib/src/conf/smixer.conf" \
|
ALSA_MIXER_SIMPLE="$HOME/hg/alsa-lib/src/conf/smixer.conf" \
|
||||||
LD_PRELOAD="$HOME/alsa/alsa-lib/src/.libs/libasound.so" \
|
LD_PRELOAD="$HOME/hg/alsa-lib/src/.libs/libasound.so" \
|
||||||
exec ./amixer "$@"
|
exec ./amixer "$@"
|
||||||
|
|
Loading…
Reference in a new issue