diff options
author | Glenn Kasten <gkasten@google.com> | 2015-06-04 14:00:22 -0700 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2015-06-08 12:08:24 -0700 |
commit | df9b397f73d8f063ff66e0fbf86ced075fe6d5aa (patch) | |
tree | d2b120bb45a4337ed2af90367d59258857184241 | |
parent | ff25010cb77455a46357d6dd012631a2599d7bf4 (diff) | |
download | android_frameworks_wilhelm-df9b397f73d8f063ff66e0fbf86ced075fe6d5aa.tar.gz android_frameworks_wilhelm-df9b397f73d8f063ff66e0fbf86ced075fe6d5aa.tar.bz2 android_frameworks_wilhelm-df9b397f73d8f063ff66e0fbf86ced075fe6d5aa.zip |
Remove redundant checks
Change-Id: I9f0f0063c3d8ba845c937aad97811d296ceaa494
-rw-r--r-- | src/android/AudioPlayer_to_android.cpp | 63 | ||||
-rw-r--r-- | src/android/AudioRecorder_to_android.cpp | 20 |
2 files changed, 8 insertions, 75 deletions
diff --git a/src/android/AudioPlayer_to_android.cpp b/src/android/AudioPlayer_to_android.cpp index 92b6d23..054eb87 100644 --- a/src/android/AudioPlayer_to_android.cpp +++ b/src/android/AudioPlayer_to_android.cpp @@ -949,17 +949,8 @@ SLresult android_audioPlayer_checkSourceSink(CAudioPlayer *pAudioPlayer) case SL_ANDROID_DATAFORMAT_PCM_EX: { const SLAndroidDataFormat_PCM_EX *df_pcm = (const SLAndroidDataFormat_PCM_EX *) pAudioSrc->pFormat; - switch (df_pcm->representation) { - case SL_ANDROID_PCM_REPRESENTATION_SIGNED_INT: - case SL_ANDROID_PCM_REPRESENTATION_UNSIGNED_INT: - case SL_ANDROID_PCM_REPRESENTATION_FLOAT: - df_representation = &df_pcm->representation; - break; - default: - SL_LOGE("Cannot create audio player: unsupported representation: %d", - df_pcm->representation); - return SL_RESULT_CONTENT_UNSUPPORTED; - } + // checkDataFormat() already checked representation + df_representation = &df_pcm->representation; } // SL_ANDROID_DATAFORMAT_PCM_EX - fall through to next test. case SL_DATAFORMAT_PCM: { const SLDataFormat_PCM *df_pcm = (const SLDataFormat_PCM *) pAudioSrc->pFormat; @@ -971,53 +962,9 @@ SLresult android_audioPlayer_checkSourceSink(CAudioPlayer *pAudioPlayer) return result; } - if (df_pcm->samplesPerSec < SL_SAMPLINGRATE_8 || - df_pcm->samplesPerSec > SL_SAMPLINGRATE_192) { - SL_LOGE("Cannot create audio player: unsupported sample rate %u milliHz", - (unsigned) df_pcm->samplesPerSec); - return SL_RESULT_CONTENT_UNSUPPORTED; - } - switch (df_pcm->bitsPerSample) { - case SL_PCMSAMPLEFORMAT_FIXED_8: - if (df_representation != NULL && - *df_representation != SL_ANDROID_PCM_REPRESENTATION_UNSIGNED_INT) { - goto default_err; - } - break; - case SL_PCMSAMPLEFORMAT_FIXED_16: - case SL_PCMSAMPLEFORMAT_FIXED_24: - if (df_representation != NULL && - *df_representation != SL_ANDROID_PCM_REPRESENTATION_SIGNED_INT) { - goto default_err; - } - break; - case SL_PCMSAMPLEFORMAT_FIXED_32: - if (df_representation != NULL - && *df_representation != SL_ANDROID_PCM_REPRESENTATION_SIGNED_INT - && *df_representation != SL_ANDROID_PCM_REPRESENTATION_FLOAT) { - goto default_err; - } - break; - // others - default: - default_err: - // this should have already been rejected by checkDataFormat - SL_LOGE("Cannot create audio player: unsupported sample bit depth %u", - (SLuint32)df_pcm->bitsPerSample); - return SL_RESULT_CONTENT_UNSUPPORTED; - } - switch (df_pcm->containerSize) { - case 8: - case 16: - case 24: - case 32: - break; - // others - default: - SL_LOGE("Cannot create audio player: unsupported container size %u", - (unsigned) df_pcm->containerSize); - return SL_RESULT_CONTENT_UNSUPPORTED; - } + // checkDataFormat() already checked sample rate + + // checkDataFormat() already checked bits per sample, container size, and representation // FIXME confirm the following // df_pcm->channelMask: the earlier platform-independent check and the diff --git a/src/android/AudioRecorder_to_android.cpp b/src/android/AudioRecorder_to_android.cpp index 0803d7f..555e27f 100644 --- a/src/android/AudioRecorder_to_android.cpp +++ b/src/android/AudioRecorder_to_android.cpp @@ -167,28 +167,14 @@ SLresult android_audioRecorder_checkSourceSink(CAudioRecorder* ar) { case SL_ANDROID_DATAFORMAT_PCM_EX: { const SLAndroidDataFormat_PCM_EX *df_pcm = (SLAndroidDataFormat_PCM_EX *) pAudioSnk->pFormat; - switch (df_pcm->representation) { - case SL_ANDROID_PCM_REPRESENTATION_SIGNED_INT: - case SL_ANDROID_PCM_REPRESENTATION_UNSIGNED_INT: - case SL_ANDROID_PCM_REPRESENTATION_FLOAT: - df_representation = &df_pcm->representation; - break; - default: - SL_LOGE("Cannot create audio recorder: unsupported representation: %d", - df_pcm->representation); - return SL_RESULT_CONTENT_UNSUPPORTED; - } + // checkDataFormat() already checked representation + df_representation = &df_pcm->representation; } // SL_ANDROID_DATAFORMAT_PCM_EX - fall through to next test. case SL_DATAFORMAT_PCM: { const SLDataFormat_PCM *df_pcm = (const SLDataFormat_PCM *) pAudioSnk->pFormat; // FIXME validate channel mask and number of channels - if (df_pcm->samplesPerSec < SL_SAMPLINGRATE_8 || - df_pcm->samplesPerSec > SL_SAMPLINGRATE_192) { - SL_LOGE("Cannot create audio recorder: unsupported sample rate %u milliHz", - (unsigned) df_pcm->samplesPerSec); - return SL_RESULT_CONTENT_UNSUPPORTED; - } + // checkDataFormat already checked sample rate ar->mNumChannels = df_pcm->numChannels; ar->mSampleRateMilliHz = df_pcm->samplesPerSec; // Note: bad field name in SL ES |