summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioSystem.cpp
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2014-01-09 17:41:02 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-01-09 17:41:03 +0000
commitf344c6cef51df9974640557f7baccb537492fa54 (patch)
tree6917f715f8c2919de8998b6e94a792c251e14b31 /media/libmedia/AudioSystem.cpp
parent9d37ea95c51157cfc493409d18ab07df0ec0ad58 (diff)
parent5446e541367061b53f45f3fd4600f9060680bca3 (diff)
downloadframeworks_av-f344c6cef51df9974640557f7baccb537492fa54.zip
frameworks_av-f344c6cef51df9974640557f7baccb537492fa54.tar.gz
frameworks_av-f344c6cef51df9974640557f7baccb537492fa54.tar.bz2
Merge "Cleanup AudioSystem::getInputBufferSize error handling and caching"
Diffstat (limited to 'media/libmedia/AudioSystem.cpp')
-rw-r--r--media/libmedia/AudioSystem.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index e37888b..4580030 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -40,10 +40,10 @@ audio_error_callback AudioSystem::gAudioErrorCallback = NULL;
DefaultKeyedVector<audio_io_handle_t, AudioSystem::OutputDescriptor *> AudioSystem::gOutputs(0);
// Cached values for recording queries, all protected by gLock
-uint32_t AudioSystem::gPrevInSamplingRate = 16000;
-audio_format_t AudioSystem::gPrevInFormat = AUDIO_FORMAT_PCM_16_BIT;
-audio_channel_mask_t AudioSystem::gPrevInChannelMask = AUDIO_CHANNEL_IN_MONO;
-size_t AudioSystem::gInBuffSize = 0;
+uint32_t AudioSystem::gPrevInSamplingRate;
+audio_format_t AudioSystem::gPrevInFormat;
+audio_channel_mask_t AudioSystem::gPrevInChannelMask;
+size_t AudioSystem::gInBuffSize = 0; // zero indicates cache is invalid
// establish binder interface to AudioFlinger service
@@ -369,6 +369,12 @@ status_t AudioSystem::getInputBufferSize(uint32_t sampleRate, audio_format_t for
return PERMISSION_DENIED;
}
inBuffSize = af->getInputBufferSize(sampleRate, format, channelMask);
+ if (inBuffSize == 0) {
+ ALOGE("AudioSystem::getInputBufferSize failed sampleRate %d format %x channelMask %x",
+ sampleRate, format, channelMask);
+ return BAD_VALUE;
+ }
+ // A benign race is possible here: we could overwrite a fresher cache entry
gLock.lock();
// save the request params
gPrevInSamplingRate = sampleRate;