Fixing lint warnings from previous commit
In this CL I have removed (almost) all lint warnings I got for this commit:
https://code.google.com/p/webrtc/source/detail?r=3454.
The only warning not fixed is a warning about usage of non-const reference. This will be fixed in a separate CL.
BUG=issue1372
Review URL: https://webrtc-codereview.appspot.com/1091006
git-svn-id: http://webrtc.googlecode.com/svn/trunk@3510 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/main/source/acm_codec_database.cc b/webrtc/modules/audio_coding/main/source/acm_codec_database.cc
index fa7688f..6a650c7 100644
--- a/webrtc/modules/audio_coding/main/source/acm_codec_database.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_codec_database.cc
@@ -17,8 +17,6 @@
// references, where appropriate.
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
-#include <stdio.h>
-
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/system_wrappers/interface/trace.h"
@@ -34,11 +32,11 @@
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#ifdef WEBRTC_CODEC_ISAC
#include "webrtc/modules/audio_coding/codecs/isac/main/interface/isac.h"
-#include "webrtc/modules/audio_coding/main/source/acm_isac.h"
-#include "webrtc/modules/audio_coding/main/source/acm_isac_macros.h"
#endif
#ifdef WEBRTC_CODEC_ISACFX
#include "webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h"
+#endif
+#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
#include "webrtc/modules/audio_coding/main/source/acm_isac.h"
#include "webrtc/modules/audio_coding/main/source/acm_isac_macros.h"
#endif
@@ -51,15 +49,15 @@
#include "webrtc/modules/audio_coding/main/source/acm_ilbc.h"
#endif
#ifdef WEBRTC_CODEC_AMR
-#include "amr_interface.h"
+#include "webrtc/modules/audio_coding/codecs/amr/include/amr_interface.h"
#include "webrtc/modules/audio_coding/main/source/acm_amr.h"
#endif
#ifdef WEBRTC_CODEC_AMRWB
-#include "amrwb_interface.h"
+#include "webrtc/modules/audio_coding/codecs/amrwb/include/amrwb_interface.h"
#include "webrtc/modules/audio_coding/main/source/acm_amrwb.h"
#endif
#ifdef WEBRTC_CODEC_CELT
-#include "celt_interface.h"
+#include "webrtc/modules/audio_coding/codecs/celt/include/celt_interface.h"
#include "webrtc/modules/audio_coding/main/source/acm_celt.h"
#endif
#ifdef WEBRTC_CODEC_G722
@@ -67,23 +65,23 @@
#include "webrtc/modules/audio_coding/main/source/acm_g722.h"
#endif
#ifdef WEBRTC_CODEC_G722_1
-#include "g7221_interface.h"
+#include "webrtc/modules/audio_coding/codecs/g7221/include/g7221_interface.h"
#include "webrtc/modules/audio_coding/main/source/acm_g7221.h"
#endif
#ifdef WEBRTC_CODEC_G722_1C
-#include "g7221c_interface.h"
+#include "webrtc/modules/audio_coding/codecs/g7221c/include/g7221c_interface.h"
#include "webrtc/modules/audio_coding/main/source/acm_g7221c.h"
#endif
#ifdef WEBRTC_CODEC_G729
-#include "g729_interface.h"
+#include "webrtc/modules/audio_coding/codecs/g729/include/g729_interface.h"
#include "webrtc/modules/audio_coding/main/source/acm_g729.h"
#endif
#ifdef WEBRTC_CODEC_G729_1
-#include "g7291_interface.h"
+#include "webrtc/modules/audio_coding/codecs/g7291/include/g7291_interface.h"
#include "webrtc/modules/audio_coding/main/source/acm_g7291.h"
#endif
#ifdef WEBRTC_CODEC_GSMFR
-#include "gsmfr_interface.h"
+#include "webrtc/modules/audio_coding/codecs/gsmfr/include/gsmfr_interface.h"
#include "webrtc/modules/audio_coding/main/source/acm_gsmfr.h"
#endif
#ifdef WEBRTC_CODEC_OPUS
@@ -91,7 +89,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_opus.h"
#endif
#ifdef WEBRTC_CODEC_SPEEX
-#include "speex_interface.h"
+#include "webrtc/modules/audio_coding/codecs/speex/include/speex_interface.h"
#include "webrtc/modules/audio_coding/main/source/acm_speex.h"
#endif
#ifdef WEBRTC_CODEC_AVT
@@ -418,45 +416,6 @@
};
// Gets the codec id number from the database. If there is some mismatch in
-// the codec settings, an error message will be recorded in the error string.
-// NOTE! Only the first mismatch found will be recorded in the error string.
-int ACMCodecDB::CodecNumber(const CodecInst* codec_inst, int* mirror_id,
- char* err_message, int max_message_len_byte) {
- int codec_id = ACMCodecDB::CodecNumber(codec_inst, mirror_id);
-
- // Write error message if ACMCodecDB::CodecNumber() returned error.
- if ((codec_id < 0) && (err_message != NULL)) {
- char my_err_msg[1000];
-
- if (codec_id == kInvalidCodec) {
- sprintf(my_err_msg, "Call to ACMCodecDB::CodecNumber failed, Codec not "
- "found");
- } else if (codec_id == kInvalidPayloadtype) {
- sprintf(my_err_msg, "Call to ACMCodecDB::CodecNumber failed, payload "
- "number %d is out of range for %s", codec_inst->pltype,
- codec_inst->plname);
- } else if (codec_id == kInvalidPacketSize) {
- sprintf(my_err_msg, "Call to ACMCodecDB::CodecNumber failed, Packet "
- "size is out of range for %s", codec_inst->plname);
- } else if (codec_id == kInvalidRate) {
- sprintf(my_err_msg, "Call to ACMCodecDB::CodecNumber failed, rate=%d "
- "is not a valid rate for %s", codec_inst->rate,
- codec_inst->plname);
- } else {
- // Other error
- sprintf(my_err_msg, "invalid codec parameters to be registered, "
- "ACMCodecDB::CodecNumber failed");
- }
-
- strncpy(err_message, my_err_msg, max_message_len_byte - 1);
- // make sure that the message is null-terminated.
- err_message[max_message_len_byte - 1] = '\0';
- }
-
- return codec_id;
-}
-
-// Gets the codec id number from the database. If there is some mismatch in
// the codec settings, the function will return an error code.
// NOTE! The first mismatch found will generate the return value.
int ACMCodecDB::CodecNumber(const CodecInst* codec_inst, int* mirror_id) {
diff --git a/webrtc/modules/audio_coding/main/source/acm_codec_database.h b/webrtc/modules/audio_coding/main/source/acm_codec_database.h
index 0ea7741..55f08d1 100644
--- a/webrtc/modules/audio_coding/main/source/acm_codec_database.h
+++ b/webrtc/modules/audio_coding/main/source/acm_codec_database.h
@@ -240,14 +240,8 @@
// Output:
// [mirror_id] - mirror id, which most often is the same as the return
// value, see above.
- // [err_message] - if present, in the event of a mismatch found between the
- // input and the database, a descriptive error message is
- // written here.
- // [err_message] - if present, the length of error message is returned here.
// Return:
// codec id if successful, otherwise < 0.
- static int CodecNumber(const CodecInst* codec_inst, int* mirror_id,
- char* err_message, int max_message_len_byte);
static int CodecNumber(const CodecInst* codec_inst, int* mirror_id);
static int CodecId(const CodecInst* codec_inst);
static int CodecId(const char* payload_name, int frequency, int channels);
diff --git a/webrtc/modules/audio_coding/main/source/acm_opus.cc b/webrtc/modules/audio_coding/main/source/acm_opus.cc
index 5648ee3..8ea5d51 100644
--- a/webrtc/modules/audio_coding/main/source/acm_opus.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_opus.cc
@@ -270,7 +270,7 @@
void ACMOpus::InternalDestructEncoderInst(void* ptr_inst) {
if (ptr_inst != NULL) {
- WebRtcOpus_EncoderFree((OpusEncInst*) ptr_inst);
+ WebRtcOpus_EncoderFree(reinterpret_cast<OpusEncInst*>(ptr_inst));
}
return;
}
diff --git a/webrtc/modules/audio_coding/main/source/audio_coding_module.cc b/webrtc/modules/audio_coding/main/source/audio_coding_module.cc
index 6891305..dc69762 100644
--- a/webrtc/modules/audio_coding/main/source/audio_coding_module.cc
+++ b/webrtc/modules/audio_coding/main/source/audio_coding_module.cc
@@ -78,12 +78,12 @@
// Checks the validity of the parameters of the given codec
bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
int mirror_id;
- char err_msg[500];
- int codec_number = ACMCodecDB::CodecNumber(&codec, &mirror_id, err_msg, 500);
+ int codec_number = ACMCodecDB::CodecNumber(&codec, &mirror_id);
if (codec_number < 0) {
- WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, err_msg);
+ WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1,
+ "Invalid codec settings.");
return false;
} else {
return true;
diff --git a/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc
index 99761c0..4211be8 100644
--- a/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc
+++ b/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc
@@ -274,7 +274,7 @@
CriticalSectionScoped lock(acm_crit_sect_);
id_ = id;
- for (int i = 0; i < ACMCodecDB::kMaxNumCodecs; i++) {
+ for (int i = 0; i < ACMCodecDB::kMaxNumCodecs; i++) {
if (codecs_[i] != NULL) {
codecs_[i]->SetUniqueID(id);
}
@@ -802,12 +802,10 @@
return -1;
}
- char error_message[500];
- int codec_id = ACMCodecDB::CodecNumber(&send_codec, mirror_id, error_message,
- sizeof(error_message));
+ int codec_id = ACMCodecDB::CodecNumber(&send_codec, mirror_id);
if (codec_id < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, acm_id,
- error_message);
+ "Invalid settings for the send codec.");
return -1;
}
@@ -1471,7 +1469,8 @@
timestamp_diff = in_frame.timestamp_ - last_in_timestamp_;
}
preprocess_frame_.timestamp_ = last_timestamp_ +
- (WebRtc_UWord32)(timestamp_diff * ((double) send_codec_inst_.plfreq /
+ static_cast<uint32_t>(timestamp_diff *
+ (static_cast<double>(send_codec_inst_.plfreq) /
static_cast<double>(in_frame.sample_rate_hz_)));
preprocess_frame_.samples_per_channel_ = input_resampler_.Resample10Msec(
@@ -1546,7 +1545,7 @@
&& (mode != VADAggr) && (mode != VADVeryAggr)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
"Invalid VAD Mode %d, no change is made to VAD/DTX status",
- (int) mode);
+ static_cast<int>(mode));
return -1;
}
diff --git a/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc b/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc
index 5a59053..46a5897 100644
--- a/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc
+++ b/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc
@@ -8,21 +8,21 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "TestAllCodecs.h"
+#include "webrtc/modules/audio_coding/main/test/TestAllCodecs.h"
#include <stdio.h>
#include <string>
#include "gtest/gtest.h"
-#include "audio_coding_module.h"
-#include "audio_coding_module_typedefs.h"
-#include "common_types.h"
-#include "engine_configurations.h"
-#include "testsupport/fileutils.h"
-#include "trace.h"
-#include "typedefs.h"
-#include "utility.h"
+#include "webrtc/common_types.h"
+#include "webrtc/engine_configurations.h"
+#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
+#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
+#include "webrtc/modules/audio_coding/main/test/utility.h"
+#include "webrtc/system_wrappers/interface/trace.h"
+#include "webrtc/test/testsupport/fileutils.h"
+#include "webrtc/typedefs.h"
// Description of the test:
// In this test we set up a one-way communication channel from a participant
@@ -127,7 +127,6 @@
}
void TestAllCodecs::Perform() {
-
const std::string file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
infile_a_.Open(file_name, 32000, "rb");
diff --git a/webrtc/modules/audio_coding/main/test/TestStereo.cc b/webrtc/modules/audio_coding/main/test/TestStereo.cc
index 52508e2..b06f19d 100644
--- a/webrtc/modules/audio_coding/main/test/TestStereo.cc
+++ b/webrtc/modules/audio_coding/main/test/TestStereo.cc
@@ -8,19 +8,19 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "TestStereo.h"
+#include "webrtc/modules/audio_coding/main/test/TestStereo.h"
#include <cassert>
-#include <iostream>
+#include <string>
#include "gtest/gtest.h"
-#include "audio_coding_module_typedefs.h"
-#include "common_types.h"
-#include "engine_configurations.h"
-#include "testsupport/fileutils.h"
-#include "trace.h"
-#include "utility.h"
+#include "webrtc/common_types.h"
+#include "webrtc/engine_configurations.h"
+#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
+#include "webrtc/modules/audio_coding/main/test/utility.h"
+#include "webrtc/system_wrappers/interface/trace.h"
+#include "webrtc/test/testsupport/fileutils.h"
namespace webrtc {
@@ -65,10 +65,10 @@
if (lost_packet_ == false) {
if (frame_type != kAudioFrameCN) {
rtp_info.type.Audio.isCNG = false;
- rtp_info.type.Audio.channel = (int) codec_mode_;
+ rtp_info.type.Audio.channel = static_cast<int>(codec_mode_);
} else {
rtp_info.type.Audio.isCNG = true;
- rtp_info.type.Audio.channel = (int) kMono;
+ rtp_info.type.Audio.channel = static_cast<int>(kMono);
}
status = receiver_acm_->IncomingPacket(payload_data, payload_size,
rtp_info);
@@ -245,7 +245,7 @@
#ifdef WEBRTC_CODEC_G722
if (test_mode_ != 0) {
printf("===========================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-stereo\n");
}
channel_a2b_->set_codec_mode(kStereo);
@@ -275,7 +275,7 @@
#ifdef WEBRTC_CODEC_PCM16
if (test_mode_ != 0) {
printf("===========================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-stereo\n");
}
channel_a2b_->set_codec_mode(kStereo);
@@ -298,7 +298,7 @@
if (test_mode_ != 0) {
printf("===========================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-stereo\n");
}
test_cntr_++;
@@ -319,7 +319,7 @@
if (test_mode_ != 0) {
printf("===========================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-stereo\n");
}
test_cntr_++;
@@ -414,7 +414,7 @@
#ifdef WEBRTC_CODEC_CELT
if (test_mode_ != 0) {
printf("===========================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-stereo\n");
}
channel_a2b_->set_codec_mode(kStereo);
@@ -437,7 +437,7 @@
#ifdef WEBRTC_CODEC_OPUS
if (test_mode_ != 0) {
printf("===========================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-stereo\n");
}
channel_a2b_->set_codec_mode(kStereo);
@@ -481,7 +481,7 @@
#ifdef WEBRTC_CODEC_G722
if (test_mode_ != 0) {
printf("===============================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Mono-to-stereo\n");
}
test_cntr_++;
@@ -495,7 +495,7 @@
#ifdef WEBRTC_CODEC_PCM16
if (test_mode_ != 0) {
printf("===============================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Mono-to-stereo\n");
}
test_cntr_++;
@@ -507,7 +507,7 @@
out_file_.Close();
if (test_mode_ != 0) {
printf("===============================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Mono-to-stereo\n");
}
test_cntr_++;
@@ -518,7 +518,7 @@
out_file_.Close();
if (test_mode_ != 0) {
printf("===============================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Mono-to-stereo\n");
}
test_cntr_++;
@@ -531,7 +531,7 @@
#ifdef PCMA_AND_PCMU
if (test_mode_ != 0) {
printf("===============================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Mono-to-stereo\n");
}
test_cntr_++;
@@ -548,7 +548,7 @@
#ifdef WEBRTC_CODEC_CELT
if (test_mode_ != 0) {
printf("===============================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Mono-to-stereo\n");
}
test_cntr_++;
@@ -562,7 +562,7 @@
#ifdef WEBRTC_CODEC_OPUS
if (test_mode_ != 0) {
printf("===============================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Mono-to-stereo\n");
}
@@ -591,7 +591,7 @@
// Run stereo audio and mono codec.
if (test_mode_ != 0) {
printf("===============================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-mono\n");
}
test_cntr_++;
@@ -613,7 +613,7 @@
#ifdef WEBRTC_CODEC_PCM16
if (test_mode_ != 0) {
printf("===============================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-mono\n");
}
test_cntr_++;
@@ -624,9 +624,9 @@
out_file_.Close();
if (test_mode_ != 0) {
printf("===============================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-mono\n");
- }
+ }
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels,
@@ -635,20 +635,20 @@
out_file_.Close();
if (test_mode_ != 0) {
printf("==============================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-mono\n");
- }
- test_cntr_++;
- OpenOutFile(test_cntr_);
- RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels,
- l16_32khz_pltype_);
- Run(channel_a2b_, audio_channels, codec_channels);
- out_file_.Close();
+ }
+ test_cntr_++;
+ OpenOutFile(test_cntr_);
+ RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels,
+ l16_32khz_pltype_);
+ Run(channel_a2b_, audio_channels, codec_channels);
+ out_file_.Close();
#endif
#ifdef PCMA_AND_PCMU
if (test_mode_ != 0) {
printf("===============================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-mono\n");
}
test_cntr_++;
@@ -664,7 +664,7 @@
#ifdef WEBRTC_CODEC_CELT
if (test_mode_ != 0) {
printf("===============================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-mono\n");
}
test_cntr_++;
@@ -677,7 +677,7 @@
#ifdef WEBRTC_CODEC_OPUS
if (test_mode_ != 0) {
printf("===============================================================\n");
- printf("Test number: %d\n",test_cntr_ + 1);
+ printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-mono\n");
}
test_cntr_++;
@@ -794,11 +794,13 @@
// For Celt the packet size in bytes is already counting the stereo part.
if (!strcmp(codec_name, "CELT")) {
pack_size_bytes_ = (WebRtc_UWord16)(
- (float) (pack_size * rate) / (float) (sampling_freq_hz * 8) + 0.875)
+ static_cast<float>(pack_size * rate) /
+ static_cast<float>(sampling_freq_hz * 8) + 0.875)
/ channels;
} else {
pack_size_bytes_ = (WebRtc_UWord16)(
- (float) (pack_size * rate) / (float) (sampling_freq_hz * 8) + 0.875);
+ static_cast<float>(pack_size * rate) /
+ static_cast<float>(sampling_freq_hz * 8) + 0.875);
}
// Set pointer to the ACM where to register the codec