At Wed, 19 Aug 2009 18:22:19 +0800, Shine Liu wrote:
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.
The hw_ptr_interrupt is the expected position where the current irq is issued. So, the current code should be correct -- it's simply increased in the size of period_size.
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.
Does the problem happen with the latest driver code (as found in sound git tree or alsa-driver-snapshot)? If yes, we'd need more further analysis, e.g. by enabling some xrun_debug flags.
thanks,
Takashi
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)
delta = new_hw_ptr - hw_ptr_interrupt; if (hw_ptr_interrupt >= runtime->boundary) { hw_ptr_interrupt -= runtime->boundary;hw_ptr_interrupt = hw_base + runtime->buffer_size;