aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2010-11-18 03:43:52 -0500
committerTakashi Iwai <tiwai@suse.de>2010-11-22 02:14:06 -0500
commit59ff878ffb26bc0be812ca8295799164f413ae88 (patch)
treed3e8c044e3094fb95027fe669dc392dedb1d2d1c
parent075140ea8bf1405057c072a84ccf4e0d3f2c76f5 (diff)
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>
-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 bc57501c584..e9debaabf37 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,
374 (unsigned long)runtime->hw_ptr_base); 374 (unsigned long)runtime->hw_ptr_base);
375 } 375 }
376 376
377 /* without period interrupts, there are no regular pointer updates */ 377 if (runtime->no_period_wakeup) {
378 if (runtime->no_period_wakeup) 378 /*
379 * Without regular period interrupts, we have to check
380 * the elapsed time to detect xruns.
381 */
382 jdelta = jiffies - runtime->hw_ptr_jiffies;
383 hdelta = jdelta - delta * HZ / runtime->rate;
384 while (hdelta > runtime->hw_ptr_buffer_jiffies / 2 + 1) {
385 delta += runtime->buffer_size;
386 hw_base += runtime->buffer_size;
387 if (hw_base >= runtime->boundary)
388 hw_base = 0;
389 new_hw_ptr = hw_base + pos;
390 hdelta -= runtime->hw_ptr_buffer_jiffies;
391 }
379 goto no_delta_check; 392 goto no_delta_check;
393 }
380 394
381 /* something must be really wrong */ 395 /* something must be really wrong */
382 if (delta >= runtime->buffer_size + runtime->period_size) { 396 if (delta >= runtime->buffer_size + runtime->period_size) {