summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2013-06-03 15:00:29 -0700
committerGlenn Kasten <gkasten@google.com>2013-06-04 16:42:58 -0700
commitbb6f0a0bb413817d707cfb4c4a30847fda520787 (patch)
tree4fa6837f6302ae59367583d52565e70f3479c140 /media
parent587f8425a9522b2d0fe1ae0d211a259ec83786d1 (diff)
downloadframeworks_av-bb6f0a0bb413817d707cfb4c4a30847fda520787.zip
frameworks_av-bb6f0a0bb413817d707cfb4c4a30847fda520787.tar.gz
frameworks_av-bb6f0a0bb413817d707cfb4c4a30847fda520787.tar.bz2
Fix underruns when sample rate != native sample rate
This forces a minimum of 3 application buffers when the sample rates don't match, using the normal mixer and low latency HAL. There is still an issue that the latency() varies depending on whether screen was off or on at the time of creating the AudioTrack. With screen on: I/AudioTrack( 2028): afFrameCount=960, minBufCount=2, afSampleRate=48000, afLatency=50 I/AudioTrack( 2028): minFrameCount: 2646, afFrameCount=960, minBufCount=3, sampleRate=44100, afSampleRate=48000, afLatency=50 With screen off: I/AudioTrack( 2817): afFrameCount=960, minBufCount=4, afSampleRate=48000, afLatency=84 I/AudioTrack( 2817): minFrameCount: 3528, afFrameCount=960, minBufCount=4, sampleRate=44100, afSampleRate=48000, afLatency=84 Change-Id: Ib45515edff2afcd672dda34881b658c800ffc25a
Diffstat (limited to 'media')
-rw-r--r--media/libmedia/AudioTrack.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index ff52b28..77fc6f6 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -861,8 +861,10 @@ status_t AudioTrack::createTrack_l(
// Ensure that buffer depth covers at least audio hardware latency
uint32_t minBufCount = afLatency / ((1000 * afFrameCount)/afSampleRate);
- if (minBufCount < 2) {
- minBufCount = 2;
+ ALOGV("afFrameCount=%d, minBufCount=%d, afSampleRate=%u, afLatency=%d",
+ afFrameCount, minBufCount, afSampleRate, afLatency);
+ if (minBufCount <= 2) {
+ minBufCount = sampleRate == afSampleRate ? 2 : 3;
}
size_t minFrameCount = (afFrameCount*sampleRate*minBufCount)/afSampleRate;