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 <ossu@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#18712}
diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module.cc
index 2fcbecf..d231a84 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 @@
       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 @@
 
 // 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 @@
                                                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<size_t>(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 @@
         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 @@
     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 @@
 
 // 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 @@
 // 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::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 @@
                                            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::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 @@
 
 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 @@
 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 734358a..e218080 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 @@
 
 // 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 @@
     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 @@
     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 @@
 
 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 @@
           ? (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::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;
   }