aaudio: fix callback size for Legacy input
Set the size of the callback buffer based on the device format
instead of the app format.
Bug: 149249791
Test: atest CtsNativeMediaAAudioTestCases
Change-Id: I0dc5724109a802eea15100782c18986a64e6acd2
diff --git a/media/libaaudio/src/legacy/AudioStreamTrack.cpp b/media/libaaudio/src/legacy/AudioStreamTrack.cpp
index 00963d6..d54d043 100644
--- a/media/libaaudio/src/legacy/AudioStreamTrack.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamTrack.cpp
@@ -196,7 +196,10 @@
// We may need to pass the data through a block size adapter to guarantee constant size.
if (mCallbackBufferSize != AAUDIO_UNSPECIFIED) {
- int callbackSizeBytes = getBytesPerFrame() * mCallbackBufferSize;
+ // This may need to change if we add format conversion before
+ // the block size adaptation.
+ mBlockAdapterBytesPerFrame = getBytesPerFrame();
+ int callbackSizeBytes = mBlockAdapterBytesPerFrame * mCallbackBufferSize;
mFixedBlockReader.open(callbackSizeBytes);
mBlockAdapter = &mFixedBlockReader;
} else {