Fix capture/periodic overrun bug.
PATCH 1/1 Fix capture/periodic overrun bug.
Hi all,
this is a bug fix for my ALSA driver I posted in August. Since then I hadn't the time to look at it, but some days ago I took some time and found the reason why there are so many overruns while capturing. Furthermore, this patch removes the one "heavy" printk for capture debugging.
From: Joachim Foerster <[email protected]>
We have to do fairly accurate counting of the minimal periods, instead of being lazy and just setting the number to zero as soon as one period elapses.
--- sound/drivers/ml403-ac97cr.c | 6 ++---- sound/drivers/pcm-indirect2.c | 20 ++------------------ 2 files changed, 4 insertions(+), 22 deletions(-)
sound/drivers/ml403-ac97cr.c +2 -4
@@ -28,11 +28,9 @@* accesses to a minimum, because after a variable amount of accesses, the AC97 * controller doesn't raise the register access finished bit anymore ... * -* - Capture support works - basically, but after ~30s (with rates > ~20kHz) -* ALSA stops reading captured samples from the intermediate buffer and -* therefore a overrun happens - ATM I don't know what's wrong. -* * - Playback support seems to be pretty stable - no issues here. +* - Capture support "works" now, too. Overruns don't happen any longer so often. +* But there might still be some ... */ #include <sound/driver.h>
sound/drivers/pcm-indirect2.c +2 -18
@@ -403,7 +403,7 @@ snd_pcm_indirect2_playback_interrupt(struct snd_pcm_substream *substream, rec->min_multiple); rec->mul_elapsed++;#endif - rec->min_periods =0 ; + rec->min_periods = (rec->min_periods % rec->min_multiple);snd_pcm_period_elapsed (substream); } }
@@ -568,24 +568,8 @@ snd_pcm_indirect2_capture_interrupt(struct snd_pcm_substream *substream, rec->mul_elapsed_real += (rec->min_periods / rec->min_multiple); rec->mul_elapsed++; - -if (!(rec->mul_elapsed %4 )) { -struct snd_pcm_runtime *runtime = substream->runtime; -unsigned int appl_ptr = -frames_to_bytes (runtime, - (unsigned int )runtime->control-> - appl_ptr) % rec->sw_buffer_size; -int diff = rec->sw_data - appl_ptr; -if (diff <0 ) - diff += rec->sw_buffer_size; -snd_printk (KERN_DEBUG -"STAT: mul_elapsed: %d, sw_data: %u, " -"appl_ptr (bytes): %u, diff: %d\n" , - rec->mul_elapsed, rec->sw_data, appl_ptr, - diff); - }#endif - rec->min_periods =0 ; + rec->min_periods = (rec->min_periods % rec->min_multiple);snd_pcm_period_elapsed (substream); } }
Signature · 1 line
1.5.2.5
At Fri, 02 Nov 2007 18:52:19 +0100,
Quoted 9 lines · Joachim Foerster
Hi all,
this is a bug fix for my ALSA driver I posted in August. Since then I hadn't the time to look at it, but some days ago I took some time and found the reason why there are so many overruns while capturing. Furthermore, this patch removes the one "heavy" printk for capture debugging.
Quoted 7 lines
From: Joachim Foerster <[email protected]>
We have to do fairly accurate counting of the minimal periods, instead of being lazy and just setting the number to zero as soon as one period elapses.
Signed-off-by Joachim Foerster <[email protected]>
Oh, it seems that your patch was lost in the patch queue before ALSA 1.0.15 release. Sorry, I applied the last one now to ALSA HG tree together with this one.
The patch to arch/ppc/syslib/virtex_device.c isn't still applied (because it's outside the ALSA HG tree). For applying this to alsa git tree, Jaroslav would need to apply manually.
Jaroslav, could you add it please?
... Or, feel free to apply that patch to ppc tree separately. It shouldn't break anything, at least :)
Thanks,
Takashi
Quoted 9 lines · Takashi Iwai
Oh, it seems that your patch was lost in the patch queue before ALSA 1.0.15 release. Sorry, I applied the last one now to ALSA HG tree together with this one.
The patch to
arch/ppc/syslib/virtex_device.cisn't still applied (because it's outside the ALSA HG tree). For applying this to alsa git tree, Jaroslav would need to apply manually.Jaroslav, could you add it please?
Please don't send this change in through the alsa git tree. arch/ppc is semi frozen and changes should really go in via paulus' tree.
I'll take another look at it and see if I can get it in.
Cheers,
g.
Signature · 4 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. [email protected] (403) 399-0195
At Mon, 5 Nov 2007 08:59:10 -0700,
Quoted 10 lines · Grant Likely
Quoted 8 lines · Takashi Iwai
Oh, it seems that your patch was lost in the patch queue before ALSA 1.0.15 release. Sorry, I applied the last one now to ALSA HG tree together with this one.
The patch to
arch/ppc/syslib/virtex_device.cisn't still applied (because it's outside the ALSA HG tree). For applying this to alsa git tree, Jaroslav would need to apply manually.
Quoted 6 lines
Quoted 1 line
Jaroslav, could you add it please?
Please don't send this change in through the alsa git tree.
arch/ppcis semi frozen and changes should really go in via paulus' tree.I'll take another look at it and see if I can get it in.
OK, thanks for information. I'll be happy to pass it to you :)
Takashi