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
This commit is contained in:
tina.legrand@webrtc.org
2013-02-14 09:28:10 +00:00
parent 45eab19e7d
commit a092cbf9b7
7 changed files with 72 additions and 119 deletions

View File

@@ -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
@@ -417,45 +415,6 @@ enum {
kInvalidRate = -50
};
// 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.

View File

@@ -240,14 +240,8 @@ class ACMCodecDB {
// 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);

View File

@@ -270,7 +270,7 @@ void ACMOpus::DestructDecoderSafe() {
void ACMOpus::InternalDestructEncoderInst(void* ptr_inst) {
if (ptr_inst != NULL) {
WebRtcOpus_EncoderFree((OpusEncInst*) ptr_inst);
WebRtcOpus_EncoderFree(reinterpret_cast<OpusEncInst*>(ptr_inst));
}
return;
}

View File

@@ -78,12 +78,12 @@ WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
// 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;

View File

@@ -802,12 +802,10 @@ static int IsValidSendCodec(const CodecInst& send_codec,
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 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame,
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 @@ int AudioCodingModuleImpl::SetVADSafe(bool enable_dtx,
&& (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;
}

View File

@@ -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 @@ TestAllCodecs::~TestAllCodecs() {
}
void TestAllCodecs::Perform() {
const std::string file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
infile_a_.Open(file_name, 32000, "rb");

View File

@@ -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 @@ WebRtc_Word32 TestPackStereo::SendData(
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 @@ void TestStereo::Perform() {
#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 @@ void TestStereo::Perform() {
#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 @@ void TestStereo::Perform() {
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 @@ void TestStereo::Perform() {
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 @@ void TestStereo::Perform() {
#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 @@ void TestStereo::Perform() {
#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 @@ void TestStereo::Perform() {
#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 @@ void TestStereo::Perform() {
#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 @@ void TestStereo::Perform() {
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 @@ void TestStereo::Perform() {
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 @@ void TestStereo::Perform() {
#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 @@ void TestStereo::Perform() {
#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 @@ void TestStereo::Perform() {
#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 @@ void TestStereo::Perform() {
// 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 @@ void TestStereo::Perform() {
#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,7 +624,7 @@ void TestStereo::Perform() {
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_++;
@@ -635,7 +635,7 @@ void TestStereo::Perform() {
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_++;
@@ -648,7 +648,7 @@ void TestStereo::Perform() {
#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 @@ void TestStereo::Perform() {
#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 @@ void TestStereo::Perform() {
#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 @@ void TestStereo::RegisterSendCodec(char side, char* codec_name,
// 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