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. // references, where appropriate.
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h" #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/modules/audio_coding/main/source/acm_common_defs.h"
#include "webrtc/system_wrappers/interface/trace.h" #include "webrtc/system_wrappers/interface/trace.h"
@@ -34,11 +32,11 @@
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h" #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
#ifdef WEBRTC_CODEC_ISAC #ifdef WEBRTC_CODEC_ISAC
#include "webrtc/modules/audio_coding/codecs/isac/main/interface/isac.h" #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 #endif
#ifdef WEBRTC_CODEC_ISACFX #ifdef WEBRTC_CODEC_ISACFX
#include "webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h" #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.h"
#include "webrtc/modules/audio_coding/main/source/acm_isac_macros.h" #include "webrtc/modules/audio_coding/main/source/acm_isac_macros.h"
#endif #endif
@@ -51,15 +49,15 @@
#include "webrtc/modules/audio_coding/main/source/acm_ilbc.h" #include "webrtc/modules/audio_coding/main/source/acm_ilbc.h"
#endif #endif
#ifdef WEBRTC_CODEC_AMR #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" #include "webrtc/modules/audio_coding/main/source/acm_amr.h"
#endif #endif
#ifdef WEBRTC_CODEC_AMRWB #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" #include "webrtc/modules/audio_coding/main/source/acm_amrwb.h"
#endif #endif
#ifdef WEBRTC_CODEC_CELT #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" #include "webrtc/modules/audio_coding/main/source/acm_celt.h"
#endif #endif
#ifdef WEBRTC_CODEC_G722 #ifdef WEBRTC_CODEC_G722
@@ -67,23 +65,23 @@
#include "webrtc/modules/audio_coding/main/source/acm_g722.h" #include "webrtc/modules/audio_coding/main/source/acm_g722.h"
#endif #endif
#ifdef WEBRTC_CODEC_G722_1 #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" #include "webrtc/modules/audio_coding/main/source/acm_g7221.h"
#endif #endif
#ifdef WEBRTC_CODEC_G722_1C #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" #include "webrtc/modules/audio_coding/main/source/acm_g7221c.h"
#endif #endif
#ifdef WEBRTC_CODEC_G729 #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" #include "webrtc/modules/audio_coding/main/source/acm_g729.h"
#endif #endif
#ifdef WEBRTC_CODEC_G729_1 #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" #include "webrtc/modules/audio_coding/main/source/acm_g7291.h"
#endif #endif
#ifdef WEBRTC_CODEC_GSMFR #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" #include "webrtc/modules/audio_coding/main/source/acm_gsmfr.h"
#endif #endif
#ifdef WEBRTC_CODEC_OPUS #ifdef WEBRTC_CODEC_OPUS
@@ -91,7 +89,7 @@
#include "webrtc/modules/audio_coding/main/source/acm_opus.h" #include "webrtc/modules/audio_coding/main/source/acm_opus.h"
#endif #endif
#ifdef WEBRTC_CODEC_SPEEX #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" #include "webrtc/modules/audio_coding/main/source/acm_speex.h"
#endif #endif
#ifdef WEBRTC_CODEC_AVT #ifdef WEBRTC_CODEC_AVT
@@ -417,45 +415,6 @@ enum {
kInvalidRate = -50 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 // Gets the codec id number from the database. If there is some mismatch in
// the codec settings, the function will return an error code. // the codec settings, the function will return an error code.
// NOTE! The first mismatch found will generate the return value. // NOTE! The first mismatch found will generate the return value.

View File

@@ -240,14 +240,8 @@ class ACMCodecDB {
// Output: // Output:
// [mirror_id] - mirror id, which most often is the same as the return // [mirror_id] - mirror id, which most often is the same as the return
// value, see above. // 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: // Return:
// codec id if successful, otherwise < 0. // 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 CodecNumber(const CodecInst* codec_inst, int* mirror_id);
static int CodecId(const CodecInst* codec_inst); static int CodecId(const CodecInst* codec_inst);
static int CodecId(const char* payload_name, int frequency, int channels); 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) { void ACMOpus::InternalDestructEncoderInst(void* ptr_inst) {
if (ptr_inst != NULL) { if (ptr_inst != NULL) {
WebRtcOpus_EncoderFree((OpusEncInst*) ptr_inst); WebRtcOpus_EncoderFree(reinterpret_cast<OpusEncInst*>(ptr_inst));
} }
return; 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 // Checks the validity of the parameters of the given codec
bool AudioCodingModule::IsCodecValid(const CodecInst& codec) { bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
int mirror_id; 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) { 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; return false;
} else { } else {
return true; return true;

View File

@@ -802,12 +802,10 @@ static int IsValidSendCodec(const CodecInst& send_codec,
return -1; return -1;
} }
char error_message[500]; int codec_id = ACMCodecDB::CodecNumber(&send_codec, mirror_id);
int codec_id = ACMCodecDB::CodecNumber(&send_codec, mirror_id, error_message,
sizeof(error_message));
if (codec_id < 0) { if (codec_id < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, acm_id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, acm_id,
error_message); "Invalid settings for the send codec.");
return -1; return -1;
} }
@@ -1471,7 +1469,8 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame,
timestamp_diff = in_frame.timestamp_ - last_in_timestamp_; timestamp_diff = in_frame.timestamp_ - last_in_timestamp_;
} }
preprocess_frame_.timestamp_ = last_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_))); static_cast<double>(in_frame.sample_rate_hz_)));
preprocess_frame_.samples_per_channel_ = input_resampler_.Resample10Msec( preprocess_frame_.samples_per_channel_ = input_resampler_.Resample10Msec(
@@ -1546,7 +1545,7 @@ int AudioCodingModuleImpl::SetVADSafe(bool enable_dtx,
&& (mode != VADAggr) && (mode != VADVeryAggr)) { && (mode != VADAggr) && (mode != VADVeryAggr)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
"Invalid VAD Mode %d, no change is made to VAD/DTX status", "Invalid VAD Mode %d, no change is made to VAD/DTX status",
(int) mode); static_cast<int>(mode));
return -1; return -1;
} }

View File

@@ -8,21 +8,21 @@
* be found in the AUTHORS file in the root of the source tree. * 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 <stdio.h>
#include <string> #include <string>
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "audio_coding_module.h" #include "webrtc/common_types.h"
#include "audio_coding_module_typedefs.h" #include "webrtc/engine_configurations.h"
#include "common_types.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
#include "engine_configurations.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "testsupport/fileutils.h" #include "webrtc/modules/audio_coding/main/test/utility.h"
#include "trace.h" #include "webrtc/system_wrappers/interface/trace.h"
#include "typedefs.h" #include "webrtc/test/testsupport/fileutils.h"
#include "utility.h" #include "webrtc/typedefs.h"
// Description of the test: // Description of the test:
// In this test we set up a one-way communication channel from a participant // In this test we set up a one-way communication channel from a participant
@@ -127,7 +127,6 @@ TestAllCodecs::~TestAllCodecs() {
} }
void TestAllCodecs::Perform() { void TestAllCodecs::Perform() {
const std::string file_name = const std::string file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
infile_a_.Open(file_name, 32000, "rb"); 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. * 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 <cassert>
#include <iostream> #include <string>
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "audio_coding_module_typedefs.h" #include "webrtc/common_types.h"
#include "common_types.h" #include "webrtc/engine_configurations.h"
#include "engine_configurations.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
#include "testsupport/fileutils.h" #include "webrtc/modules/audio_coding/main/test/utility.h"
#include "trace.h" #include "webrtc/system_wrappers/interface/trace.h"
#include "utility.h" #include "webrtc/test/testsupport/fileutils.h"
namespace webrtc { namespace webrtc {
@@ -65,10 +65,10 @@ WebRtc_Word32 TestPackStereo::SendData(
if (lost_packet_ == false) { if (lost_packet_ == false) {
if (frame_type != kAudioFrameCN) { if (frame_type != kAudioFrameCN) {
rtp_info.type.Audio.isCNG = false; 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 { } else {
rtp_info.type.Audio.isCNG = true; 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, status = receiver_acm_->IncomingPacket(payload_data, payload_size,
rtp_info); rtp_info);
@@ -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. // For Celt the packet size in bytes is already counting the stereo part.
if (!strcmp(codec_name, "CELT")) { if (!strcmp(codec_name, "CELT")) {
pack_size_bytes_ = (WebRtc_UWord16)( 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; / channels;
} else { } else {
pack_size_bytes_ = (WebRtc_UWord16)( 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 // Set pointer to the ACM where to register the codec