diff options
author | Glenn Kasten <gkasten@google.com> | 2012-06-25 11:49:27 -0700 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2012-07-13 09:05:50 -0700 |
commit | 04cd0186305e2b59d23c9147787046c6662029cc (patch) | |
tree | 5c2da34c5489ab0741729ba6b66cec980c384720 | |
parent | 5f0033d27b75fead593ed7ca2b86f5b6f5adf6cc (diff) | |
download | frameworks_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
-rw-r--r-- | media/libmedia/AudioRecord.cpp | 5 | ||||
-rw-r--r-- | media/libmedia/AudioTrack.cpp | 5 |
2 files changed, 10 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) { diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index 9fd78b3..177359b 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -54,6 +54,11 @@ status_t AudioTrack::getMinFrameCount( audio_stream_type_t streamType, uint32_t sampleRate) { + if (frameCount == NULL) return BAD_VALUE; + + // default to 0 in case of error + *frameCount = 0; + // FIXME merge with similar code in createTrack_l(), except we're missing // some information here that is available in createTrack_l(): // audio_io_handle_t output |