summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2010-11-18 09:43:52 +0100
committerTakashi Iwai <tiwai@suse.de>2010-11-22 08:14:06 +0100
commit59ff878ffb26bc0be812ca8295799164f413ae88 (patch)
treed3e8c044e3094fb95027fe669dc392dedb1d2d1c /sound
parentALSA: oxygen: support for period wakeup disabling (diff)
downloadlinux-59ff878ffb26bc0be812ca8295799164f413ae88.tar.xz
linux-59ff878ffb26bc0be812ca8295799164f413ae88.zip
ALSA: pcm: detect xruns in no-period-wakeup mode
When period wakeups are disabled, successive calls to the pointer update function do not have a maximum allowed distance, so xruns cannot be detected with the pointer value only. To detect xruns, compare the actually elapsed time with the time that should have theoretically elapsed since the last update. When the hardware pointer has wrapped around due to an xrun, the actually elapsed time will be too big by about hw_ptr_buffer_jiffies. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/core/pcm_lib.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index bc57501c584a..e9debaabf376 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -374,9 +374,23 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
(unsigned long)runtime->hw_ptr_base);
}
- /* without period interrupts, there are no regular pointer updates */
- if (runtime->no_period_wakeup)
+ if (runtime->no_period_wakeup) {
+ /*
+ * Without regular period interrupts, we have to check
+ * the elapsed time to detect xruns.
+ */
+ jdelta = jiffies - runtime->hw_ptr_jiffies;
+ hdelta = jdelta - delta * HZ / runtime->rate;
+ while (hdelta > runtime->hw_ptr_buffer_jiffies / 2 + 1) {
+ delta += runtime->buffer_size;
+ hw_base += runtime->buffer_size;
+ if (hw_base >= runtime->boundary)
+ hw_base = 0;
+ new_hw_ptr = hw_base + pos;
+ hdelta -= runtime->hw_ptr_buffer_jiffies;
+ }
goto no_delta_check;
+ }
/* something must be really wrong */
if (delta >= runtime->buffer_size + runtime->period_size) {