OBS User unknown 2009-04-24 17:24:03 +00:00 committed by Git OBS Bridge
parent 56e362f096
commit 4bf5fa344e
3 changed files with 361 additions and 5 deletions

View File

@ -187,7 +187,7 @@ index 66692b3..e2dcfd6 100644
CTL{name}="Internal Mic Boost",PROGRAM=="__ctl_search", \
diff --git a/alsactl/init_parse.c b/alsactl/init_parse.c
index 31ed56e..77146d2 100644
index 31ed56e..335cb06 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)
@ -199,6 +199,15 @@ index 31ed56e..77146d2 100644
if (isdigit(*(pos2-1)) && isdigit(*(pos2-2))) {
if (val < 0)
val -= strtol(pos2 + 1, NULL, 0);
@@ -396,7 +396,7 @@ static int set_ctl_value(struct space *space, const char *value, int all)
}
val = snd_ctl_convert_from_dB(snd_hctl_ctl(space->ctl_handle), space->ctl_id, val, &lval, -1);
if (val < 0) {
- Perror(space, "unable to convert dB value '%s' to internal integer range", value);
+ dbg("unable to convert dB value '%s' to internal integer range", value);
return val;
}
snd_ctl_elem_value_set_integer(space->ctl_value, idx, lval);
@@ -1253,7 +1253,7 @@ static char *new_root_dir(const char *filename)
res = strdup(filename);
@ -208,6 +217,19 @@ index 31ed56e..77146d2 100644
if (tmp)
*tmp = '\0';
}
@@ -1313,10 +1313,9 @@ static int parse_line(struct space *space, char *line, size_t linesize)
}
snprintf(string, sizeof(string), "%i", err);
space->program_result = strdup(string);
- if (err < 0 || space->program_result == NULL) {
- err = 0;
+ err = 0;
+ if (space->program_result == NULL)
break;
- }
} else if (op == KEY_OP_MATCH || op == KEY_OP_NOMATCH) {
dbg("ctl match: '%s' '%s'", value, attr);
temp = (char *)elemid_get(space, attr);
diff --git a/alsactl/init_utils_string.c b/alsactl/init_utils_string.c
index 2598e9f..01ea800 100644
--- a/alsactl/init_utils_string.c
@ -230,11 +252,294 @@ index 2598e9f..01ea800 100644
static void remove_trailing_chars(char *path, char c)
{
size_t len;
diff --git a/alsamixer/alsamixer.c b/alsamixer/alsamixer.c
index 414033e..c65c22d 100644
--- a/alsamixer/alsamixer.c
+++ b/alsamixer/alsamixer.c
@@ -2113,11 +2113,13 @@ mixer_iteration (void)
mixer_hscroll_delta -= 1;
break;
case KEY_UP:
+ case 'k':
case 'w':
case 'W':
mixer_vscroll_delta -= 1;
break;
case KEY_DOWN:
+ case 'j':
case 'x':
case 'X':
mixer_vscroll_delta += 1;
@@ -2179,12 +2181,14 @@ mixer_iteration (void)
break;
case 'w':
case KEY_UP:
+ case 'k':
mixer_set_delta(1);
case 'W':
mixer_add_delta(1);
break;
case 'x':
case KEY_DOWN:
+ case 'j':
mixer_set_delta(-1);
case 'X':
mixer_add_delta(-1);
diff --git a/aplay/Makefile.am b/aplay/Makefile.am
index 60811de..92323d1 100644
--- a/aplay/Makefile.am
+++ b/aplay/Makefile.am
@@ -1,5 +1,7 @@
+LIBRT = @LIBRT@
+
INCLUDES = -I$(top_srcdir)/include
-LDADD = $(LIBINTL)
+LDADD = $(LIBINTL) $(LIBRT)
# debug flags
#LDFLAGS = -static
diff --git a/aplay/aplay.c b/aplay/aplay.c
index 837e46a..c7c82a1 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -101,12 +101,15 @@ static snd_pcm_uframes_t buffer_frames = 0;
static int avail_min = -1;
static int start_delay = 0;
static int stop_delay = 0;
+static int monotonic = 0;
static int verbose = 0;
static int vumeter = VUMETER_NONE;
static int buffer_pos = 0;
static size_t bits_per_sample, bits_per_frame;
static size_t chunk_bytes;
static int test_position = 0;
+static int test_coef = 8;
+static int test_nowait = 0;
static snd_output_t *log;
static int fd = -1;
@@ -188,7 +191,10 @@ _("Usage: %s [OPTION]... [FILE]...\n"
" --disable-channels disable automatic channel conversions\n"
" --disable-format disable automatic format conversions\n"
" --disable-softvol disable software volume control (softvol)\n"
-" --test-position test ring buffer position\n")
+" --test-position test ring buffer position\n"
+" --test-coef=# test coeficient for ring buffer position (default 8)\n"
+" expression for validation is: coef * (buffer_size / 2)\n"
+" --test-nowait do not wait for ring buffer - eats whole CPU\n")
, command);
printf(_("Recognized sample formats are:"));
for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) {
@@ -350,7 +356,9 @@ enum {
OPT_DISABLE_CHANNELS,
OPT_DISABLE_FORMAT,
OPT_DISABLE_SOFTVOL,
- OPT_TEST_POSITION
+ OPT_TEST_POSITION,
+ OPT_TEST_COEF,
+ OPT_TEST_NOWAIT
};
int main(int argc, char *argv[])
@@ -389,6 +397,8 @@ int main(int argc, char *argv[])
{"disable-format", 0, 0, OPT_DISABLE_FORMAT},
{"disable-softvol", 0, 0, OPT_DISABLE_SOFTVOL},
{"test-position", 0, 0, OPT_TEST_POSITION},
+ {"test-coef", 1, 0, OPT_TEST_COEF},
+ {"test-nowait", 0, 0, OPT_TEST_NOWAIT},
{0, 0, 0, 0}
};
char *pcm_name = "default";
@@ -570,6 +580,14 @@ int main(int argc, char *argv[])
case OPT_TEST_POSITION:
test_position = 1;
break;
+ case OPT_TEST_COEF:
+ test_coef = strtol(optarg, NULL, 0);
+ if (test_coef < 1)
+ test_coef = 1;
+ break;
+ case OPT_TEST_NOWAIT:
+ test_nowait = 1;
+ break;
default:
fprintf(stderr, _("Try `%s --help' for more information.\n"), command);
return 1;
@@ -1017,6 +1035,7 @@ static void set_params(void)
&buffer_frames);
}
assert(err >= 0);
+ monotonic = snd_pcm_hw_params_is_monotonic(params);
err = snd_pcm_hw_params(handle, params);
if (err < 0) {
error(_("Unable to install hw params:"));
@@ -1112,6 +1131,18 @@ do { \
} while (0)
#endif
+#ifndef timermsub
+#define timermsub(a, b, result) \
+do { \
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
+ (result)->tv_nsec = (a)->tv_nsec - (b)->tv_nsec; \
+ if ((result)->tv_nsec < 0) { \
+ --(result)->tv_sec; \
+ (result)->tv_nsec += 1000000000L; \
+ } \
+} while (0)
+#endif
+
/* I/O error handler */
static void xrun(void)
{
@@ -1124,13 +1155,27 @@ static void xrun(void)
exit(EXIT_FAILURE);
}
if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) {
- struct timeval now, diff, tstamp;
- gettimeofday(&now, 0);
- snd_pcm_status_get_trigger_tstamp(status, &tstamp);
- timersub(&now, &tstamp, &diff);
- fprintf(stderr, _("%s!!! (at least %.3f ms long)\n"),
- stream == SND_PCM_STREAM_PLAYBACK ? _("underrun") : _("overrun"),
- diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
+ if (monotonic) {
+#ifdef HAVE_CLOCK_GETTIME
+ struct timespec now, diff, tstamp;
+ clock_gettime(CLOCK_MONOTONIC, &now);
+ snd_pcm_status_get_trigger_htstamp(status, &tstamp);
+ timermsub(&now, &tstamp, &diff);
+ fprintf(stderr, _("%s!!! (at least %.3f ms long)\n"),
+ stream == SND_PCM_STREAM_PLAYBACK ? _("underrun") : _("overrun"),
+ diff.tv_sec * 1000 + diff.tv_nsec / 10000000.0);
+#else
+ fprintf(stderr, "%s !!!\n", _("underrun"));
+#endif
+ } else {
+ struct timeval now, diff, tstamp;
+ gettimeofday(&now, 0);
+ snd_pcm_status_get_trigger_tstamp(status, &tstamp);
+ timersub(&now, &tstamp, &diff);
+ fprintf(stderr, _("%s!!! (at least %.3f ms long)\n"),
+ stream == SND_PCM_STREAM_PLAYBACK ? _("underrun") : _("overrun"),
+ diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
+ }
if (verbose) {
fprintf(stderr, _("Status:\n"));
snd_pcm_status_dump(status, log);
@@ -1396,20 +1441,60 @@ static void compute_max_peak(u_char *data, size_t count)
static void do_test_position(void)
{
- static int counter = 0;
+ static long counter = 0;
+ static time_t tmr = -1;
+ time_t now;
+ static float availsum, delaysum, samples;
+ static snd_pcm_sframes_t maxavail, maxdelay;
+ static snd_pcm_sframes_t minavail, mindelay;
+ static snd_pcm_sframes_t badavail = 0, baddelay = 0;
+ snd_pcm_sframes_t outofrange;
snd_pcm_sframes_t avail, delay;
int err;
err = snd_pcm_avail_delay(handle, &avail, &delay);
if (err < 0)
return;
- if (avail > 4 * (snd_pcm_sframes_t)buffer_frames ||
- avail < -4 * (snd_pcm_sframes_t)buffer_frames ||
- delay > 4 * (snd_pcm_sframes_t)buffer_frames ||
- delay < -4 * (snd_pcm_sframes_t)buffer_frames) {
- fprintf(stderr, "Suspicious buffer position (%i total): avail = %li, delay = %li, buffer = %li\n", ++counter, (long)avail, (long)delay, (long)buffer_frames);
+ outofrange = (test_coef * (snd_pcm_sframes_t)buffer_frames) / 2;
+ if (avail > outofrange || avail < -outofrange ||
+ delay > outofrange || delay < -outofrange) {
+ badavail = avail; baddelay = delay;
+ availsum = delaysum = samples = 0;
+ maxavail = maxdelay = 0;
+ minavail = mindelay = buffer_frames * 16;
+ fprintf(stderr, _("Suspicious buffer position (%li total): "
+ "avail = %li, delay = %li, buffer = %li\n"),
+ ++counter, (long)avail, (long)delay, (long)buffer_frames);
} else if (verbose) {
- fprintf(stderr, "Buffer position: %li/%li (%li)\n", (long)avail, (long)delay, (long)buffer_frames);
+ time(&now);
+ if (tmr == (time_t) -1) {
+ tmr = now;
+ availsum = delaysum = samples = 0;
+ maxavail = maxdelay = 0;
+ minavail = mindelay = buffer_frames * 16;
+ }
+ if (avail > maxavail)
+ maxavail = avail;
+ if (delay > maxdelay)
+ maxdelay = delay;
+ if (avail < minavail)
+ minavail = avail;
+ if (delay < mindelay)
+ mindelay = delay;
+ availsum += avail;
+ delaysum += delay;
+ samples++;
+ if (avail != 0 && now != tmr) {
+ fprintf(stderr, "BUFPOS: avg%li/%li "
+ "min%li/%li max%li/%li (%li) (%li:%li/%li)\n",
+ (long)(availsum / samples),
+ (long)(delaysum / samples),
+ (long)minavail, (long)mindelay,
+ (long)maxavail, (long)maxdelay,
+ (long)buffer_frames,
+ counter, badavail, baddelay);
+ tmr = now;
+ }
}
}
@@ -1433,7 +1518,8 @@ static ssize_t pcm_write(u_char *data, size_t count)
if (test_position)
do_test_position();
if (r == -EAGAIN || (r >= 0 && (size_t)r < count)) {
- snd_pcm_wait(handle, 1000);
+ if (!test_nowait)
+ snd_pcm_wait(handle, 1000);
} else if (r == -EPIPE) {
xrun();
} else if (r == -ESTRPIPE) {
@@ -1478,7 +1564,8 @@ static ssize_t pcm_writev(u_char **data, unsigned int channels, size_t count)
if (test_position)
do_test_position();
if (r == -EAGAIN || (r >= 0 && (size_t)r < count)) {
- snd_pcm_wait(handle, 1000);
+ if (!test_nowait)
+ snd_pcm_wait(handle, 1000);
} else if (r == -EPIPE) {
xrun();
} else if (r == -ESTRPIPE) {
@@ -1520,7 +1607,8 @@ static ssize_t pcm_read(u_char *data, size_t rcount)
if (test_position)
do_test_position();
if (r == -EAGAIN || (r >= 0 && (size_t)r < count)) {
- snd_pcm_wait(handle, 1000);
+ if (!test_nowait)
+ snd_pcm_wait(handle, 1000);
} else if (r == -EPIPE) {
xrun();
} else if (r == -ESTRPIPE) {
@@ -1562,7 +1650,8 @@ static ssize_t pcm_readv(u_char **data, unsigned int channels, size_t rcount)
if (test_position)
do_test_position();
if (r == -EAGAIN || (r >= 0 && (size_t)r < count)) {
- snd_pcm_wait(handle, 1000);
+ if (!test_nowait)
+ snd_pcm_wait(handle, 1000);
} else if (r == -EPIPE) {
xrun();
} else if (r == -ESTRPIPE) {
diff --git a/configure.in b/configure.in
index 59247ed..0facec4 100644
index 59247ed..d26ae65 100644
--- a/configure.in
+++ b/configure.in
@@ -29,10 +29,27 @@ AC_PROG_INSTALL
@@ -29,10 +29,44 @@ AC_PROG_INSTALL
AC_PROG_LN_S
AM_PATH_ALSA(1.0.16)
@ -252,6 +557,23 @@ index 59247ed..0facec4 100644
+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 Check for librt
+LIBRT=""
+AC_MSG_CHECKING(for librt)
+AC_ARG_WITH(librt,
+ AS_HELP_STRING([--with-librt], [Use librt for monotonic clock (default = yes)]),
+ [ have_librt="$withval" ], [ have_librt="yes" ])
+if test "$have_librt" = "yes"; then
+ AC_CHECK_LIB([rt], [clock_gettime], [HAVE_LIBRT="yes"])
+ if test "$HAVE_LIBRT" = "yes" ; then
+ LIBRT="-lrt"
+ AC_DEFINE([HAVE_LIBRT], 1, [Have librt])
+ AC_DEFINE([HAVE_CLOCK_GETTIME], 1, [Have clock gettime])
+ fi
+else
+ AC_MSG_RESULT(no)
+fi
+
dnl Disable alsamixer
CURSESINC=""
@ -262,7 +584,7 @@ index 59247ed..0facec4 100644
AC_ARG_ENABLE(alsamixer,
[ --disable-alsamixer Disable alsamixer compilation],
[case "${enableval}" in
@@ -40,6 +57,7 @@ AC_ARG_ENABLE(alsamixer,
@@ -40,6 +74,7 @@ AC_ARG_ENABLE(alsamixer,
no) alsamixer=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-alsamixer) ;;
esac],[alsamixer=true])
@ -270,6 +592,15 @@ index 59247ed..0facec4 100644
AM_CONDITIONAL(ALSAMIXER, test x$alsamixer = xtrue)
dnl Disable alsaconf
@@ -142,6 +177,8 @@ AC_SYS_LARGEFILE
SAVE_UTIL_VERSION
+AC_SUBST(LIBRT)
+
AC_OUTPUT(Makefile alsactl/Makefile alsactl/init/Makefile \
alsamixer/Makefile amidi/Makefile amixer/Makefile \
m4/Makefile po/Makefile.in \
diff --git a/speaker-test/speaker-test.c b/speaker-test/speaker-test.c
index 75a4bed..63a7151 100644
--- a/speaker-test/speaker-test.c

View File

@ -1,3 +1,17 @@
-------------------------------------------------------------------
Thu Apr 23 15:11:25 CEST 2009 - tiwai@suse.de
- updated as of 2009.04.23:
* Added vi-like key bindings to alsamixer
* alsactl/init: Fix CTL{value} assigning - make it relevant to
documentation
* aplay/arecord: improve suspicious buffer detection and add
--test-coef parameter
* aplay/arecord: remove debug printfs introduced by previous
patch
* aplay/arecord: fix underrun/overrun time calculation for
monotonic clock
-------------------------------------------------------------------
Wed Mar 18 12:19:29 CET 2009 - tiwai@suse.de

View File

@ -28,7 +28,7 @@ Requires: dialog pciutils
AutoReqProv: on
Summary: Advanced Linux Sound Architecture Utilities
Version: 1.0.19
Release: 3
Release: 4
Source: ftp://ftp.alsa-project.org/pub/util/alsa-utils-%{package_version}.tar.bz2
Patch: alsa-utils-git-fixes.diff
Url: http://www.alsa-project.org/
@ -78,6 +78,17 @@ make %{?jobs:-j %jobs}
%{_datadir}/alsa
%changelog
* Thu Apr 23 2009 tiwai@suse.de
- updated as of 2009.04.23:
* Added vi-like key bindings to alsamixer
* alsactl/init: Fix CTL{value} assigning - make it relevant to
documentation
* aplay/arecord: improve suspicious buffer detection and add
--test-coef parameter
* aplay/arecord: remove debug printfs introduced by previous
patch
* aplay/arecord: fix underrun/overrun time calculation for
monotonic clock
* Wed Mar 18 2009 tiwai@suse.de
- add missing -I option for alsactl
- prefer /etc/modprobe.d/50-sound.conf for new module-init-tools