All of lore.kernel.org
 help / color / mirror / Atom feed
From: furrywolf <alsa2@bushytails.net>
To: patch@alsa-project.org
Cc: alsa-devel@alsa-project.org, furrywolf <alsa2@bushytails.net>
Subject: [PATCH - alsa-lib 1/1] Patch for another bug in snd_pcm_area_silence().
Date: Thu,  1 Feb 2018 10:12:12 -0800	[thread overview]
Message-ID: <1517508732-27545-1-git-send-email-alsa2@bushytails.net> (raw)

Only silence areas 64 bits at a time if it's possible to do so, which is
when either the silence values are all zero, or when the format width
divides evenly into 64 bits.  For formats that are neither of these, let
the width-specific code handle the entire silencing.  Silencing formats
that are not evenly divisible into 64 bits in 64-bit chunks, when the
data isn't just zeroes, results in values being written to shifting
positions in the sample, giving garbage.

Makes Takashi Sakamoto's tester happy for all tests.  Yay!  (And Thanks!)

Signed-off-by: furrywolf <alsa2@bushytails.net>

diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index 1753cda..5f9bd9f 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -2947,7 +2947,7 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes
 	dst = snd_pcm_channel_area_addr(dst_area, dst_offset);
 	width = snd_pcm_format_physical_width(format);
 	silence = snd_pcm_format_silence_64(format);
-	if (dst_area->step == (unsigned int) width) {
+	if (dst_area->step == (unsigned int) width && (!silence || !(64 % width))) {
 		unsigned int dwords = samples * width / 64;
 		uint64_t *dstp = (uint64_t *)dst;
 		samples -= dwords * 64 / width;
-- 
1.9.1

             reply	other threads:[~2018-02-01 18:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-01 18:12 furrywolf [this message]
2018-02-02  6:41 ` [PATCH - alsa-lib 1/1] Patch for another bug in snd_pcm_area_silence() Takashi Sakamoto
2018-02-05  9:06   ` Jaroslav Kysela
2018-02-05  9:30     ` Michael Nazzareno Trimarchi
2018-02-05 14:22     ` Jaroslav Kysela

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=1517508732-27545-1-git-send-email-alsa2@bushytails.net \
    --to=alsa2@bushytails.net \
    --cc=alsa-devel@alsa-project.org \
    --cc=patch@alsa-project.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.