]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: fix a bug to copy silent samples aligned to 64
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Fri, 2 Feb 2018 05:44:35 +0000 (14:44 +0900)
committerJaroslav Kysela <perex@perex.cz>
Mon, 5 Feb 2018 08:58:03 +0000 (09:58 +0100)
bits for
  24 bit sample cases

A function of 'snd_pcm_area_silence()' has a fast path to copy silent data
efficiently. However, the fast path works well just for a case that target
buffer consists of data samples for which unit of data alignment is
divisors of 64 bits.

At present, the fast path handles sample data aligned to 24 bit. In this
case, the buffer can includes extra 8 bits. This has no issue for 'signed'
case because silent data is zero, however it has an issue for 'unsigned'
case.

This commit fixes the bug by skipping cases of sample data of 24 bit.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm.c

index 1753cdac6537cf41b196bfa07bba35a4e729e917..86250970293f5ee5abf46d6bf4e5f9df9c0da934 100644 (file)
@@ -2947,7 +2947,11 @@ 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) {
+        /*
+         * Iterate copying silent sample for sample data aligned to 64 bit.
+         * This is a fast path.
+         */
+        if (dst_area->step == (unsigned int) width && (64 % width) == 0) {
                unsigned int dwords = samples * width / 64;
                uint64_t *dstp = (uint64_t *)dst;
                samples -= dwords * 64 / width;