Adds usage of RTC_LOG macros in code for Android

Bug: webrtc:8710
Change-Id: Ifeedc51ef7d4998278b9583d9530f8f2bdc8f3a2
Reviewed-on: https://webrtc-review.googlesource.com/39266
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21678}
This commit is contained in:
henrika
2018-01-12 14:35:07 +01:00
committed by Commit Bot
parent dde8702f11
commit 53e048d83a
2 changed files with 56 additions and 67 deletions

View File

@ -12,21 +12,13 @@
#include <utility>
#include <android/log.h>
#include "modules/audio_device/android/audio_common.h"
#include "modules/utility/include/helpers_android.h"
#include "rtc_base/arraysize.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/platform_thread.h"
#define TAG "AudioManager"
#define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__)
#define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
#define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
namespace webrtc {
// AudioManager::JavaAudioManager implementation
@ -41,11 +33,11 @@ AudioManager::JavaAudioManager::JavaAudioManager(
is_device_blacklisted_for_open_sles_usage_(
native_reg->GetMethodId("isDeviceBlacklistedForOpenSLESUsage",
"()Z")) {
ALOGD("JavaAudioManager::ctor @[tid=%d]", rtc::CurrentThreadId());
RTC_LOG(INFO) << "JavaAudioManager::ctor";
}
AudioManager::JavaAudioManager::~JavaAudioManager() {
ALOGD("JavaAudioManager::dtor[tid=%d]", rtc::CurrentThreadId());
RTC_LOG(INFO) << "JavaAudioManager::~dtor";
}
bool AudioManager::JavaAudioManager::Init() {
@ -76,7 +68,7 @@ AudioManager::AudioManager()
low_latency_playout_(false),
low_latency_record_(false),
delay_estimate_in_milliseconds_(0) {
ALOGD("ctor[tid=%d]", rtc::CurrentThreadId());
RTC_LOG(INFO) << "ctor";
RTC_CHECK(j_environment_);
JNINativeMethod native_methods[] = {
{"nativeCacheAudioParameters", "(IIIZZZZZZIIJ)V",
@ -91,14 +83,14 @@ AudioManager::AudioManager()
}
AudioManager::~AudioManager() {
ALOGD("~dtor[tid=%d]", rtc::CurrentThreadId());
RTC_LOG(INFO) << "dtor";
RTC_DCHECK(thread_checker_.CalledOnValidThread());
Close();
}
void AudioManager::SetActiveAudioLayer(
AudioDeviceModule::AudioLayer audio_layer) {
ALOGD("SetActiveAudioLayer(%d)[tid=%d]", audio_layer, rtc::CurrentThreadId());
RTC_LOG(INFO) << "SetActiveAudioLayer: " << audio_layer;
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(!initialized_);
// Store the currently utilized audio layer.
@ -111,25 +103,27 @@ void AudioManager::SetActiveAudioLayer(
(audio_layer == AudioDeviceModule::kAndroidJavaAudio)
? kHighLatencyModeDelayEstimateInMilliseconds
: kLowLatencyModeDelayEstimateInMilliseconds;
ALOGD("delay_estimate_in_milliseconds: %d", delay_estimate_in_milliseconds_);
RTC_LOG(INFO) << "delay_estimate_in_milliseconds: "
<< delay_estimate_in_milliseconds_;
}
SLObjectItf AudioManager::GetOpenSLEngine() {
ALOGD("GetOpenSLEngine[tid=%d]", rtc::CurrentThreadId());
RTC_LOG(INFO) << "GetOpenSLEngine";
RTC_DCHECK(thread_checker_.CalledOnValidThread());
// Only allow usage of OpenSL ES if such an audio layer has been specified.
if (audio_layer_ != AudioDeviceModule::kAndroidOpenSLESAudio &&
audio_layer_ !=
AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio) {
ALOGI("Unable to create OpenSL engine for the current audio layer: %d",
audio_layer_);
RTC_LOG(INFO)
<< "Unable to create OpenSL engine for the current audio layer: "
<< audio_layer_;
return nullptr;
}
// OpenSL ES for Android only supports a single engine per application.
// If one already has been created, return existing object instead of
// creating a new.
if (engine_object_.Get() != nullptr) {
ALOGI("The OpenSL ES engine object has already been created");
RTC_LOG(WARNING) << "The OpenSL ES engine object has already been created";
return engine_object_.Get();
}
// Create the engine object in thread safe mode.
@ -138,14 +132,15 @@ SLObjectItf AudioManager::GetOpenSLEngine() {
SLresult result =
slCreateEngine(engine_object_.Receive(), 1, option, 0, NULL, NULL);
if (result != SL_RESULT_SUCCESS) {
ALOGE("slCreateEngine() failed: %s", GetSLErrorString(result));
RTC_LOG(LS_ERROR) << "slCreateEngine() failed: "
<< GetSLErrorString(result);
engine_object_.Reset();
return nullptr;
}
// Realize the SL Engine in synchronous mode.
result = engine_object_->Realize(engine_object_.Get(), SL_BOOLEAN_FALSE);
if (result != SL_RESULT_SUCCESS) {
ALOGE("Realize() failed: %s", GetSLErrorString(result));
RTC_LOG(LS_ERROR) << "Realize() failed: " << GetSLErrorString(result);
engine_object_.Reset();
return nullptr;
}
@ -154,12 +149,12 @@ SLObjectItf AudioManager::GetOpenSLEngine() {
}
bool AudioManager::Init() {
ALOGD("Init[tid=%d]", rtc::CurrentThreadId());
RTC_LOG(INFO) << "Init";
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(!initialized_);
RTC_DCHECK_NE(audio_layer_, AudioDeviceModule::kPlatformDefaultAudio);
if (!j_audio_manager_->Init()) {
ALOGE("init failed!");
RTC_LOG(LS_ERROR) << "Init() failed";
return false;
}
initialized_ = true;
@ -167,7 +162,7 @@ bool AudioManager::Init() {
}
bool AudioManager::Close() {
ALOGD("Close[tid=%d]", rtc::CurrentThreadId());
RTC_LOG(INFO) << "Close";
RTC_DCHECK(thread_checker_.CalledOnValidThread());
if (!initialized_)
return true;
@ -177,7 +172,6 @@ bool AudioManager::Close() {
}
bool AudioManager::IsCommunicationModeEnabled() const {
ALOGD("IsCommunicationModeEnabled()");
RTC_DCHECK(thread_checker_.CalledOnValidThread());
return j_audio_manager_->IsCommunicationModeEnabled();
}
@ -199,7 +193,6 @@ bool AudioManager::IsNoiseSuppressorSupported() const {
bool AudioManager::IsLowLatencyPlayoutSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
ALOGD("IsLowLatencyPlayoutSupported()");
// 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()
@ -209,13 +202,11 @@ bool AudioManager::IsLowLatencyPlayoutSupported() const {
bool AudioManager::IsLowLatencyRecordSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
ALOGD("IsLowLatencyRecordSupported()");
return low_latency_record_;
}
bool AudioManager::IsProAudioSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
ALOGD("IsProAudioSupported()");
// TODO(henrika): return the state independently of if OpenSL ES is
// blacklisted or not for now. We could use the same approach as in
// IsLowLatencyPlayoutSupported() but I can't see the need for it yet.
@ -224,13 +215,11 @@ bool AudioManager::IsProAudioSupported() const {
bool AudioManager::IsStereoPlayoutSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
ALOGD("IsStereoPlayoutSupported()");
return (playout_parameters_.channels() == 2);
}
bool AudioManager::IsStereoRecordSupported() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
ALOGD("IsStereoRecordSupported()");
return (record_parameters_.channels() == 2);
}
@ -272,18 +261,19 @@ void AudioManager::OnCacheAudioParameters(JNIEnv* env,
jboolean pro_audio,
jint output_buffer_size,
jint input_buffer_size) {
ALOGD("OnCacheAudioParameters[tid=%d]", rtc::CurrentThreadId());
ALOGD("hardware_aec: %d", hardware_aec);
ALOGD("hardware_agc: %d", hardware_agc);
ALOGD("hardware_ns: %d", hardware_ns);
ALOGD("low_latency_output: %d", low_latency_output);
ALOGD("low_latency_input: %d", low_latency_input);
ALOGD("pro_audio: %d", pro_audio);
ALOGD("sample_rate: %d", sample_rate);
ALOGD("output_channels: %d", output_channels);
ALOGD("input_channels: %d", input_channels);
ALOGD("output_buffer_size: %d", output_buffer_size);
ALOGD("input_buffer_size: %d", input_buffer_size);
RTC_LOG(INFO)
<< "OnCacheAudioParameters: "
<< "hardware_aec: " << static_cast<bool>(hardware_aec)
<< ", hardware_agc: " << static_cast<bool>(hardware_agc)
<< ", hardware_ns: " << static_cast<bool>(hardware_ns)
<< ", low_latency_output: " << static_cast<bool>(low_latency_output)
<< ", low_latency_input: " << static_cast<bool>(low_latency_input)
<< ", pro_audio: " << static_cast<bool>(pro_audio)
<< ", sample_rate: " << static_cast<int>(sample_rate)
<< ", output_channels: " << static_cast<int>(output_channels)
<< ", input_channels: " << static_cast<int>(input_channels)
<< ", output_buffer_size: " << static_cast<int>(output_buffer_size)
<< ", input_buffer_size: " << static_cast<int>(input_buffer_size);
RTC_DCHECK(thread_checker_.CalledOnValidThread());
hardware_aec_ = hardware_aec;
hardware_agc_ = hardware_agc;