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

Unified Diff: webrtc/modules/audio_device/audio_device_impl.cc

Issue 2119633004: Adds support for OpenSL ES based audio capture on Android (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing presubmit warnings Created 4 years, 3 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 | « webrtc/modules/audio_device/audio_device_buffer.cc ('k') | webrtc/modules/utility/include/jvm_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_device/audio_device_impl.cc
diff --git a/webrtc/modules/audio_device/audio_device_impl.cc b/webrtc/modules/audio_device/audio_device_impl.cc
index 850e9f3db92e20ab6103de53aade1f48ad5f85ea..cf69275eebd5634fc8136937aaba64e1838aa8eb 100644
--- a/webrtc/modules/audio_device/audio_device_impl.cc
+++ b/webrtc/modules/audio_device/audio_device_impl.cc
@@ -10,6 +10,7 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
+#include "webrtc/base/checks.h"
#include "webrtc/base/refcount.h"
#include "webrtc/base/timeutils.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
@@ -33,6 +34,7 @@
#include "webrtc/modules/audio_device/android/audio_record_jni.h"
#include "webrtc/modules/audio_device/android/audio_track_jni.h"
#include "webrtc/modules/audio_device/android/opensles_player.h"
+#include "webrtc/modules/audio_device/android/opensles_recorder.h"
#elif defined(WEBRTC_LINUX)
#if defined(LINUX_ALSA)
#include "audio_device_alsa_linux.h"
@@ -238,13 +240,18 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() {
_audioManagerAndroid.reset(new AudioManager());
// Select best possible combination of audio layers.
if (audioLayer == kPlatformDefaultAudio) {
- if (_audioManagerAndroid->IsLowLatencyPlayoutSupported()) {
- // Always use OpenSL ES for output on devices that supports the
+ if (_audioManagerAndroid->IsLowLatencyPlayoutSupported() &&
+ _audioManagerAndroid->IsLowLatencyRecordSupported()) {
+ // Use OpenSL ES for both playout and recording.
+ audioLayer = kAndroidOpenSLESAudio;
+ } else if (_audioManagerAndroid->IsLowLatencyPlayoutSupported() &&
+ !_audioManagerAndroid->IsLowLatencyRecordSupported()) {
+ // Use OpenSL ES for output on devices that only supports the
// low-latency output audio path.
audioLayer = kAndroidJavaInputAndOpenSLESOutputAudio;
} else {
- // Use Java-based audio in both directions when low-latency output
- // is not supported.
+ // Use Java-based audio in both directions when low-latency output is
+ // not supported.
audioLayer = kAndroidJavaAudio;
}
}
@@ -253,6 +260,10 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() {
// Java audio for both input and output audio.
ptrAudioDevice = new AudioDeviceTemplate<AudioRecordJni, AudioTrackJni>(
audioLayer, audio_manager);
+ } else if (audioLayer == kAndroidOpenSLESAudio) {
+ // OpenSL ES based audio for both input and output audio.
+ ptrAudioDevice = new AudioDeviceTemplate<OpenSLESRecorder, OpenSLESPlayer>(
+ audioLayer, audio_manager);
} else if (audioLayer == kAndroidJavaInputAndOpenSLESOutputAudio) {
// Java audio for input and OpenSL ES for output audio (i.e. mixed APIs).
// This combination provides low-latency output audio and at the same
@@ -261,7 +272,7 @@ int32_t AudioDeviceModuleImpl::CreatePlatformSpecificObjects() {
audioLayer, audio_manager);
} else {
// Invalid audio layer.
- ptrAudioDevice = NULL;
+ ptrAudioDevice = nullptr;
}
// END #if defined(WEBRTC_ANDROID)
« no previous file with comments | « webrtc/modules/audio_device/audio_device_buffer.cc ('k') | webrtc/modules/utility/include/jvm_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698