Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(744)

Unified Diff: media/audio/android/opensles_util.cc

Issue 1921963004: Add support for multichannel playback to OpenSLES output. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoid multichannel on KitKat. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/android/opensles_util.h ('k') | media/media.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
+ 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
« no previous file with comments | « media/audio/android/opensles_util.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698