aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2011-11-15 19:04:03 -0800
committerSimon Wilson <simonwilson@google.com>2011-11-16 14:26:33 -0800
commitee9ba87d9b964eb518a836c848907b1c83991e93 (patch)
treeb432f63875e68fa5593ee319e591fb412b2ae07e
parent52510160f90bb583f4eaf1392533b8a2108323c7 (diff)
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
-rw-r--r--pcm.c5
1 files changed, 4 insertions, 1 deletions
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;