diff options
author | Eric Laurent <elaurent@google.com> | 2012-06-04 13:45:29 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2012-06-04 14:27:56 -0700 |
commit | ab9071b8d1b375418eb797c9a790da71de644344 (patch) | |
tree | 637a5322ed80b9de92433ed9851302e45d78b727 /services/audioflinger | |
parent | 399930859a75d806ce0ef124ac22025ae4ef0549 (diff) | |
download | frameworks_av-ab9071b8d1b375418eb797c9a790da71de644344.zip frameworks_av-ab9071b8d1b375418eb797c9a790da71de644344.tar.gz frameworks_av-ab9071b8d1b375418eb797c9a790da71de644344.tar.bz2 |
audioflinger: fix active sleep time calculation.
When an audioTrack underruns, the audioflinger mixer thread
sleeps for a certain time to give the app a chance to recover.
This time is based on the reported audio HAL latency.
Some audio HALs implementing deep buffering have a variable
latency and this creates a problem if the sleep time is cached
when the output stream is opened and not updated afterwards.
This change derives the active sleep time from the mix buffer
framecount instead of the latency. This is more conservative
but works for variable latency.
Bug 6588525.
Change-Id: Ia892fc290fe06f836565c3ae15f7a2ce026c88c6
Diffstat (limited to 'services/audioflinger')
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index bf40886..0ebea76 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -2114,14 +2114,7 @@ audio_stream_t* AudioFlinger::PlaybackThread::stream() const uint32_t AudioFlinger::PlaybackThread::activeSleepTimeUs() const { - // A2DP output latency is not due only to buffering capacity. It also reflects encoding, - // decoding and transfer time. So sleeping for half of the latency would likely cause - // underruns - if (audio_is_a2dp_device((audio_devices_t)mDevice)) { - return (uint32_t)((uint32_t)((mNormalFrameCount * 1000) / mSampleRate) * 1000); - } else { - return (uint32_t)(mOutput->stream->get_latency(mOutput->stream) * 1000) / 2; - } + return (uint32_t)((uint32_t)((mNormalFrameCount * 1000) / mSampleRate) * 1000); } status_t AudioFlinger::PlaybackThread::setSyncEvent(const sp<SyncEvent>& event) |