Logging and tracing of audio devices on Andriod.
Replaced invokations of WEBRTC_TRACE with LOG, which is visible in the android system log. BUG=NONE R=henrika@webrtc.org Review URL: https://codereview.webrtc.org/2091803002 . Cr-Commit-Position: refs/heads/master@{#13308}
This commit is contained in:
parent
6bb1ef2b86
commit
098e6c5d0a
@ -11,16 +11,11 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_
|
||||
#define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/thread_checker.h"
|
||||
#include "webrtc/modules/audio_device/android/audio_manager.h"
|
||||
#include "webrtc/modules/audio_device/audio_device_generic.h"
|
||||
#include "webrtc/system_wrappers/include/trace.h"
|
||||
|
||||
#define TAG "AudioDeviceTemplate"
|
||||
#define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -44,20 +39,22 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
output_(audio_manager_),
|
||||
input_(audio_manager_),
|
||||
initialized_(false) {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
RTC_CHECK(audio_manager);
|
||||
audio_manager_->SetActiveAudioLayer(audio_layer);
|
||||
}
|
||||
|
||||
virtual ~AudioDeviceTemplate() {
|
||||
}
|
||||
virtual ~AudioDeviceTemplate() { LOG(INFO) << __FUNCTION__; }
|
||||
|
||||
int32_t ActiveAudioLayer(
|
||||
AudioDeviceModule::AudioLayer& audioLayer) const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
audioLayer = audio_layer_;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t Init() override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
RTC_DCHECK(!initialized_);
|
||||
if (!audio_manager_->Init())
|
||||
@ -76,6 +73,7 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
}
|
||||
|
||||
int32_t Terminate() override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
int32_t err = input_.Terminate();
|
||||
err |= output_.Terminate();
|
||||
@ -86,15 +84,18 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
}
|
||||
|
||||
bool Initialized() const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
return initialized_;
|
||||
}
|
||||
|
||||
int16_t PlayoutDevices() override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int16_t RecordingDevices() override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -117,6 +118,7 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
int32_t SetPlayoutDevice(uint16_t index) override {
|
||||
// OK to use but it has no effect currently since device selection is
|
||||
// done using Andoid APIs instead.
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -129,6 +131,7 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
int32_t SetRecordingDevice(uint16_t index) override {
|
||||
// OK to use but it has no effect currently since device selection is
|
||||
// done using Andoid APIs instead.
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -139,34 +142,42 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
}
|
||||
|
||||
int32_t PlayoutIsAvailable(bool& available) override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
available = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t InitPlayout() override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return output_.InitPlayout();
|
||||
}
|
||||
|
||||
bool PlayoutIsInitialized() const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return output_.PlayoutIsInitialized();
|
||||
}
|
||||
|
||||
int32_t RecordingIsAvailable(bool& available) override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
available = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t InitRecording() override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return input_.InitRecording();
|
||||
}
|
||||
|
||||
bool RecordingIsInitialized() const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return input_.RecordingIsInitialized();
|
||||
}
|
||||
|
||||
int32_t StartPlayout() override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
if (!audio_manager_->IsCommunicationModeEnabled()) {
|
||||
ALOGW("The application should use MODE_IN_COMMUNICATION audio mode!");
|
||||
LOG(WARNING)
|
||||
<< "The application should use MODE_IN_COMMUNICATION audio mode!";
|
||||
}
|
||||
return output_.StartPlayout();
|
||||
}
|
||||
@ -175,23 +186,28 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
// Avoid using audio manger (JNI/Java cost) if playout was inactive.
|
||||
if (!Playing())
|
||||
return 0;
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
int32_t err = output_.StopPlayout();
|
||||
return err;
|
||||
}
|
||||
|
||||
bool Playing() const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return output_.Playing();
|
||||
}
|
||||
|
||||
int32_t StartRecording() override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
if (!audio_manager_->IsCommunicationModeEnabled()) {
|
||||
ALOGW("The application should use MODE_IN_COMMUNICATION audio mode!");
|
||||
LOG(WARNING)
|
||||
<< "The application should use MODE_IN_COMMUNICATION audio mode!";
|
||||
}
|
||||
return input_.StartRecording();
|
||||
}
|
||||
|
||||
int32_t StopRecording() override {
|
||||
// Avoid using audio manger (JNI/Java cost) if recording was inactive.
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
if (!Recording())
|
||||
return 0;
|
||||
int32_t err = input_.StopRecording();
|
||||
@ -199,6 +215,7 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
}
|
||||
|
||||
bool Recording() const override {
|
||||
LOG(LS_VERBOSE) << __FUNCTION__;
|
||||
return input_.Recording() ;
|
||||
}
|
||||
|
||||
@ -210,6 +227,7 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
}
|
||||
|
||||
bool AGC() const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -226,38 +244,47 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
}
|
||||
|
||||
int32_t InitSpeaker() override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SpeakerIsInitialized() const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t InitMicrophone() override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool MicrophoneIsInitialized() const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t SpeakerVolumeIsAvailable(bool& available) override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return output_.SpeakerVolumeIsAvailable(available);
|
||||
}
|
||||
|
||||
int32_t SetSpeakerVolume(uint32_t volume) override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return output_.SetSpeakerVolume(volume);
|
||||
}
|
||||
|
||||
int32_t SpeakerVolume(uint32_t& volume) const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return output_.SpeakerVolume(volume);
|
||||
}
|
||||
|
||||
int32_t MaxSpeakerVolume(uint32_t& maxVolume) const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return output_.MaxSpeakerVolume(maxVolume);
|
||||
}
|
||||
|
||||
int32_t MinSpeakerVolume(uint32_t& minVolume) const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return output_.MinSpeakerVolume(minVolume);
|
||||
}
|
||||
|
||||
@ -343,12 +370,14 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
}
|
||||
|
||||
int32_t StereoPlayoutIsAvailable(bool& available) override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
available = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO(henrika): add support.
|
||||
int32_t SetStereoPlayout(bool enable) override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -360,15 +389,18 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
}
|
||||
|
||||
int32_t StereoRecordingIsAvailable(bool& available) override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
available = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t SetStereoRecording(bool enable) override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t StereoRecording(bool& enabled) const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
enabled = false;
|
||||
return 0;
|
||||
}
|
||||
@ -388,12 +420,14 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
int32_t PlayoutDelay(uint16_t& delay_ms) const override {
|
||||
// Best guess we can do is to use half of the estimated total delay.
|
||||
delay_ms = audio_manager_->GetDelayEstimateInMilliseconds() / 2;
|
||||
LOG(LS_VERBOSE) << __FUNCTION__ << " delay = " << delay_ms;
|
||||
RTC_DCHECK_GT(delay_ms, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t RecordingDelay(uint16_t& delay_ms) const override {
|
||||
// Best guess we can do is to use half of the estimated total delay.
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
delay_ms = audio_manager_->GetDelayEstimateInMilliseconds() / 2;
|
||||
RTC_DCHECK_GT(delay_ms, 0);
|
||||
return 0;
|
||||
@ -405,30 +439,35 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
}
|
||||
|
||||
bool PlayoutWarning() const override {
|
||||
LOG(LS_VERBOSE) << __FUNCTION__;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PlayoutError() const override {
|
||||
LOG(LS_VERBOSE) << __FUNCTION__;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RecordingWarning() const override {
|
||||
LOG(LS_VERBOSE) << __FUNCTION__;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RecordingError() const override {
|
||||
LOG(LS_VERBOSE) << __FUNCTION__;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClearPlayoutWarning() override {}
|
||||
void ClearPlayoutWarning() override { LOG(INFO) << __FUNCTION__; }
|
||||
|
||||
void ClearPlayoutError() override {}
|
||||
void ClearPlayoutError() override { LOG(INFO) << __FUNCTION__; }
|
||||
|
||||
void ClearRecordingWarning() override {}
|
||||
void ClearRecordingWarning() override { LOG(INFO) << __FUNCTION__; }
|
||||
|
||||
void ClearRecordingError() override {}
|
||||
void ClearRecordingError() override { LOG(INFO) << __FUNCTION__; }
|
||||
|
||||
void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
output_.AttachAudioBuffer(audioBuffer);
|
||||
input_.AttachAudioBuffer(audioBuffer);
|
||||
}
|
||||
@ -452,10 +491,16 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
// Returns true if the device both supports built in AEC and the device
|
||||
// is not blacklisted.
|
||||
bool BuiltInAECIsAvailable() const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return audio_manager_->IsAcousticEchoCancelerSupported();
|
||||
}
|
||||
|
||||
int32_t EnableBuiltInAEC(bool enable) override {
|
||||
if (enable) {
|
||||
LOG(INFO) << __FUNCTION__ << ": enabling built in AEC";
|
||||
} else {
|
||||
LOG(INFO) << __FUNCTION__ << ": disabling built in AEC";
|
||||
}
|
||||
RTC_CHECK(BuiltInAECIsAvailable()) << "HW AEC is not available";
|
||||
return input_.EnableBuiltInAEC(enable);
|
||||
}
|
||||
@ -463,10 +508,16 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
// Returns true if the device both supports built in AGC and the device
|
||||
// is not blacklisted.
|
||||
bool BuiltInAGCIsAvailable() const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return audio_manager_->IsAutomaticGainControlSupported();
|
||||
}
|
||||
|
||||
int32_t EnableBuiltInAGC(bool enable) override {
|
||||
if (enable) {
|
||||
LOG(INFO) << __FUNCTION__ << ": enabling built in AGC";
|
||||
} else {
|
||||
LOG(INFO) << __FUNCTION__ << ": disabling built in AGC";
|
||||
}
|
||||
RTC_CHECK(BuiltInAGCIsAvailable()) << "HW AGC is not available";
|
||||
return input_.EnableBuiltInAGC(enable);
|
||||
}
|
||||
@ -474,10 +525,16 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
|
||||
// Returns true if the device both supports built in NS and the device
|
||||
// is not blacklisted.
|
||||
bool BuiltInNSIsAvailable() const override {
|
||||
LOG(INFO) << __FUNCTION__;
|
||||
return audio_manager_->IsNoiseSuppressorSupported();
|
||||
}
|
||||
|
||||
int32_t EnableBuiltInNS(bool enable) override {
|
||||
if (enable) {
|
||||
LOG(INFO) << __FUNCTION__ << ": enabling built in NS";
|
||||
} else {
|
||||
LOG(INFO) << __FUNCTION__ << ": disabling built in NS";
|
||||
}
|
||||
RTC_CHECK(BuiltInNSIsAvailable()) << "HW NS is not available";
|
||||
return input_.EnableBuiltInNS(enable);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user