alsa/0006-pcm-dshare-Fix-overflow-when-slave_hw_ptr-rolls-over.patch
Takashi Iwai 31229b2211 Accepting request 689240 from home:tiwai:branches:multimedia:libs
- Backport upstream fixes: PCM sw_params behavior fix, UCM additions and
  corrections, dshare position overflow fix, build fixes for Android:
  0001-pcm-Preserve-period_event-in-snd_pcm_hw_sw_params-ca.patch
  0004-ucm-Add-ucm-files-for-DB820c-board.patch
  0005-ucm-bytcr-PlatformEnableSeq.conf-update-some-comment.patch
  0006-pcm-dshare-Fix-overflow-when-slave_hw_ptr-rolls-over.patch
  0007-test-latency-use-frame-bytes-correctly-in-writebuf.patch
  0008-conf-pcm-dmix-add-CHANNELS-argument.patch
  0009-Android-avoid-using-versionsort.patch
  0010-pcm-add-the-missing-strings.h-include.patch
  0011-alisp-add-the-missing-include.patch
  0012-add-snd_strlcpy-and-use-it-everywhere.patch
  0013-pcm-rate-plugin-fix-signess-in-snd_pcm_rate_avail_up.patch
- Drop -Iinclude/alsa from alsa.pc (bsc#1130333)
  0014-Drop-I-includedir-alsa-from-alsa.pc.patch

OBS-URL: https://build.opensuse.org/request/show/689240
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=245
2019-03-28 07:09:39 +00:00

45 lines
1.7 KiB
Diff

From 7cea8c156204ebae7c0dc60801dde5ddfa5bb7d0 Mon Sep 17 00:00:00 2001
From: Brendan Shanks <brendan.shanks@teradek.com>
Date: Mon, 11 Feb 2019 11:51:26 -0800
Subject: [PATCH 06/14] pcm: dshare: Fix overflow when slave_hw_ptr rolls over
boundary
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In snd_pcm_dshare_sync_area() when 'slave_hw_ptr' rolls over
'slave_boundary', the wrong variable is checked ('dshare->slave_hw_ptr' vs
the local 'slave_hw_ptr'). In some cases, this results in 'slave_hw_ptr'
not rolling over correctly. 'slave_size' and 'size' are then much too
large, and the for loop blocks for several minutes copying samples.
This was likely only triggered on 32-bit systems, since the PCM boundary
is computed based on LONG_MAX and is much larger on 64-bit systems.
This same change was made to pcm_dmix in commit
6c7f60f7a982fdba828e4530a9d7aa0aa2b704ae ("Fix boundary overlap”) from
June 2005.
Signed-off-by: Brendan Shanks <brendan.shanks@teradek.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
src/pcm/pcm_dshare.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/pcm/pcm_dshare.c b/src/pcm/pcm_dshare.c
index 2bb735fe1b46..f135b5dfce8b 100644
--- a/src/pcm/pcm_dshare.c
+++ b/src/pcm/pcm_dshare.c
@@ -121,7 +121,7 @@ static void snd_pcm_dshare_sync_area(snd_pcm_t *pcm)
*/
slave_hw_ptr -= slave_hw_ptr % dshare->slave_period_size;
slave_hw_ptr += dshare->slave_buffer_size;
- if (dshare->slave_hw_ptr > dshare->slave_boundary)
+ if (slave_hw_ptr >= dshare->slave_boundary)
slave_hw_ptr -= dshare->slave_boundary;
if (slave_hw_ptr < dshare->slave_appl_ptr)
slave_size = slave_hw_ptr + (dshare->slave_boundary - dshare->slave_appl_ptr);
--
2.16.4