diff options
author | ilewis <inl@google.com> | 2016-02-12 13:15:01 -0800 |
---|---|---|
committer | Ian Ni-Lewis <ilewis@google.com> | 2016-02-16 17:07:21 +0000 |
commit | 28340d1d9199b789f0db015680b008c98084f0b7 (patch) | |
tree | 467daa47b1ea22f86c53e234a23ef82efc9d454a | |
parent | d67d2393c62827a91f84b1eed83a789387cff032 (diff) | |
download | android_frameworks_wilhelm-28340d1d9199b789f0db015680b008c98084f0b7.tar.gz android_frameworks_wilhelm-28340d1d9199b789f0db015680b008c98084f0b7.tar.bz2 android_frameworks_wilhelm-28340d1d9199b789f0db015680b008c98084f0b7.zip |
Emulating old channel mask behavior for both input and output
This adds the "ignore positional channel masks" behavior back
into output as well as input.
Bug: 27042146
Change-Id: I51fc4a4494cd9477fdcddb6901cd353b88ea2c2e
(cherry picked from commit f4f89da331441ec4693c8ebb6ae3cf5460a22328)
-rw-r--r-- | src/android/AudioPlayer_to_android.cpp | 11 | ||||
-rw-r--r-- | src/android/AudioRecorder_to_android.cpp | 16 |
2 files changed, 20 insertions, 7 deletions
diff --git a/src/android/AudioPlayer_to_android.cpp b/src/android/AudioPlayer_to_android.cpp index 056ecd5..41272db 100644 --- a/src/android/AudioPlayer_to_android.cpp +++ b/src/android/AudioPlayer_to_android.cpp @@ -1477,8 +1477,17 @@ SLresult android_audioPlayer_realize(CAudioPlayer *pAudioPlayer, SLboolean async audio_channel_mask_t channelMask; channelMask = sles_to_audio_output_channel_mask(df_pcm->channelMask); - if (channelMask == SL_ANDROID_UNKNOWN_CHANNELMASK) { + + // To maintain backward compatibility with previous releases, ignore + // channel masks that are not indexed. + if (channelMask == AUDIO_CHANNEL_INVALID + || audio_channel_mask_get_representation(channelMask) + == AUDIO_CHANNEL_REPRESENTATION_POSITION) { channelMask = audio_channel_out_mask_from_count(df_pcm->numChannels); + SL_LOGI("Emulating old channel mask behavior " + "(ignoring positional mask %#x, using default mask %#x based on " + "channel count of %d)", df_pcm->channelMask, channelMask, + df_pcm->numChannels); } SL_LOGV("AudioPlayer: mapped SLES channel mask %#x to android channel mask %#x", df_pcm->channelMask, diff --git a/src/android/AudioRecorder_to_android.cpp b/src/android/AudioRecorder_to_android.cpp index c0215c2..0a99129 100644 --- a/src/android/AudioRecorder_to_android.cpp +++ b/src/android/AudioRecorder_to_android.cpp @@ -447,14 +447,18 @@ SLresult android_audioRecorder_realize(CAudioRecorder* ar, SLboolean async) { // note that df_pcm->channelMask has already been validated during object creation. audio_channel_mask_t channelMask = sles_to_audio_input_channel_mask(df_pcm->channelMask); - // To maintain backward compatibility with previous releases, ignore input - // channel masks that are not indexed. We do not define valid positional bits - // for OpenSL ES input formats. - if (audio_channel_mask_get_representation(channelMask) - == AUDIO_CHANNEL_REPRESENTATION_POSITION) { + // To maintain backward compatibility with previous releases, ignore + // channel masks that are not indexed. + if (channelMask == AUDIO_CHANNEL_INVALID + || audio_channel_mask_get_representation(channelMask) + == AUDIO_CHANNEL_REPRESENTATION_POSITION) { channelMask = audio_channel_in_mask_from_count(df_pcm->numChannels); + SL_LOGI("Emulating old channel mask behavior " + "(ignoring positional mask %#x, using default mask %#x based on " + "channel count of %d)", df_pcm->channelMask, channelMask, + df_pcm->numChannels); } - SL_LOGV("SLES channel mask 0x%x converted to Android mask 0x%x", df_pcm->channelMask, channelMask); + SL_LOGV("SLES channel mask %#x converted to Android mask %#x", df_pcm->channelMask, channelMask); // initialize platform-specific CAudioRecorder fields ar->mAudioRecord = new android::AudioRecord( |