From bbd106d104ec3995964e89cb54a9a5a67fc7591d Mon Sep 17 00:00:00 2001 From: Alexander Stein Date: Thu, 10 Apr 2025 13:01:19 +0200 Subject: [PATCH 1/2] bat: Fix buffer time configuration By swapping time configuration some hardware constraints can be supported. Fixes the error: Set parameter to device error: buffer time: 500000 hw:tqmtlv320aic32: Invalid argument(-22) Signed-off-by: Alexander Stein Signed-off-by: Takashi Iwai --- bat/alsa.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bat/alsa.c b/bat/alsa.c index 67489c421..457e79a2b 100644 --- a/bat/alsa.c +++ b/bat/alsa.c @@ -221,23 +221,23 @@ static int set_snd_pcm_params(struct bat *bat, struct pcm_container *sndpcm) period_time = buffer_time / DIV_BUFFERTIME; - /* Set buffer time and period time */ - err = snd_pcm_hw_params_set_buffer_time_near(sndpcm->handle, - params, &buffer_time, 0); + /* Set period time and buffer time */ + err = snd_pcm_hw_params_set_period_time_near(sndpcm->handle, + params, &period_time, 0); if (err < 0) { fprintf(bat->err, _("Set parameter to device error: ")); - fprintf(bat->err, _("buffer time: %d %s: %s(%d)\n"), - buffer_time, + fprintf(bat->err, _("period time: %d %s: %s(%d)\n"), + period_time, device_name, snd_strerror(err), err); return err; } - err = snd_pcm_hw_params_set_period_time_near(sndpcm->handle, - params, &period_time, 0); + err = snd_pcm_hw_params_set_buffer_time_near(sndpcm->handle, + params, &buffer_time, 0); if (err < 0) { fprintf(bat->err, _("Set parameter to device error: ")); - fprintf(bat->err, _("period time: %d %s: %s(%d)\n"), - period_time, + fprintf(bat->err, _("buffer time: %d %s: %s(%d)\n"), + buffer_time, device_name, snd_strerror(err), err); return err; } From 29ad5de8f156d7a954ab2f0c3c9c58dac9dfb595 Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Wed, 4 Jun 2025 09:35:00 +0200 Subject: [PATCH 2/2] alsaloop: only log xrun debug messages when verbose Xruns can happen quite often (E.G. continuously when using alsaloop to/from the UAC gadget driver without a connected host), so only log the debug messages when verbose logging has been requested to not flood the logs. Signed-off-by: Peter Korsgaard --- alsaloop/pcmjob.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/alsaloop/pcmjob.c b/alsaloop/pcmjob.c index ffb439b45..2720f55f0 100644 --- a/alsaloop/pcmjob.c +++ b/alsaloop/pcmjob.c @@ -647,13 +647,15 @@ static int xrun(struct loopback_handle *lhandle) int err; if (lhandle == lhandle->loopback->play) { - logit(LOG_DEBUG, "underrun for %s\n", lhandle->id); + if (verbose) + logit(LOG_DEBUG, "underrun for %s\n", lhandle->id); xrun_stats(lhandle->loopback); if ((err = snd_pcm_prepare(lhandle->handle)) < 0) return err; lhandle->xrun_pending = 1; } else { - logit(LOG_DEBUG, "overrun for %s\n", lhandle->id); + if (verbose) + logit(LOG_DEBUG, "overrun for %s\n", lhandle->id); xrun_stats(lhandle->loopback); if ((err = snd_pcm_prepare(lhandle->handle)) < 0) return err;