From ee9ba87d9b964eb518a836c848907b1c83991e93 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Tue, 15 Nov 2011 19:04:03 -0800 Subject: pcm: fix underrun detection The changes made for mmap mode broke the underrun detection by pushing the stop_threshold beyong the buffer size. This caused the hw_ptr to go past the app_ptr and pcm_get_htimestamp() to report wrong values in case of underrun. Change-Id: Ic671fdd09f3afb8a301a391b48788fd9bc99322d --- pcm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pcm.c b/pcm.c index d12e5da..461eb5a 100644 --- a/pcm.c +++ b/pcm.c @@ -333,6 +333,9 @@ int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail, if (rc < 0) return -1; + if (pcm->mmap_status->state == PCM_STATE_XRUN) + return -1; + *tstamp = pcm->mmap_status->tstamp; if (tstamp->tv_sec == 0 && tstamp->tv_nsec == 0) return -1; @@ -540,7 +543,7 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, /* pick a high stop threshold - todo: does this need further tuning */ if (!config->stop_threshold) pcm->config.stop_threshold = sparams.stop_threshold = - config->period_count * config->period_size * 10; + config->period_count * config->period_size; else sparams.stop_threshold = config->stop_threshold; -- cgit v1.2.3