summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/Threads.cpp
diff options
context:
space:
mode:
authorPhil Burk <philburk@google.com>2015-07-14 09:42:29 -0700
committerLajos Molnar <lajos@google.com>2015-07-17 20:56:04 +0000
commitca5e6143740299c877d69e97f7968cd04476d32c (patch)
tree50101b57406c5abce066ec90120d91d3dfd0152b /services/audioflinger/Threads.cpp
parentbc24bb8a552097e7975d0c16fad80158b542ba62 (diff)
downloadframeworks_av-ca5e6143740299c877d69e97f7968cd04476d32c.zip
frameworks_av-ca5e6143740299c877d69e97f7968cd04476d32c.tar.gz
frameworks_av-ca5e6143740299c877d69e97f7968cd04476d32c.tar.bz2
AudioFlinger: fix repeated underruns for compressed audio
The AudioFlinger kept pausing the audio when playing compressed AC3 or DTS. This caused pause/resume loops that were hard to break out of. The AudioFlinger was thinking that the compressed audio was PCM because the HAL was in PCM mode playing SPDIF data bursts. It also thought that EAC3 was at 192000 Hz instead of 48000 Hz because the data bursts are played at a higher rate. This CL adds more calls to the shim that separates the AudioFlinger. Now the AudioFlinger gets information about the HAL sample rate, channel masks and format from the shim instead of calling the HAL directly. The AudioFlinger now uses a different threshold for detecting underruns when the audio is compressed. Bug: 19938315 Bug: 20891646 Change-Id: Ib16f539346d1c7a273ea4feb3d3afcc3dc60237d Signed-off-by: Phil Burk <philburk@google.com>
Diffstat (limited to 'services/audioflinger/Threads.cpp')
-rw-r--r--services/audioflinger/Threads.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index d9f1a83..c360051 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -2081,8 +2081,8 @@ int AudioFlinger::PlaybackThread::asyncCallback(stream_callback_event_t event,
void AudioFlinger::PlaybackThread::readOutputParameters_l()
{
// unfortunately we have no way of recovering from errors here, hence the LOG_ALWAYS_FATAL
- mSampleRate = mOutput->stream->common.get_sample_rate(&mOutput->stream->common);
- mChannelMask = mOutput->stream->common.get_channels(&mOutput->stream->common);
+ mSampleRate = mOutput->getSampleRate();
+ mChannelMask = mOutput->getChannelMask();
if (!audio_is_output_channel(mChannelMask)) {
LOG_ALWAYS_FATAL("HAL channel mask %#x not valid for output", mChannelMask);
}
@@ -2092,8 +2092,12 @@ void AudioFlinger::PlaybackThread::readOutputParameters_l()
mChannelMask);
}
mChannelCount = audio_channel_count_from_out_mask(mChannelMask);
+
+ // Get actual HAL format.
mHALFormat = mOutput->stream->common.get_format(&mOutput->stream->common);
- mFormat = mHALFormat;
+ // Get format from the shim, which will be different than the HAL format
+ // if playing compressed audio over HDMI passthrough.
+ mFormat = mOutput->getFormat();
if (!audio_is_valid_format(mFormat)) {
LOG_ALWAYS_FATAL("HAL format %#x not valid for output", mFormat);
}
@@ -4559,9 +4563,10 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::DirectOutputThread::prep
// app does not call stop() and relies on underrun to stop:
// hence the test on (track->mRetryCount > 1).
// If retryCount<=1 then track is about to underrun and be removed.
+ // Do not use a high threshold for compressed audio.
uint32_t minFrames;
if ((track->sharedBuffer() == 0) && !track->isStopping_1() && !track->isPausing()
- && (track->mRetryCount > 1)) {
+ && (track->mRetryCount > 1) && audio_is_linear_pcm(mFormat)) {
minFrames = mNormalFrameCount;
} else {
minFrames = 1;
@@ -4650,6 +4655,9 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::DirectOutputThread::prep
// it will then automatically call start() when data is available
android_atomic_or(CBLK_DISABLED, &cblk->mFlags);
} else if (last) {
+ ALOGW("pause because of UNDERRUN, framesReady = %zu,"
+ "minFrames = %u, mFormat = %#x",
+ track->framesReady(), minFrames, mFormat);
mixerStatus = MIXER_TRACKS_ENABLED;
if (mHwSupportsPause && !mHwPaused && !mStandby) {
doHwPause = true;