Switch to base/logging.h in neteq_impl.cc
This change includes base/logging.h instead of the old and deprecated
system_wrappers/interface/logging.h. This requires some changes of the
actual logging invocations.
For reference the following regexps where used (in Eclipse) for a few
of the replacements:
find: LOG_FERR1\(\s*([^,]*),\s*([^,]*),\s*(.*)\);
replace: LOG($1) << "$2 " << $3;
find: LOG_FERR2\(\s*([^,]*),\s*([^,]*),\s*([^,]*),\s*(.*)\);
replace: LOG($1) << "$2 " << $3 << " " << $4;
BUG=4735
R=minyue@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/50229004 .
Cr-Commit-Position: refs/heads/master@{#9669}
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
index 6598a79..3b81999 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -15,6 +15,7 @@
#include <algorithm>
+#include "webrtc/base/logging.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
#include "webrtc/modules/audio_coding/codecs/audio_decoder.h"
#include "webrtc/modules/audio_coding/neteq/accelerate.h"
@@ -40,7 +41,6 @@
#include "webrtc/modules/audio_coding/neteq/timestamp_scaler.h"
#include "webrtc/modules/interface/module_common_types.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
-#include "webrtc/system_wrappers/interface/logging.h"
// Modify the code to obtain backwards bit-exactness. Once bit-exactness is no
// longer required, this #define should be removed (and the code that it
@@ -102,7 +102,6 @@
"Changing to 8000 Hz.";
fs = 8000;
}
- LOG(LS_VERBOSE) << "Create NetEqImpl object with fs = " << fs << ".";
fs_hz_ = fs;
fs_mult_ = fs / 8000;
output_size_samples_ = kOutputSizeMs * 8 * fs_mult_;
@@ -113,9 +112,7 @@
}
}
-NetEqImpl::~NetEqImpl() {
- LOG(LS_INFO) << "Deleting NetEqImpl object.";
-}
+NetEqImpl::~NetEqImpl() = default;
int NetEqImpl::InsertPacket(const WebRtcRTPHeader& rtp_header,
const uint8_t* payload,
@@ -130,7 +127,6 @@
int error = InsertPacketInternal(rtp_header, payload, length_bytes,
receive_timestamp, false);
if (error != 0) {
- LOG_FERR1(LS_WARNING, InsertPacketInternal, error);
error_code_ = error;
return kFail;
}
@@ -151,7 +147,6 @@
rtp_header, kSyncPayload, sizeof(kSyncPayload), receive_timestamp, true);
if (error != 0) {
- LOG_FERR1(LS_WARNING, InsertPacketInternal, error);
error_code_ = error;
return kFail;
}
@@ -168,7 +163,6 @@
LOG(LS_VERBOSE) << "Produced " << *samples_per_channel <<
" samples/channel for " << *num_channels << " channel(s)";
if (error != 0) {
- LOG_FERR1(LS_WARNING, GetAudioInternal, error);
error_code_ = error;
return kFail;
}
@@ -181,11 +175,10 @@
int NetEqImpl::RegisterPayloadType(enum NetEqDecoder codec,
uint8_t rtp_payload_type) {
CriticalSectionScoped lock(crit_sect_.get());
- LOG_API2(static_cast<int>(rtp_payload_type), codec);
+ LOG(LS_VERBOSE) << "RegisterPayloadType "
+ << static_cast<int>(rtp_payload_type) << " " << codec;
int ret = decoder_database_->RegisterPayload(rtp_payload_type, codec);
if (ret != DecoderDatabase::kOK) {
- LOG_FERR2(LS_WARNING, RegisterPayload, static_cast<int>(rtp_payload_type),
- codec);
switch (ret) {
case DecoderDatabase::kInvalidRtpPayloadType:
error_code_ = kInvalidRtpPayloadType;
@@ -209,7 +202,8 @@
uint8_t rtp_payload_type,
int sample_rate_hz) {
CriticalSectionScoped lock(crit_sect_.get());
- LOG_API2(static_cast<int>(rtp_payload_type), codec);
+ LOG(LS_VERBOSE) << "RegisterExternalDecoder "
+ << static_cast<int>(rtp_payload_type) << " " << codec;
if (!decoder) {
LOG(LS_ERROR) << "Cannot register external decoder with NULL pointer";
assert(false);
@@ -218,8 +212,6 @@
int ret = decoder_database_->InsertExternal(rtp_payload_type, codec,
sample_rate_hz, decoder);
if (ret != DecoderDatabase::kOK) {
- LOG_FERR2(LS_WARNING, InsertExternal, static_cast<int>(rtp_payload_type),
- codec);
switch (ret) {
case DecoderDatabase::kInvalidRtpPayloadType:
error_code_ = kInvalidRtpPayloadType;
@@ -246,7 +238,6 @@
int NetEqImpl::RemovePayloadType(uint8_t rtp_payload_type) {
CriticalSectionScoped lock(crit_sect_.get());
- LOG_API1(static_cast<int>(rtp_payload_type));
int ret = decoder_database_->Remove(rtp_payload_type);
if (ret == DecoderDatabase::kOK) {
return kOK;
@@ -255,7 +246,6 @@
} else {
error_code_ = kOtherError;
}
- LOG_FERR1(LS_WARNING, Remove, static_cast<int>(rtp_payload_type));
return kFail;
}
@@ -389,7 +379,7 @@
void NetEqImpl::FlushBuffers() {
CriticalSectionScoped lock(crit_sect_.get());
- LOG_API0();
+ LOG(LS_VERBOSE) << "FlushBuffers";
packet_buffer_->Flush();
assert(sync_buffer_.get());
assert(expand_.get());
@@ -517,7 +507,6 @@
if (decoder_database_->IsRed(main_header.payloadType)) {
assert(!is_sync_packet); // We had a sanity check for this.
if (payload_splitter_->SplitRed(&packet_list) != PayloadSplitter::kOK) {
- LOG_FERR1(LS_WARNING, SplitRed, packet_list.size());
PacketBuffer::DeleteAllPackets(&packet_list);
return kRedundancySplitError;
}
@@ -532,7 +521,6 @@
// Check payload types.
if (decoder_database_->CheckPayloadTypes(packet_list) ==
DecoderDatabase::kDecoderNotFound) {
- LOG_FERR1(LS_WARNING, CheckPayloadTypes, packet_list.size());
PacketBuffer::DeleteAllPackets(&packet_list);
return kUnknownRtpPayloadType;
}
@@ -556,13 +544,10 @@
current_packet->payload_length,
&event);
if (ret != DtmfBuffer::kOK) {
- LOG_FERR2(LS_WARNING, ParseEvent, ret,
- current_packet->payload_length);
PacketBuffer::DeleteAllPackets(&packet_list);
return kDtmfParsingError;
}
if (dtmf_buffer_->InsertEvent(event) != DtmfBuffer::kOK) {
- LOG_FERR0(LS_WARNING, InsertEvent);
PacketBuffer::DeleteAllPackets(&packet_list);
return kDtmfInsertError;
}
@@ -578,7 +563,6 @@
// Check for FEC in packets, and separate payloads into several packets.
int ret = payload_splitter_->SplitFec(&packet_list, decoder_database_.get());
if (ret != PayloadSplitter::kOK) {
- LOG_FERR1(LS_WARNING, SplitFec, packet_list.size());
PacketBuffer::DeleteAllPackets(&packet_list);
switch (ret) {
case PayloadSplitter::kUnknownPayloadType:
@@ -593,7 +577,6 @@
// sync-packets.
ret = payload_splitter_->SplitAudio(&packet_list, *decoder_database_);
if (ret != PayloadSplitter::kOK) {
- LOG_FERR1(LS_WARNING, SplitAudio, packet_list.size());
PacketBuffer::DeleteAllPackets(&packet_list);
switch (ret) {
case PayloadSplitter::kUnknownPayloadType:
@@ -630,9 +613,7 @@
// Reset DSP timestamp etc. if packet buffer flushed.
new_codec_ = true;
update_sample_rate_and_channels = true;
- LOG_F(LS_WARNING) << "Packet buffer flushed";
} else if (ret != PacketBuffer::kOK) {
- LOG_FERR1(LS_WARNING, InsertPacketList, packet_list.size());
PacketBuffer::DeleteAllPackets(&packet_list);
return kOtherError;
}
@@ -716,7 +697,6 @@
int return_value = GetDecision(&operation, &packet_list, &dtmf_event,
&play_dtmf);
if (return_value != 0) {
- LOG_FERR1(LS_WARNING, GetDecision, return_value);
assert(false);
last_mode_ = kModeError;
return return_value;
@@ -807,7 +787,7 @@
break;
}
case kUndefined: {
- LOG_F(LS_ERROR) << "Invalid operation kUndefined.";
+ LOG(LS_ERROR) << "Invalid operation kUndefined.";
assert(false); // This should not happen.
last_mode_ = kModeError;
return kInvalidOperation;
@@ -834,15 +814,17 @@
num_output_samples_per_channel = static_cast<int>(
max_length / sync_buffer_->Channels());
}
- int samples_from_sync = static_cast<int>(
- sync_buffer_->GetNextAudioInterleaved(num_output_samples_per_channel,
- output));
+ const int samples_from_sync =
+ static_cast<int>(sync_buffer_->GetNextAudioInterleaved(
+ num_output_samples_per_channel, output));
*num_channels = static_cast<int>(sync_buffer_->Channels());
LOG(LS_VERBOSE) << "Sync buffer (" << *num_channels << " channel(s)):" <<
" insert " << algorithm_buffer_->Size() << " samples, extract " <<
samples_from_sync << " samples";
if (samples_from_sync != output_size_samples_) {
- LOG_F(LS_ERROR) << "samples_from_sync != output_size_samples_";
+ LOG(LS_ERROR) << "samples_from_sync (" << samples_from_sync
+ << ") != output_size_samples_ (" << output_size_samples_
+ << ")";
// TODO(minyue): treatment of under-run, filling zeros
memset(output, 0, num_output_samples * sizeof(int16_t));
*samples_per_channel = output_size_samples_;
@@ -983,7 +965,7 @@
} else {
assert(header);
if (!header) {
- LOG_F(LS_ERROR) << "Packet missing where it shouldn't.";
+ LOG(LS_ERROR) << "Packet missing where it shouldn't.";
return -1;
}
timestamp_ = header->timestamp;
@@ -1129,7 +1111,6 @@
extracted_samples = ExtractPackets(required_samples, packet_list);
if (extracted_samples < 0) {
- LOG_F(LS_WARNING) << "Failed to extract packets from buffer.";
return kPacketBufferCorruption;
}
}
@@ -1165,7 +1146,8 @@
decoder = decoder_database_->GetDecoder(payload_type);
assert(decoder);
if (!decoder) {
- LOG_FERR1(LS_WARNING, GetDecoder, static_cast<int>(payload_type));
+ LOG(LS_WARNING) << "Unknown payload type "
+ << static_cast<int>(payload_type);
PacketBuffer::DeleteAllPackets(packet_list);
return kDecoderNotFound;
}
@@ -1177,7 +1159,8 @@
->GetDecoderInfo(payload_type);
assert(decoder_info);
if (!decoder_info) {
- LOG_FERR1(LS_WARNING, GetDecoderInfo, static_cast<int>(payload_type));
+ LOG(LS_WARNING) << "Unknown payload type "
+ << static_cast<int>(payload_type);
PacketBuffer::DeleteAllPackets(packet_list);
return kDecoderNotFound;
}
@@ -1239,11 +1222,12 @@
// Got some error code from the decoder.
decoder_error_code_ = error_code;
return_value = kDecoderErrorCode;
+ LOG(LS_WARNING) << "Decoder returned error code: " << error_code;
} else {
// Decoder does not implement error codes. Return generic error.
return_value = kOtherDecoderError;
+ LOG(LS_WARNING) << "Decoder error (no error code)";
}
- LOG_FERR2(LS_WARNING, DecodeLoop, error_code, packet_list->size());
*operation = kExpand; // Do expansion to get data instead.
}
if (*speech_type != AudioDecoder::kComfortNoise) {
@@ -1329,14 +1313,14 @@
<< decoder_frame_length_ << " samples per channel)";
} else if (decode_length < 0) {
// Error.
- LOG_FERR2(LS_WARNING, Decode, decode_length, payload_length);
+ LOG(LS_WARNING) << "Decode " << decode_length << " " << payload_length;
*decoded_length = -1;
PacketBuffer::DeleteAllPackets(packet_list);
break;
}
if (*decoded_length > static_cast<int>(decoded_buffer_length_)) {
// Guard against overflow.
- LOG_F(LS_WARNING) << "Decoded too much.";
+ LOG(LS_WARNING) << "Decoded too much.";
PacketBuffer::DeleteAllPackets(packet_list);
return kDecodedTooMuch;
}
@@ -1614,7 +1598,6 @@
// UpdateParameters() deletes |packet|.
if (comfort_noise_->UpdateParameters(packet) ==
ComfortNoise::kInternalError) {
- LOG_FERR0(LS_WARNING, UpdateParameters);
algorithm_buffer_->Zeros(output_size_samples_);
return -comfort_noise_->internal_error_code();
}
@@ -1627,11 +1610,9 @@
dtmf_tone_generator_->Reset();
}
if (cn_return == ComfortNoise::kInternalError) {
- LOG_FERR1(LS_WARNING, comfort_noise_->Generate, cn_return);
decoder_error_code_ = comfort_noise_->internal_error_code();
return kComfortNoiseErrorCode;
} else if (cn_return == ComfortNoise::kUnknownPayloadType) {
- LOG_FERR1(LS_WARNING, comfort_noise_->Generate, cn_return);
return kUnknownRtpPayloadType;
}
return 0;
@@ -1800,6 +1781,7 @@
const RTPHeader* header = packet_buffer_->NextRtpHeader();
assert(header);
if (!header) {
+ LOG(LS_ERROR) << "Packet buffer unexpectedly empty.";
return -1;
}
uint32_t first_timestamp = header->timestamp;
@@ -1813,8 +1795,7 @@
// |header| may be invalid after the |packet_buffer_| operation.
header = NULL;
if (!packet) {
- LOG_FERR1(LS_ERROR, GetNextPacket, discard_count) <<
- "Should always be able to extract a packet here";
+ LOG(LS_ERROR) << "Should always be able to extract a packet here";
assert(false); // Should always be able to extract a packet here.
return -1;
}
@@ -1850,9 +1831,8 @@
}
}
} else {
- LOG_FERR1(LS_WARNING, GetDecoder,
- static_cast<int>(packet->header.payloadType))
- << "Could not find a decoder for a packet about to be extracted.";
+ LOG(LS_WARNING) << "Unknown payload type "
+ << static_cast<int>(packet->header.payloadType);
assert(false);
}
if (packet_duration <= 0) {
@@ -1899,7 +1879,7 @@
}
void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) {
- LOG_API2(fs_hz, channels);
+ LOG(LS_VERBOSE) << "SetSampleRateAndChannels " << fs_hz << " " << channels;
// TODO(hlundin): Change to an enumerator and skip assert.
assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000);
assert(channels > 0);