diff --git a/webrtc/modules/audio_device/android/audio_manager.cc b/webrtc/modules/audio_device/android/audio_manager.cc index 25735eb44..81fabdf9f 100644 --- a/webrtc/modules/audio_device/android/audio_manager.cc +++ b/webrtc/modules/audio_device/android/audio_manager.cc @@ -34,7 +34,10 @@ AudioManager::JavaAudioManager::JavaAudioManager( init_(native_reg->GetMethodId("init", "()Z")), dispose_(native_reg->GetMethodId("dispose", "()V")), is_communication_mode_enabled_( - native_reg->GetMethodId("isCommunicationModeEnabled", "()Z")) { + native_reg->GetMethodId("isCommunicationModeEnabled", "()Z")), + is_device_blacklisted_for_open_sles_usage_( + native_reg->GetMethodId( + "isDeviceBlacklistedForOpenSLESUsage", "()Z")) { ALOGD("JavaAudioManager::ctor%s", GetThreadInfo().c_str()); } @@ -54,6 +57,11 @@ bool AudioManager::JavaAudioManager::IsCommunicationModeEnabled() { return audio_manager_->CallBooleanMethod(is_communication_mode_enabled_); } +bool AudioManager::JavaAudioManager::IsDeviceBlacklistedForOpenSLESUsage() { + return audio_manager_->CallBooleanMethod( + is_device_blacklisted_for_open_sles_usage_); +} + // AudioManager implementation AudioManager::AudioManager() : j_environment_(JVM::GetInstance()->environment()), @@ -139,10 +147,10 @@ bool AudioManager::IsAcousticEchoCancelerSupported() const { bool AudioManager::IsLowLatencyPlayoutSupported() const { DCHECK(thread_checker_.CalledOnValidThread()); ALOGD("IsLowLatencyPlayoutSupported()"); - // TODO(henrika): enable again once issue in b/21485703 has been sorted out. - // This is just a temporary fix. - ALOGW("NOTE: OpenSL ES output is currently disabled!"); - return false; + // Some devices are blacklisted for usage of OpenSL ES even if they report + // that low-latency playout is supported. See b/21485703 for details. + return j_audio_manager_->IsDeviceBlacklistedForOpenSLESUsage() ? + false : low_latency_playout_; } int AudioManager::GetDelayEstimateInMilliseconds() const { diff --git a/webrtc/modules/audio_device/android/audio_manager.h b/webrtc/modules/audio_device/android/audio_manager.h index a2f192ca0..8d96d27e3 100644 --- a/webrtc/modules/audio_device/android/audio_manager.h +++ b/webrtc/modules/audio_device/android/audio_manager.h @@ -98,12 +98,14 @@ class AudioManager { bool Init(); void Close(); bool IsCommunicationModeEnabled(); + bool IsDeviceBlacklistedForOpenSLESUsage(); private: rtc::scoped_ptr audio_manager_; jmethodID init_; jmethodID dispose_; jmethodID is_communication_mode_enabled_; + jmethodID is_device_blacklisted_for_open_sles_usage_; }; AudioManager(); diff --git a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java index 95c2ca0e4..9396c49ae 100644 --- a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java +++ b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java @@ -108,6 +108,17 @@ class WebRtcAudioManager { return (audioManager.getMode() == AudioManager.MODE_IN_COMMUNICATION); } + private boolean isDeviceBlacklistedForOpenSLESUsage() { + boolean blacklisted = + WebRtcAudioUtils.deviceIsBlacklistedForOpenSLESUsage(); + if (blacklisted) { + // TODO(henrika): enable again for all devices once issue in b/21485703 + // has been resolved. + Loge(Build.MODEL + " is blacklisted for OpenSL ES usage!"); + } + return blacklisted; + } + private void storeAudioParameters() { // Only mono is supported currently (in both directions). // TODO(henrika): add support for stereo playout. diff --git a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java index 68096687c..9aff519a1 100644 --- a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java +++ b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java @@ -35,6 +35,13 @@ public final class WebRtcAudioUtils { "D6503", // Sony Xperia Z2 D6503 }; + // List of devices where we have seen issues (e.g. bad audio quality) using + // the low latency ouput mode in combination with OpenSL ES. + // The device name is given by Build.MODEL. + private static final String[] BLACKLISTED_OPEN_SL_ES_MODELS = new String[] { + "Nexus 6", // Nexus 6 + }; + // Use 44.1kHz as the default sampling rate. private static final int SAMPLE_RATE_HZ = 44100; @@ -76,6 +83,13 @@ public final class WebRtcAudioUtils { return blackListedModels.contains(Build.MODEL); } + // Returns true if the device is blacklisted for OpenSL ES usage. + public static boolean deviceIsBlacklistedForOpenSLESUsage() { + List blackListedModels = + Arrays.asList(BLACKLISTED_OPEN_SL_ES_MODELS); + return blackListedModels.contains(Build.MODEL); + } + // Returns true if the device supports Acoustic Echo Canceler (AEC). public static boolean isAcousticEchoCancelerSupported() { // AcousticEchoCanceler was added in API level 16 (Jelly Bean).