| 1 |
From: Takashi Iwai <tiwai@suse.de>
|
| 2 |
Date: Thu, 19 Mar 2009 09:08:49 +0000 (+0100)
|
| 3 |
Subject: ALSA: pcm - Fix delta calculation at boundary overlap
|
| 4 |
X-Git-Url: http://git.alsa-project.org/?p=alsa-kernel.git;a=commitdiff_plain;h=09a067199b6caa61818fc04f4759048dff13b21c
|
| 5 |
|
| 6 |
ALSA: pcm - Fix delta calculation at boundary overlap
|
| 7 |
|
| 8 |
When the hw_ptr_interrupt reaches the boundary, it must check whether
|
| 9 |
the hw_base was already lapped and corret the delta value appropriately.
|
| 10 |
|
| 11 |
Also, rebasing the hw_ptr needs a correction because buffer_size isn't
|
| 12 |
always aligned to period_size.
|
| 13 |
|
| 14 |
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
| 15 |
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
| 16 |
---
|
| 17 |
|
| 18 |
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
|
| 19 |
index 92ed6d8..063c675 100644
|
| 20 |
--- a/sound/core/pcm_lib.c
|
| 21 |
+++ b/sound/core/pcm_lib.c
|
| 22 |
@@ -221,8 +221,11 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream)
|
| 23 |
new_hw_ptr = hw_base + pos;
|
| 24 |
hw_ptr_interrupt = runtime->hw_ptr_interrupt + runtime->period_size;
|
| 25 |
delta = new_hw_ptr - hw_ptr_interrupt;
|
| 26 |
- if (hw_ptr_interrupt == runtime->boundary)
|
| 27 |
- hw_ptr_interrupt = 0;
|
| 28 |
+ if (hw_ptr_interrupt >= runtime->boundary) {
|
| 29 |
+ hw_ptr_interrupt %= runtime->boundary;
|
| 30 |
+ if (!hw_base) /* hw_base was already lapped; recalc delta */
|
| 31 |
+ delta = new_hw_ptr - hw_ptr_interrupt;
|
| 32 |
+ }
|
| 33 |
if (delta < 0) {
|
| 34 |
delta += runtime->buffer_size;
|
| 35 |
if (delta < 0) {
|
| 36 |
@@ -233,6 +236,8 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream)
|
| 37 |
(long)hw_ptr_interrupt);
|
| 38 |
/* rebase to interrupt position */
|
| 39 |
hw_base = new_hw_ptr = hw_ptr_interrupt;
|
| 40 |
+ /* align hw_base to buffer_size */
|
| 41 |
+ hw_base -= hw_base % runtime->buffer_size;
|
| 42 |
delta = 0;
|
| 43 |
} else {
|
| 44 |
hw_base += runtime->buffer_size;
|