From 300ec8c8db4afcfe834817490a9b82de3cf12f9c Mon Sep 17 00:00:00 2001 From: Alex Loiko Date: Tue, 30 May 2017 17:23:28 +0200 Subject: [PATCH] Remove WEBRTC_TRACE from webrtc/modules/audio_coding We'd like to remove all occurrences of WEBRTC_TRACE and delete the macro! One logging mechanism is enough. NOTRY=True Bug: webrtc:5118 Change-Id: Ic226318e0aebe3a71785fcb4ce07371872ab7128 Reviewed-on: https://chromium-review.googlesource.com/518133 Reviewed-by: Oskar Sundbom Commit-Queue: Alex Loiko Cr-Commit-Position: refs/heads/master@{#18712} --- .../audio_coding/acm2/audio_coding_module.cc | 53 +++++++------------ .../audio_coding/acm2/codec_manager.cc | 47 +++++++--------- .../audio_coding/test/TestAllCodecs.cc | 5 +- 3 files changed, 38 insertions(+), 67 deletions(-) diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module.cc index 2fcbecf379..d231a8447e 100644 --- a/webrtc/modules/audio_coding/acm2/audio_coding_module.cc +++ b/webrtc/modules/audio_coding/acm2/audio_coding_module.cc @@ -19,7 +19,6 @@ #include "webrtc/modules/audio_coding/acm2/codec_manager.h" #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" #include "webrtc/system_wrappers/include/metrics.h" -#include "webrtc/system_wrappers/include/trace.h" namespace webrtc { @@ -466,10 +465,9 @@ AudioCodingModuleImpl::AudioCodingModuleImpl( codec_histogram_bins_log_(), number_of_consecutive_empty_packets_(0) { if (InitializeReceiverSafe() < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, - "Cannot initialize receiver"); + LOG(LS_ERROR) << "Cannot initialize receiver"; } - WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceAudioCoding, id_, "Created"); + LOG(LS_INFO) << "Created"; } AudioCodingModuleImpl::~AudioCodingModuleImpl() = default; @@ -638,13 +636,11 @@ rtc::Optional AudioCodingModuleImpl::SendCodec() const { // Get current send frequency. int AudioCodingModuleImpl::SendFrequency() const { - WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_, - "SendFrequency()"); + LOG(LS_VERBOSE) << "SendFrequency()"; rtc::CritScope lock(&acm_crit_sect_); if (!encoder_stack_) { - WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_, - "SendFrequency Failed, no codec is registered"); + LOG(LS_VERBOSE) << "SendFrequency Failed, no codec is registered"; return -1; } @@ -680,30 +676,26 @@ int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame, InputData* input_data) { if (audio_frame.samples_per_channel_ == 0) { assert(false); - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, - "Cannot Add 10 ms audio, payload length is zero"); + LOG(LS_ERROR) << "Cannot Add 10 ms audio, payload length is zero"; return -1; } if (audio_frame.sample_rate_hz_ > 48000) { assert(false); - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, - "Cannot Add 10 ms audio, input frequency not valid"); + LOG(LS_ERROR) << "Cannot Add 10 ms audio, input frequency not valid"; return -1; } // If the length and frequency matches. We currently just support raw PCM. if (static_cast(audio_frame.sample_rate_hz_ / 100) != audio_frame.samples_per_channel_) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, - "Cannot Add 10 ms audio, input frequency and length doesn't" - " match"); + LOG(LS_ERROR) + << "Cannot Add 10 ms audio, input frequency and length doesn't match"; return -1; } if (audio_frame.num_channels_ != 1 && audio_frame.num_channels_ != 2) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, - "Cannot Add 10 ms audio, invalid number of channels."); + LOG(LS_ERROR) << "Cannot Add 10 ms audio, invalid number of channels."; return -1; } @@ -835,8 +827,7 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame, dest_ptr_audio); if (samples_per_channel < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, - "Cannot add 10 ms audio, resampling failed"); + LOG(LS_ERROR) << "Cannot add 10 ms audio, resampling failed"; return -1; } preprocess_frame_.samples_per_channel_ = @@ -873,8 +864,7 @@ int AudioCodingModuleImpl::SetREDStatus(bool enable_red) { encoder_stack_ = encoder_factory_->rent_a_codec.RentEncoderStack(sp); return 0; #else - WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, id_, - " WEBRTC_CODEC_RED is undefined"); + LOG(LS_WARNING) << " WEBRTC_CODEC_RED is undefined"; return -1; #endif } @@ -976,8 +966,7 @@ int AudioCodingModuleImpl::ReceiveFrequency() const { // Get current playout frequency. int AudioCodingModuleImpl::PlayoutFrequency() const { - WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_, - "PlayoutFrequency()"); + LOG(LS_VERBOSE) << "PlayoutFrequency()"; return receiver_.last_output_sample_rate_hz(); } @@ -1102,8 +1091,7 @@ int AudioCodingModuleImpl::IncomingPacket(const uint8_t* incoming_payload, // Minimum playout delay (Used for lip-sync). int AudioCodingModuleImpl::SetMinimumPlayoutDelay(int time_ms) { if ((time_ms < 0) || (time_ms > 10000)) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, - "Delay must be in the range of 0-1000 milliseconds."); + LOG(LS_ERROR) << "Delay must be in the range of 0-1000 milliseconds."; return -1; } return receiver_.SetMinimumDelay(time_ms); @@ -1111,8 +1099,7 @@ int AudioCodingModuleImpl::SetMinimumPlayoutDelay(int time_ms) { int AudioCodingModuleImpl::SetMaximumPlayoutDelay(int time_ms) { if ((time_ms < 0) || (time_ms > 10000)) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, - "Delay must be in the range of 0-1000 milliseconds."); + LOG(LS_ERROR) << "Delay must be in the range of 0-1000 milliseconds."; return -1; } return receiver_.SetMaximumDelay(time_ms); @@ -1125,8 +1112,7 @@ int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz, bool* muted) { // GetAudio always returns 10 ms, at the requested sample rate. if (receiver_.GetAudio(desired_freq_hz, audio_frame, muted) != 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, - "PlayoutData failed, RecOut Failed"); + LOG(LS_ERROR) << "PlayoutData failed, RecOut Failed"; return -1; } audio_frame->id_ = id_; @@ -1153,8 +1139,7 @@ int AudioCodingModuleImpl::GetNetworkStatistics(NetworkStatistics* statistics) { } int AudioCodingModuleImpl::RegisterVADCallback(ACMVADCallback* vad_callback) { - WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceAudioCoding, id_, - "RegisterVADCallback()"); + LOG(LS_VERBOSE) << "RegisterVADCallback()"; rtc::CritScope lock(&callback_crit_sect_); vad_callback_ = vad_callback; return 0; @@ -1253,8 +1238,7 @@ int AudioCodingModuleImpl::FilteredCurrentDelayMs() const { bool AudioCodingModuleImpl::HaveValidEncoder(const char* caller_name) const { if (!encoder_stack_) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, - "%s failed: No send codec is registered.", caller_name); + LOG(LS_ERROR) << caller_name << " failed: No send codec is registered."; return false; } return true; @@ -1378,8 +1362,7 @@ int AudioCodingModule::Codec(const char* payload_name, bool AudioCodingModule::IsCodecValid(const CodecInst& codec) { bool valid = acm2::RentACodec::IsCodecValid(codec); if (!valid) - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, - "Invalid codec setting"); + LOG(LS_ERROR) << "Invalid codec setting"; return valid; } diff --git a/webrtc/modules/audio_coding/acm2/codec_manager.cc b/webrtc/modules/audio_coding/acm2/codec_manager.cc index 734358a925..e218080057 100644 --- a/webrtc/modules/audio_coding/acm2/codec_manager.cc +++ b/webrtc/modules/audio_coding/acm2/codec_manager.cc @@ -11,9 +11,9 @@ #include "webrtc/modules/audio_coding/acm2/codec_manager.h" #include "webrtc/base/checks.h" -#include "webrtc/base/format_macros.h" +//#include "webrtc/base/format_macros.h" +#include "webrtc/base/logging.h" #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" -#include "webrtc/system_wrappers/include/trace.h" #include "webrtc/typedefs.h" namespace webrtc { @@ -23,34 +23,29 @@ namespace { // Check if the given codec is a valid to be registered as send codec. int IsValidSendCodec(const CodecInst& send_codec) { - int dummy_id = 0; if ((send_codec.channels != 1) && (send_codec.channels != 2)) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, - "Wrong number of channels (%" PRIuS ", only mono and stereo " - "are supported)", - send_codec.channels); + LOG(LS_ERROR) << "Wrong number of channels (" << send_codec.channels + << "), only mono and stereo are supported)"; return -1; } auto maybe_codec_id = RentACodec::CodecIdByInst(send_codec); if (!maybe_codec_id) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, - "Invalid codec setting for the send codec."); + LOG(LS_ERROR) << "Invalid codec setting for the send codec."; return -1; } // Telephone-event cannot be a send codec. if (!STR_CASE_CMP(send_codec.plname, "telephone-event")) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, - "telephone-event cannot be a send codec"); + LOG(LS_ERROR) << "telephone-event cannot be a send codec"; return -1; } if (!RentACodec::IsSupportedNumChannels(*maybe_codec_id, send_codec.channels) .value_or(false)) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, - "%" PRIuS " number of channels not supportedn for %s.", - send_codec.channels, send_codec.plname); + LOG(LS_ERROR) << send_codec.channels + << " number of channels not supported for " + << send_codec.plname << "."; return -1; } return RentACodec::CodecIndexFromId(*maybe_codec_id).value_or(-1); @@ -81,15 +76,13 @@ bool CodecManager::RegisterEncoder(const CodecInst& send_codec) { return false; } - int dummy_id = 0; switch (RentACodec::RegisterRedPayloadType( &codec_stack_params_.red_payload_types, send_codec)) { case RentACodec::RegistrationResult::kOk: return true; case RentACodec::RegistrationResult::kBadFreq: - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, - "RegisterSendCodec() failed, invalid frequency for RED" - " registration"); + LOG(LS_ERROR) << "RegisterSendCodec() failed, invalid frequency for RED" + " registration"; return false; case RentACodec::RegistrationResult::kSkip: break; @@ -99,9 +92,8 @@ bool CodecManager::RegisterEncoder(const CodecInst& send_codec) { case RentACodec::RegistrationResult::kOk: return true; case RentACodec::RegistrationResult::kBadFreq: - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, - "RegisterSendCodec() failed, invalid frequency for CNG" - " registration"); + LOG(LS_ERROR) << "RegisterSendCodec() failed, invalid frequency for CNG" + " registration"; return false; case RentACodec::RegistrationResult::kSkip: break; @@ -135,15 +127,14 @@ CodecInst CodecManager::ForgeCodecInst( bool CodecManager::SetCopyRed(bool enable) { if (enable && codec_stack_params_.use_codec_fec) { - WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, 0, - "Codec internal FEC and RED cannot be co-enabled."); + LOG(LS_WARNING) << "Codec internal FEC and RED cannot be co-enabled."; return false; } if (enable && send_codec_inst_ && codec_stack_params_.red_payload_types.count(send_codec_inst_->plfreq) < 1) { - WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, 0, - "Cannot enable RED at %i Hz.", send_codec_inst_->plfreq); + LOG(LS_WARNING) << "Cannot enable RED at " << send_codec_inst_->plfreq + << " Hz."; return false; } codec_stack_params_.use_red = enable; @@ -162,8 +153,7 @@ bool CodecManager::SetVAD(bool enable, ACMVADMode mode) { ? (codec_stack_params_.speech_encoder->NumChannels() != 1) : false; if (enable && stereo_send) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, 0, - "VAD/DTX not supported for stereo sending"); + LOG(LS_ERROR) << "VAD/DTX not supported for stereo sending"; return false; } @@ -181,8 +171,7 @@ bool CodecManager::SetVAD(bool enable, ACMVADMode mode) { bool CodecManager::SetCodecFEC(bool enable_codec_fec) { if (enable_codec_fec && codec_stack_params_.use_red) { - WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, 0, - "Codec internal FEC and RED cannot be co-enabled."); + LOG(LS_WARNING) << "Codec internal FEC and RED cannot be co-enabled."; return false; } diff --git a/webrtc/modules/audio_coding/test/TestAllCodecs.cc b/webrtc/modules/audio_coding/test/TestAllCodecs.cc index 12fe4551bd..96c52414a0 100644 --- a/webrtc/modules/audio_coding/test/TestAllCodecs.cc +++ b/webrtc/modules/audio_coding/test/TestAllCodecs.cc @@ -14,12 +14,12 @@ #include #include +#include "webrtc/base/logging.h" #include "webrtc/common_types.h" #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" #include "webrtc/modules/audio_coding/include/audio_coding_module.h" #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h" #include "webrtc/modules/audio_coding/test/utility.h" -#include "webrtc/system_wrappers/include/trace.h" #include "webrtc/test/gtest.h" #include "webrtc/test/testsupport/fileutils.h" #include "webrtc/typedefs.h" @@ -127,8 +127,7 @@ void TestAllCodecs::Perform() { infile_a_.Open(file_name, 32000, "rb"); if (test_mode_ == 0) { - WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1, - "---------- TestAllCodecs ----------"); + LOG(LS_INFO) << "---------- TestAllCodecs ----------"; } acm_a_->InitializeReceiver();