From fbd282b1464f013e84fd750faf7af61b595c279d Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 27 Oct 2023 15:05:06 -0500 Subject: [PATCH 1/2] aplay: log pcm status before reporting a fatal error When the --fatal-errors happen, nothing is provided to the user even when the '-v' verbose option is specified. This patch adds the fatal error exit after dumping the logs. No functionality change, just better information on what just happened. Signed-off-by: Pierre-Louis Bossart --- aplay/aplay.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/aplay/aplay.c b/aplay/aplay.c index 9cf36dee2..0060789ea 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -1656,12 +1656,6 @@ static void xrun(void) prg_exit(EXIT_FAILURE); } if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) { - if (fatal_errors) { - error(_("fatal %s: %s"), - stream == SND_PCM_STREAM_PLAYBACK ? _("underrun") : _("overrun"), - snd_strerror(res)); - prg_exit(EXIT_FAILURE); - } if (monotonic) { #ifdef HAVE_CLOCK_GETTIME struct timespec now, diff, tstamp; @@ -1687,6 +1681,12 @@ static void xrun(void) fprintf(stderr, _("Status:\n")); snd_pcm_status_dump(status, log); } + if (fatal_errors) { + error(_("fatal %s: %s"), + stream == SND_PCM_STREAM_PLAYBACK ? _("underrun") : _("overrun"), + snd_strerror(res)); + prg_exit(EXIT_FAILURE); + } if ((res = snd_pcm_prepare(handle))<0) { error(_("xrun: prepare error: %s"), snd_strerror(res)); prg_exit(EXIT_FAILURE); From 8237b1fe3c3aed29c3f34fa236af589c74379eab Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 27 Oct 2023 15:09:56 -0500 Subject: [PATCH 2/2] aplay: enable timestamps by default When the '-v' or '--test-position' options are used, the 'tstamp' is shown as zero. Unconditionally enable the timestamps and choose the timestamp time based on the 'monotonic' variable. Example log: Status(R/W) (standalone avail=36 delay=924): state : RUNNING trigger_time: 2045.504937 tstamp : 2190.754602 delay : 924 avail : 36 avail_max : 444 Status(R/W) (standalone avail=44 delay=912): state : RUNNING trigger_time: 2045.504937 tstamp : 2190.754852 delay : 912 avail : 48 avail_max : 48 underrun!!! (at least 471.161 ms long) Status: state : XRUN trigger_time: 2190.786234 tstamp : 2191.257392 delay : 0 avail : 1412 avail_max : 1412 aplay: xrun:1690: fatal underrun: Success Alternatively a new option could be added to control the behavior. Signed-off-by: Pierre-Louis Bossart --- aplay/aplay.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/aplay/aplay.c b/aplay/aplay.c index 0060789ea..90c630565 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -1473,6 +1473,15 @@ static void set_params(void) err = snd_pcm_sw_params_set_stop_threshold(handle, swparams, stop_threshold); assert(err >= 0); + err = snd_pcm_sw_params_set_tstamp_mode(handle, swparams, SND_PCM_TSTAMP_ENABLE); + assert(err >= 0); + + if (monotonic) + err = snd_pcm_sw_params_set_tstamp_type(handle, swparams, SND_PCM_TSTAMP_TYPE_MONOTONIC); + else + err = snd_pcm_sw_params_set_tstamp_type(handle, swparams, SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY); + assert(err >= 0); + if (snd_pcm_sw_params(handle, swparams) < 0) { error(_("unable to install sw params:")); snd_pcm_sw_params_dump(swparams, log);