forked from pool/alsa-utils
362 lines
10 KiB
Diff
362 lines
10 KiB
Diff
diff --git a/Makefile.am b/Makefile.am
|
|
index 554617d..5296977 100644
|
|
--- a/Makefile.am
|
|
+++ b/Makefile.am
|
|
@@ -1,16 +1,25 @@
|
|
INCLUDES=-I$(top_srcdir)/include
|
|
+
|
|
+SUBDIRS = include alsactl utils m4 po
|
|
if ALSAMIXER
|
|
-ALSAMIXER_DIR=alsamixer
|
|
-else
|
|
-ALSAMIXER_DIR=
|
|
+SUBDIRS += alsamixer
|
|
+endif
|
|
+if HAVE_MIXER
|
|
+SUBDIRS += amixer
|
|
+endif
|
|
+if HAVE_RAWMIDI
|
|
+SUBDIRS += amidi
|
|
endif
|
|
if ALSACONF
|
|
-ALSACONF_DIR=alsaconf
|
|
-else
|
|
-ALSACONF_DIR=
|
|
+SUBDIRS += alsaconf
|
|
endif
|
|
-SUBDIRS= include alsactl $(ALSACONF_DIR) $(ALSAMIXER_DIR) amidi amixer \
|
|
- aplay iecset seq speaker-test utils m4 po
|
|
+if HAVE_PCM
|
|
+SUBDIRS += aplay iecset speaker-test
|
|
+endif
|
|
+if HAVE_SEQ
|
|
+SUBDIRS += seq
|
|
+endif
|
|
+
|
|
EXTRA_DIST= TODO gitcompile
|
|
AUTOMAKE_OPTIONS=foreign
|
|
ACLOCAL_AMFLAGS = -I m4
|
|
diff --git a/alsaconf/alsaconf.in b/alsaconf/alsaconf.in
|
|
index 6e9ff75..ccc1b37 100644
|
|
--- a/alsaconf/alsaconf.in
|
|
+++ b/alsaconf/alsaconf.in
|
|
@@ -291,6 +291,8 @@ esac
|
|
|
|
# cfgfile = base config file to remove/update the sound setting
|
|
# cfgout = new config file to write the sound setting (if different from $cfgfile)
|
|
+cfgout=""
|
|
+cfgoldout=""
|
|
if [ -n "$cfgfile" ]; then
|
|
if [ ! -r "$cfgfile" ]; then
|
|
xecho "ERROR: The config file doesn't exist: "
|
|
@@ -301,10 +303,22 @@ else
|
|
if [ "$distribution" = "gentoo" ]; then
|
|
cfgfile="/etc/modules.d/alsa"
|
|
elif [ "$kernel" = "new" ]; then
|
|
+ cfgfile="/etc/modprobe.conf"
|
|
if [ -d /etc/modprobe.d ]; then
|
|
- cfgout="/etc/modprobe.d/sound"
|
|
+ cfgout="/etc/modprobe.d/50-sound.conf"
|
|
+ cfgoldout="/etc/modprobe.d/sound"
|
|
+ if [ ! -f $cfgout ]; then
|
|
+ modver=$(modprobe -V | sed -e's/^module-init-tools version //')
|
|
+ case "$modver" in
|
|
+ 3.[789]*)
|
|
+ ;;
|
|
+ *)
|
|
+ cfgout="/etc/modprobe.d/sound"
|
|
+ cfgoldout=""
|
|
+ ;;
|
|
+ esac
|
|
+ fi
|
|
fi
|
|
- cfgfile="/etc/modprobe.conf"
|
|
elif [ "$distribution" = "debian" ]; then
|
|
cfgfile="/etc/modutils/sound"
|
|
elif [ -e /etc/modules.conf ]; then
|
|
@@ -818,7 +832,7 @@ ac_config_card () {
|
|
msg=$(xmsg "
|
|
Configuring %s
|
|
Do you want to modify %s (and %s if present)?" $CARD_DRIVER $cfgout $cfgfile)
|
|
- $DIALOG --yesno "$msg" 8 50 || acex 0
|
|
+ $DIALOG --yesno "$msg" 10 50 || acex 0
|
|
else
|
|
msg=$(xmsg "
|
|
Configuring %s
|
|
@@ -875,6 +889,7 @@ alias sound-slot-0 $CARD_DRIVER" >> $addcfg
|
|
if [ -n "$cfgout" ]; then
|
|
[ ! -r "$cfgfile" ] || cmp -s "$TMP" "$cfgfile" || cat "$TMP" > "$cfgfile"
|
|
cmp -s "$addcfg" "$cfgout" || cat "$addcfg" > "$cfgout"
|
|
+ test -n "$cfgoldout" && rm -f "$cfgoldout"
|
|
else
|
|
echo "$ACB
|
|
# --- ALSACONF version $version ---" >> $TMP
|
|
diff --git a/alsactl/alsactl.c b/alsactl/alsactl.c
|
|
index e0bc276..02e082f 100644
|
|
--- a/alsactl/alsactl.c
|
|
+++ b/alsactl/alsactl.c
|
|
@@ -97,7 +97,8 @@ int main(int argc, char *argv[])
|
|
};
|
|
char *cfgfile = SYS_ASOUNDRC;
|
|
char *initfile = DATADIR "/init/00main";
|
|
- char *cardname, **tmp, ncardname[16];
|
|
+ char *cardname, ncardname[16];
|
|
+ const char *const *tmp;
|
|
int removestate = 0;
|
|
int init_fallback = 1; /* new default behavior */
|
|
int res;
|
|
@@ -106,7 +107,7 @@ int main(int argc, char *argv[])
|
|
while (1) {
|
|
int c;
|
|
|
|
- if ((c = getopt_long(argc, argv, "hdvf:FgE:i:Pr:R", long_option, NULL)) < 0)
|
|
+ if ((c = getopt_long(argc, argv, "hdvf:FgE:i:IPr:R", long_option, NULL)) < 0)
|
|
break;
|
|
switch (c) {
|
|
case 'h':
|
|
diff --git a/alsactl/init/default b/alsactl/init/default
|
|
index 66692b3..e2dcfd6 100644
|
|
--- a/alsactl/init/default
|
|
+++ b/alsactl/init/default
|
|
@@ -11,6 +11,7 @@
|
|
# **************************************************************************
|
|
|
|
ENV{volume}:="-20dB"
|
|
+ENV{cvolume}:="12dB"
|
|
|
|
CTL{reset}="mixer"
|
|
CTL{name}="Playback Volume",PROGRAM=="__ctl_search", \
|
|
@@ -55,14 +56,21 @@ CTL{name}="PC Speaker Playback Switch",PROGRAM=="__ctl_search", \
|
|
CTL{values}="on"
|
|
|
|
CTL{reset}="mixer"
|
|
-CTL{name}="PCM Playback Volume",PROGRAM=="__ctl_search", \
|
|
- CTL{values}="$env{volume}",RESULT!="0",CTL{values}="75%"
|
|
+CTL{name}="PCM Playback Volume",PROGRAM!="__ctl_search",GOTO="pcm0_end"
|
|
+# exception - some HDA codecs have shifted dB range
|
|
+CTL{dBmin}=="-34.50dB",CTL{dBmax}=="12.00dB",CTL{values}="0dB",GOTO="pcm0_end"
|
|
+CTL{values}="$env{volume}",RESULT!="0",CTL{values}="75%"
|
|
+LABEL="pcm0_end"
|
|
CTL{name}="PCM Playback Switch",PROGRAM=="__ctl_search", \
|
|
CTL{values}="on"
|
|
|
|
CTL{reset}="mixer"
|
|
-CTL{name}="PCM Playback Volume",CTL{index}="1",PROGRAM=="__ctl_search", \
|
|
- CTL{values}="$env{volume}",RESULT!="0",CTL{values}="75%"
|
|
+CTL{name}="PCM Playback Volume",CTL{index}="1",PROGRAM!="__ctl_search", \
|
|
+ GOTO="pcm1_end"
|
|
+# exception - some HDA codecs have shifted dB range
|
|
+CTL{dBmin}=="-34.50dB",CTL{dBmax}=="12.00dB",CTL{values}="0dB",GOTO="pcm1_end"
|
|
+CTL{values}="$env{volume}",RESULT!="0",CTL{values}="75%"
|
|
+LABEL="pcm1_end"
|
|
CTL{name}="PCM Playback Switch",CTL{index}="1",PROGRAM=="__ctl_search", \
|
|
CTL{values}="on"
|
|
|
|
@@ -91,8 +99,11 @@ CTL{name}="Music Playback Switch",PROGRAM=="__ctl_search", \
|
|
CTL{values}="on"
|
|
|
|
CTL{reset}="mixer"
|
|
-CTL{name}="CD Playback Volume",PROGRAM=="__ctl_search", \
|
|
- CTL{values}="$env{volume}",RESULT!="0",CTL{values}="75%"
|
|
+CTL{name}="CD Playback Volume",PROGRAM!="__ctl_search", GOTO="cd0_end"
|
|
+# exception - some HDA codecs have shifted dB range
|
|
+CTL{dBmin}=="-34.50dB",CTL{dBmax}=="12.00dB",CTL{values}="0dB",GOTO="cd0_end"
|
|
+CTL{values}="$env{volume}",RESULT!="0",CTL{values}="75%"
|
|
+LABEL="cd0_end"
|
|
CTL{name}="CD Playback Switch",PROGRAM=="__ctl_search", \
|
|
CTL{values}="on"
|
|
|
|
@@ -130,15 +141,14 @@ ENV{volume}:="20dB"
|
|
|
|
CTL{reset}="mixer"
|
|
CTL{name}="Capture Volume",PROGRAM=="__ctl_search", \
|
|
- CTL{values}="$env{volume}",RESULT!="0",CTL{values}="75%"
|
|
+ CTL{values}="$env{cvolume}",RESULT!="0",CTL{values}="75%"
|
|
CTL{name}="Capture Switch",PROGRAM=="__ctl_search", \
|
|
CTL{values}="on"
|
|
|
|
-CTL{name}="Input Source",PROGRAM=="__ctl_search", \
|
|
- CTL{enums}=="*|Internal Mic|*",CTL{values}="Internal Mic", \
|
|
+CTL{name}="Input Source",PROGRAM!="__ctl_search", GOTO="end_input_source"
|
|
+CTL{enums}=="*|Internal Mic|*",CTL{values}="Internal Mic", \
|
|
GOTO="end_input_source"
|
|
-CTL{name}="Input Source",PROGRAM=="__ctl_search", \
|
|
- CTL{enums}=="*|Mic|*",CTL{values}="Mic"
|
|
+CTL{enums}=="*|Mic|*",CTL{values}="Mic"
|
|
LABEL="end_input_source"
|
|
|
|
CTL{name}="Internal Mic Boost",PROGRAM=="__ctl_search", \
|
|
diff --git a/alsactl/init_parse.c b/alsactl/init_parse.c
|
|
index 31ed56e..77146d2 100644
|
|
--- a/alsactl/init_parse.c
|
|
+++ b/alsactl/init_parse.c
|
|
@@ -381,7 +381,7 @@ static int set_ctl_value(struct space *space, const char *value, int all)
|
|
snd_ctl_elem_value_set_integer(space->ctl_value, idx, val);
|
|
} else if (items > 2 && value[items-2] == 'd' && value[items-1] == 'B') {
|
|
val = strtol(value, NULL, 0) * 100;
|
|
- if ((pos2 = index(value, '.')) != NULL) {
|
|
+ if ((pos2 = strchr(value, '.')) != NULL) {
|
|
if (isdigit(*(pos2-1)) && isdigit(*(pos2-2))) {
|
|
if (val < 0)
|
|
val -= strtol(pos2 + 1, NULL, 0);
|
|
@@ -1253,7 +1253,7 @@ static char *new_root_dir(const char *filename)
|
|
|
|
res = strdup(filename);
|
|
if (res) {
|
|
- tmp = rindex(res, '/');
|
|
+ tmp = strrchr(res, '/');
|
|
if (tmp)
|
|
*tmp = '\0';
|
|
}
|
|
diff --git a/alsactl/init_utils_string.c b/alsactl/init_utils_string.c
|
|
index 2598e9f..01ea800 100644
|
|
--- a/alsactl/init_utils_string.c
|
|
+++ b/alsactl/init_utils_string.c
|
|
@@ -17,17 +17,6 @@
|
|
*/
|
|
|
|
|
|
-static int string_is_true(const char *str)
|
|
-{
|
|
- if (strcasecmp(str, "true") == 0)
|
|
- return 1;
|
|
- if (strcasecmp(str, "yes") == 0)
|
|
- return 1;
|
|
- if (strcasecmp(str, "1") == 0)
|
|
- return 1;
|
|
- return 0;
|
|
-}
|
|
-
|
|
static void remove_trailing_chars(char *path, char c)
|
|
{
|
|
size_t len;
|
|
diff --git a/configure.in b/configure.in
|
|
index 59247ed..0facec4 100644
|
|
--- a/configure.in
|
|
+++ b/configure.in
|
|
@@ -29,10 +29,27 @@ AC_PROG_INSTALL
|
|
AC_PROG_LN_S
|
|
AM_PATH_ALSA(1.0.16)
|
|
|
|
+dnl Check components
|
|
+AC_CHECK_HEADERS([alsa/pcm.h], [have_pcm="yes"], [have_pcm="no"],
|
|
+ [#include <alsa/asoundlib.h>])
|
|
+AC_CHECK_HEADERS([alsa/mixer.h], [have_mixer="yes"], [have_mixer="no"],
|
|
+ [#include <alsa/asoundlib.h>])
|
|
+AC_CHECK_HEADERS([alsa/rawmidi.h], [have_rawmidi="yes"], [have_rawmidi="no"],
|
|
+ [#include <alsa/asoundlib.h>])
|
|
+AC_CHECK_HEADERS([alsa/seq.h], [have_seq="yes"], [have_seq="no"],
|
|
+ [#include <alsa/asoundlib.h>])
|
|
+
|
|
+AM_CONDITIONAL(HAVE_PCM, test "$have_pcm" = "yes")
|
|
+AM_CONDITIONAL(HAVE_MIXER, test "$have_mixer" = "yes")
|
|
+AM_CONDITIONAL(HAVE_RAWMIDI, test "$have_rawmidi" = "yes")
|
|
+AM_CONDITIONAL(HAVE_SEQ, test "$have_seq" = "yes")
|
|
+
|
|
dnl Disable alsamixer
|
|
CURSESINC=""
|
|
CURSESLIB=""
|
|
CURSES_CFLAGS=""
|
|
+alsamixer=
|
|
+if test "$have_mixer" = "yes"; then
|
|
AC_ARG_ENABLE(alsamixer,
|
|
[ --disable-alsamixer Disable alsamixer compilation],
|
|
[case "${enableval}" in
|
|
@@ -40,6 +57,7 @@ AC_ARG_ENABLE(alsamixer,
|
|
no) alsamixer=false ;;
|
|
*) AC_MSG_ERROR(bad value ${enableval} for --enable-alsamixer) ;;
|
|
esac],[alsamixer=true])
|
|
+fi
|
|
AM_CONDITIONAL(ALSAMIXER, test x$alsamixer = xtrue)
|
|
|
|
dnl Disable alsaconf
|
|
diff --git a/speaker-test/speaker-test.c b/speaker-test/speaker-test.c
|
|
index 75a4bed..63a7151 100644
|
|
--- a/speaker-test/speaker-test.c
|
|
+++ b/speaker-test/speaker-test.c
|
|
@@ -85,48 +85,48 @@ static const char *given_test_wav_file = NULL;
|
|
static char *wav_file_dir = SOUNDSDIR;
|
|
|
|
static const char *const channel_name[MAX_CHANNELS] = {
|
|
- N_("Front Left"),
|
|
- N_("Front Right"),
|
|
- N_("Rear Left"),
|
|
- N_("Rear Right"),
|
|
- N_("Center"),
|
|
- N_("LFE"),
|
|
- N_("Side Left"),
|
|
- N_("Side Right"),
|
|
- N_("Channel 9"),
|
|
- N_("Channel 10"),
|
|
- N_("Channel 11"),
|
|
- N_("Channel 12"),
|
|
- N_("Channel 13"),
|
|
- N_("Channel 14"),
|
|
- N_("Channel 15"),
|
|
- N_("Channel 16")
|
|
+ /* 0 */ N_("Front Left"),
|
|
+ /* 1 */ N_("Front Right"),
|
|
+ /* 2 */ N_("Rear Left"),
|
|
+ /* 3 */ N_("Rear Right"),
|
|
+ /* 4 */ N_("Center"),
|
|
+ /* 5 */ N_("LFE"),
|
|
+ /* 6 */ N_("Side Left"),
|
|
+ /* 7 */ N_("Side Right"),
|
|
+ /* 8 */ N_("Channel 9"),
|
|
+ /* 9 */ N_("Channel 10"),
|
|
+ /* 10 */ N_("Channel 11"),
|
|
+ /* 11 */ N_("Channel 12"),
|
|
+ /* 12 */ N_("Channel 13"),
|
|
+ /* 13 */ N_("Channel 14"),
|
|
+ /* 14 */ N_("Channel 15"),
|
|
+ /* 15 */ N_("Channel 16")
|
|
};
|
|
|
|
static const int channels4[] = {
|
|
- 0,
|
|
- 1,
|
|
- 3,
|
|
- 2
|
|
+ 0, /* Front Left */
|
|
+ 1, /* Front Right */
|
|
+ 3, /* Rear Right */
|
|
+ 2, /* Rear Left */
|
|
};
|
|
static const int channels6[] = {
|
|
- 0,
|
|
- 4,
|
|
- 1,
|
|
- 3,
|
|
- 2,
|
|
- 5
|
|
-};
|
|
+ 0, /* Front Left */
|
|
+ 4, /* Center */
|
|
+ 1, /* Front Right */
|
|
+ 3, /* Rear Right */
|
|
+ 2, /* Rear Left */
|
|
+ 5, /* LFE */
|
|
+};
|
|
static const int channels8[] = {
|
|
- 0,
|
|
- 4,
|
|
- 1,
|
|
- 7,
|
|
- 3,
|
|
- 2,
|
|
- 6,
|
|
- 5
|
|
-};
|
|
+ 0, /* Front Left */
|
|
+ 4, /* Center */
|
|
+ 1, /* Front Right */
|
|
+ 7, /* Side Right */
|
|
+ 3, /* Rear Right */
|
|
+ 2, /* Rear Left */
|
|
+ 6, /* Side Left */
|
|
+ 5, /* LFE */
|
|
+};
|
|
|
|
static void generate_sine(uint8_t *frames, int channel, int count, double *_phase) {
|
|
double phase = *_phase;
|