From 8ba90326d683b035d99e24db669093e4602a7149 Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Wed, 30 Oct 2013 11:29:27 -0700 Subject: Remove default channel mask for AudioTrack It doesn't make sense to have a default channel mask, since the caller needs to know what format it will use when supplying data, and there is currently no API to return the channel mask of an AudioTrack. audio_is_output_channel() does not allow 0, so it will catch any stragglers (I'm not aware of any). Also move channel mask validation earlier. Change-Id: Ia018ded8711455581a2a935f37432b049422d492 --- media/libmedia/AudioTrack.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'media') diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index df58909..8319dcd 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -250,9 +250,6 @@ status_t AudioTrack::set( if (format == AUDIO_FORMAT_DEFAULT) { format = AUDIO_FORMAT_PCM_16_BIT; } - if (channelMask == 0) { - channelMask = AUDIO_CHANNEL_OUT_STEREO; - } // validate parameters if (!audio_is_valid_format(format)) { @@ -260,6 +257,11 @@ status_t AudioTrack::set( return BAD_VALUE; } + if (!audio_is_output_channel(channelMask)) { + ALOGE("Invalid channel mask %#x", channelMask); + return BAD_VALUE; + } + // AudioFlinger does not currently support 8-bit data in shared memory if (format == AUDIO_FORMAT_PCM_8_BIT && sharedBuffer != 0) { ALOGE("8-bit data in shared memory is not supported"); @@ -282,10 +284,6 @@ status_t AudioTrack::set( flags = (audio_output_flags_t)(flags &~AUDIO_OUTPUT_FLAG_DEEP_BUFFER); } - if (!audio_is_output_channel(channelMask)) { - ALOGE("Invalid channel mask %#x", channelMask); - return BAD_VALUE; - } mChannelMask = channelMask; uint32_t channelCount = popcount(channelMask); mChannelCount = channelCount; -- cgit v1.1