Chromium Code Reviews| Index: media/audio/android/opensles_util.cc |
| diff --git a/media/audio/android/opensles_util.cc b/media/audio/android/opensles_util.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cf5ea3b98d85921d57389aa3ee05407d102e2545 |
| --- /dev/null |
| +++ b/media/audio/android/opensles_util.cc |
| @@ -0,0 +1,50 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "media/audio/android/opensles_util.h" |
| + |
| +namespace media { |
| + |
| +#define SL_ANDROID_SPEAKER_QUAD \ |
| + (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT | SL_SPEAKER_BACK_LEFT | \ |
| + SL_SPEAKER_BACK_RIGHT) |
| +#define SL_ANDROID_SPEAKER_5DOT1 \ |
| + (SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT | SL_SPEAKER_FRONT_CENTER | \ |
| + SL_SPEAKER_LOW_FREQUENCY | SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT) |
| +#define SL_ANDROID_SPEAKER_7DOT1 \ |
| + (SL_ANDROID_SPEAKER_5DOT1 | SL_SPEAKER_SIDE_LEFT | SL_SPEAKER_SIDE_RIGHT) |
| + |
| +// Ported from: |
| +// https://android.googlesource.com/platform/frameworks/wilhelm/+/refs/heads/master/src/android/channels.h |
| +// https://android.googlesource.com/platform/frameworks/wilhelm/+/refs/heads/master/src/android/channels.c |
| +SLuint32 ChannelCountToSLESChannelMask(int channel_count) { |
|
henrika (OOO until Aug 14)
2016/04/28 07:52:54
I understand that you want to avoid the existing D
DaleCurtis
2016/04/28 17:27:26
AndroidTV devices and those hooked up via HDMI sho
henrika (OOO until Aug 14)
2016/04/29 07:46:31
Thanks. Just hope it works then ;-)
|
| + if (channel_count > 2) { |
| + LOG(WARNING) << "Guessing channel layout for " << channel_count |
| + << " channels; speaker order may be incorrect."; |
| + } |
| + |
| + switch (channel_count) { |
| + case 1: |
| + return SL_SPEAKER_FRONT_LEFT; |
| + case 2: |
| + return SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT; |
| + case 3: |
| + return SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT | |
| + SL_SPEAKER_FRONT_CENTER; |
| + case 4: |
| + return SL_ANDROID_SPEAKER_QUAD; |
| + case 5: |
| + return SL_ANDROID_SPEAKER_QUAD | SL_SPEAKER_FRONT_CENTER; |
| + case 6: |
| + return SL_ANDROID_SPEAKER_5DOT1; |
| + case 7: |
| + return SL_ANDROID_SPEAKER_5DOT1 | SL_SPEAKER_BACK_CENTER; |
| + case 8: |
| + return SL_ANDROID_SPEAKER_7DOT1; |
| + } |
| + |
| + return 0; |
| +} |
| + |
| +} // namespace media |