From: Jarkko Nikula <jarkko.nikula@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: Takashi Iwai <tiwai@suse.de>,
Jarkko Nikula <jarkko.nikula@linux.intel.com>,
guillaume-florianx.vidal@intel.com
Subject: [PATCH] speaker-test: Fix dropped samples at the end of test
Date: Fri, 12 Sep 2014 15:14:28 +0300 [thread overview]
Message-ID: <1410524068-15982-1-git-send-email-jarkko.nikula@linux.intel.com> (raw)
Commit 6d1673526b0f ("Avoid unnecessary drain/restart in speaker-test")
drains only when buffer is bigger than audio sample. This has a drawback
that up to buffer size amount of data may not be heard at the end of audio
sample.
This was noted with "speaker-test -c 2 -t wav -s 2" test on a
hardware that has a buffer size of 24000 samples and 48 kHz sample rate.
Instead of playing "front right" it played something like "front ra".
Reverse buffer size vs sample size test wouldn't work either since then
samples smaller than buffer are dropped.
Fix this by removing buffer_size tests from write_loop() and do
drain/restart always when not aborting.
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reported-by: Vidal, Guillaume-florianX <guillaume-florianx.vidal@intel.com>
---
This was originally noted on Baytrail ADSP hw (default buffer size 24000)
but can be heard also on Intel HDA (default buffer size 8192) when audio
sample is small enough but bigger than buffer. For instance 100 ms sample
finishes too shortly (buffer size 8192, sample size 9600) but 50 ms plays
ok (buffer size 8192, sample size 4800).
I guess some optimization can be done for snd_pcm_prepare() when not looping
but that's not necessary for this fix.
---
speaker-test/speaker-test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/speaker-test/speaker-test.c b/speaker-test/speaker-test.c
index 61396f296c65..836fd26d35b1 100644
--- a/speaker-test/speaker-test.c
+++ b/speaker-test/speaker-test.c
@@ -942,7 +942,7 @@ static int write_loop(snd_pcm_t *handle, int channel, int periods, uint8_t *fram
snd_pcm_bytes_to_frames(handle, err * channels))) < 0)
break;
}
- if (buffer_size > n && !in_aborting) {
+ if (!in_aborting) {
snd_pcm_drain(handle);
snd_pcm_prepare(handle);
}
@@ -964,7 +964,7 @@ static int write_loop(snd_pcm_t *handle, int channel, int periods, uint8_t *fram
if ((err = write_buffer(handle, frames, period_size)) < 0)
return err;
}
- if (buffer_size > n * period_size && !in_aborting) {
+ if (!in_aborting) {
snd_pcm_drain(handle);
snd_pcm_prepare(handle);
}
--
2.1.0
next reply other threads:[~2014-09-12 12:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-12 12:14 Jarkko Nikula [this message]
2014-09-15 15:23 ` [PATCH] speaker-test: Fix dropped samples at the end of test Takashi Iwai
2014-09-16 3:30 ` Jie, Yang
2014-09-16 7:51 ` Jarkko Nikula
2014-09-16 14:45 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1410524068-15982-1-git-send-email-jarkko.nikula@linux.intel.com \
--to=jarkko.nikula@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=guillaume-florianx.vidal@intel.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).