Fix Offload playback in AudioFlinger
This fixes Offload playback regression introduced by adding
flexible format to mSinkBuffer. Test case is AAC file playback.
Bug: 13450717
Change-Id: I0fa11978295ed4793be90c565e5b8abedf156914
Signed-off-by: Andy Hung <hunga@google.com>
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 8aee194..1c46c27 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -1786,8 +1786,9 @@
// Originally this was int16_t[] array, need to remove legacy implications.
free(mSinkBuffer);
mSinkBuffer = NULL;
- const size_t sinkBufferSize = mNormalFrameCount * mChannelCount
- * audio_bytes_per_sample(mFormat);
+ // For sink buffer size, we use the frame size from the downstream sink to avoid problems
+ // with non PCM formats for compressed music, e.g. AAC, and Offload threads.
+ const size_t sinkBufferSize = mNormalFrameCount * mFrameSize;
(void)posix_memalign(&mSinkBuffer, 32, sinkBufferSize);
// We resize the mMixerBuffer according to the requirements of the sink buffer which