]> git.alsa-project.org Git - alsa-utils.git/commitdiff
amixer - show dB values for simple mixer interface (which is default)
authorJaroslav Kysela <perex@perex.cz>
Thu, 27 Jul 2006 09:02:00 +0000 (11:02 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 27 Jul 2006 09:02:00 +0000 (11:02 +0200)
alsamixer/go [changed mode: 0644->0755]
amixer/amixer.c
amixer/go [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index f432345..2a4059a
@@ -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 "$@"
index 4ba6df3a1da6b52da2d389e4c8123fd53e6e4573..921a5e0ca199d1ac8635a972c7b7d7070d04b306 100644 (file)
@@ -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)) {
old mode 100644 (file)
new mode 100755 (executable)
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 "$@"