summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioRecord.cpp
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-06-25 11:49:27 -0700
committerGlenn Kasten <gkasten@google.com>2012-07-13 09:05:50 -0700
commit04cd0186305e2b59d23c9147787046c6662029cc (patch)
tree5c2da34c5489ab0741729ba6b66cec980c384720 /media/libmedia/AudioRecord.cpp
parent5f0033d27b75fead593ed7ca2b86f5b6f5adf6cc (diff)
downloadframeworks_av-04cd0186305e2b59d23c9147787046c6662029cc.zip
frameworks_av-04cd0186305e2b59d23c9147787046c6662029cc.tar.gz
frameworks_av-04cd0186305e2b59d23c9147787046c6662029cc.tar.bz2
getMinFrameCount error handling
Convention is for "get" APIs that directly return status_t and indirectly return a value via a pointer, to return BAD_VALUE if the pointer is NULL. Also indirectly return 0 for other errors. Change-Id: I1599f20ecb26e9723f9fb384ffbf911ff3a2ce1c
Diffstat (limited to 'media/libmedia/AudioRecord.cpp')
-rw-r--r--media/libmedia/AudioRecord.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index d3c0b2b..13e60a7 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -41,6 +41,11 @@ status_t AudioRecord::getMinFrameCount(
audio_format_t format,
audio_channel_mask_t channelMask)
{
+ if (frameCount == NULL) return BAD_VALUE;
+
+ // default to 0 in case of error
+ *frameCount = 0;
+
size_t size = 0;
if (AudioSystem::getInputBufferSize(sampleRate, format, channelMask, &size)
!= NO_ERROR) {