Allow getInputBufferSize for compressed formats
For cases where the primary hardware device does not support querying
the buffer size for a compressed format, the implementation falls back
to querying buffer size using PCM. This should be improved later to use
a format -> nominal buffer size lookup.
Change-Id: I0feff62651f2b39f6f53cc1b6ed62525cd2bcb78
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index f55b1c9..a1fca98 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -1889,7 +1889,7 @@
return 0;
}
if ((sampleRate == 0) ||
- !audio_is_valid_format(format) || !audio_has_proportional_frames(format) ||
+ !audio_is_valid_format(format) ||
!audio_is_input_channel(channelMask)) {
return 0;
}
@@ -1912,6 +1912,10 @@
std::vector<audio_format_t> formats = {format};
if (format != AUDIO_FORMAT_PCM_16_BIT) {
+ // For compressed format, buffer size may be queried using PCM. Allow this for compatibility
+ // in cases the primary hw dev does not support the format.
+ // TODO: replace with a table of formats and nominal buffer sizes (based on nominal bitrate
+ // and codec frame size).
formats.push_back(AUDIO_FORMAT_PCM_16_BIT);
}