All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shine Liu <shinel@foxmail.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de
Subject: [PATCH] pcm_lib.c: Fixed inaccurate calculation of hw_ptr_interrupt in snd_pcm_update_hw_ptr_interrupt function
Date: Wed, 19 Aug 2009 18:22:19 +0800	[thread overview]
Message-ID: <1250677339.3516.17.camel@shinel> (raw)

There's no restriction on that the runtime->period_size should be the
multiplicator of the runtime->buffer_size in current kernel code.

So "hw_ptr_interrupt = runtime->hw_ptr_interrupt +
runtime->period_size;" is not always the trueth.

I've encounter the problem of this bug, the kernel told me "PCM:
Unexpected hw_pointer value (stream=0, pos=8, intr_ptr=16384)".

The period_size and buffer_size I used was 0x800 and 0x3e80 when the bug
occured.

Following patch will fix the bug.



Signed-off-by: Shine Liu <shinel@foxmail.com>
-----------------------------------------------------------------------

--- a/sound/core/pcm_lib.c	2009-08-14 06:43:34.000000000 +0800
+++ b/sound/core/pcm_lib.c	2009-08-19 17:59:00.000000000 +0800
@@ -248,6 +248,12 @@
 	hw_base = runtime->hw_ptr_base;
 	new_hw_ptr = hw_base + pos;
 	hw_ptr_interrupt = runtime->hw_ptr_interrupt + runtime->period_size;
+	/* if the period_size is not the multiplicator of the 
+ 	 * buffer_size, the hw_ptr_interrupt calculated above 
+ 	 * may not be correct, should be fixed. 
+ 	 */
+	if(hw_ptr_interrupt > hw_base + runtime->buffer_size)
+		hw_ptr_interrupt = hw_base + runtime->buffer_size;
 	delta = new_hw_ptr - hw_ptr_interrupt;
 	if (hw_ptr_interrupt >= runtime->boundary) {
 		hw_ptr_interrupt -= runtime->boundary;

             reply	other threads:[~2009-08-19 10:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-19 10:22 Shine Liu [this message]
2009-08-19 10:34 ` [PATCH] pcm_lib.c: Fixed inaccurate calculation of hw_ptr_interrupt in snd_pcm_update_hw_ptr_interrupt function Takashi Iwai
2009-08-19 10:59   ` Shine Liu
2009-08-19 12:05     ` Takashi Iwai
2009-08-19 12:48       ` Shine Liu
2009-08-19 12:53         ` Takashi Iwai
2009-08-19 13:01           ` Shine Liu
2009-08-20  7:20           ` Shine Liu
2009-08-20  8:42             ` Clemens Ladisch
2009-08-20 15:02       ` [PATCH] ASoC: S3C24XX : Align the peroid size to the buffer size Shine Liu
2009-08-20 18:44         ` Mark Brown

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=1250677339.3516.17.camel@shinel \
    --to=shinel@foxmail.com \
    --cc=alsa-devel@alsa-project.org \
    --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 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.