summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTueidj <tueidj@hotmail.com>2013-08-28 21:33:00 +0800
committerChih-Wei Huang <cwhuang@linux.org.tw>2013-09-10 23:42:53 +0800
commit1c2c376341d016f7d7da43aa9909043a6738bd5d (patch)
tree50914834f5bd9469e28c066089d8a1ecea0ae08d
parente7c00cd2232af1260e083ccc0f007910851da261 (diff)
downloadplatform_hardware_libaudio-1c2c376341d016f7d7da43aa9909043a6738bd5d.tar.gz
platform_hardware_libaudio-1c2c376341d016f7d7da43aa9909043a6738bd5d.tar.bz2
platform_hardware_libaudio-1c2c376341d016f7d7da43aa9909043a6738bd5d.zip
Fix bad sleep time
The bad sleep time occurs when pcm_get_htimestamp() fails, leaving kernel_frames uninitialized and causing out->cur_write_threshold to be set to a very large value. The following patch ensures kernel_frames is initialized to a sane value, it should fix most of the "limiting sleep time" warnings and stuttering audio caused by sleeping too much.
-rw-r--r--audio_hw.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/audio_hw.c b/audio_hw.c
index 447f55f..334732e 100644
--- a/audio_hw.c
+++ b/audio_hw.c
@@ -715,8 +715,10 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
struct timespec time_stamp;
if (pcm_get_htimestamp(out->pcm,
(unsigned int *)&kernel_frames,
- &time_stamp) < 0)
+ &time_stamp) < 0) {
+ kernel_frames = 0; /* assume no space is available */
break;
+ }
kernel_frames = pcm_get_buffer_size(out->pcm) - kernel_frames;
if (kernel_frames > out->cur_write_threshold) {