Fix coverity issues in ACM.

Fixes: Big parameter passed by value (PASS_BY_VALUE)
Passing parameter codec of size 52 bytes by value.

BUG=
TEST=audio_coding_module_tests, trybots

Review URL: https://webrtc-codereview.appspot.com/529002

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2142 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org 2012-04-27 17:06:48 +00:00
parent a88cb6fce0
commit 5c0c18d823
2 changed files with 20 additions and 20 deletions

View File

@ -573,7 +573,7 @@ WebRtc_Word32 AudioCodingModuleImpl::RegisterSendCodec(
// RED can be registered with other payload type. If not registered a default // RED can be registered with other payload type. If not registered a default
// payload type is used. // payload type is used.
if (IsCodecRED(send_codec)) { if (IsCodecRED(&send_codec)) {
// TODO(tlegrand): Remove this check. Already taken care of in // TODO(tlegrand): Remove this check. Already taken care of in
// ACMCodecDB::CodecNumber(). // ACMCodecDB::CodecNumber().
// Check if the payload-type is valid // Check if the payload-type is valid
@ -590,7 +590,7 @@ WebRtc_Word32 AudioCodingModuleImpl::RegisterSendCodec(
// CNG can be registered with other payload type. If not registered the // CNG can be registered with other payload type. If not registered the
// default payload types from codec database will be used. // default payload types from codec database will be used.
if (IsCodecCN(send_codec)) { if (IsCodecCN(&send_codec)) {
// CNG is registered. // CNG is registered.
switch (send_codec.plfreq) { switch (send_codec.plfreq) {
case 8000: { case 8000: {
@ -1283,7 +1283,7 @@ WebRtc_Word32 AudioCodingModuleImpl::RegisterReceiveCodec(
// If codec already registered, unregister. Except for CN where we only // If codec already registered, unregister. Except for CN where we only
// unregister if payload type is changing. // unregister if payload type is changing.
if ((_registeredPlTypes[codec_id] == receive_codec.pltype) if ((_registeredPlTypes[codec_id] == receive_codec.pltype)
&& IsCodecCN(receive_codec)) { && IsCodecCN(&receive_codec)) {
// Codec already registered as receiver with this payload type. Nothing // Codec already registered as receiver with this payload type. Nothing
// to be done. // to be done.
return 0; return 0;
@ -1310,8 +1310,8 @@ WebRtc_Word32 AudioCodingModuleImpl::RegisterReceiveCodec(
// Register stereo codecs with the slave, or, if we've had already seen a // Register stereo codecs with the slave, or, if we've had already seen a
// stereo codec, register CN or RED as a special case. // stereo codec, register CN or RED as a special case.
if (receive_codec.channels == 2 || if (receive_codec.channels == 2 ||
(_stereoReceiveRegistered && (IsCodecCN(receive_codec) || (_stereoReceiveRegistered && (IsCodecCN(&receive_codec) ||
IsCodecRED(receive_codec)))) { IsCodecRED(&receive_codec)))) {
// TODO(andrew): refactor this block to combine with InitStereoSlave(). // TODO(andrew): refactor this block to combine with InitStereoSlave().
if (!_stereoReceiveRegistered) { if (!_stereoReceiveRegistered) {
@ -1366,7 +1366,7 @@ WebRtc_Word32 AudioCodingModuleImpl::RegisterReceiveCodec(
_registeredPlTypes[codec_id] = receive_codec.pltype; _registeredPlTypes[codec_id] = receive_codec.pltype;
if (IsCodecRED(receive_codec)) { if (IsCodecRED(&receive_codec)) {
_receiveREDPayloadType = receive_codec.pltype; _receiveREDPayloadType = receive_codec.pltype;
} }
return 0; return 0;
@ -1583,24 +1583,24 @@ int AudioCodingModuleImpl::UpdateUponReceivingCodec(int index) {
return 0; return 0;
} }
bool AudioCodingModuleImpl::IsCodecForSlave(int index) { bool AudioCodingModuleImpl::IsCodecForSlave(int index) const {
return (_registeredPlTypes[index] != -1 && _stereoReceive[index]); return (_registeredPlTypes[index] != -1 && _stereoReceive[index]);
} }
bool AudioCodingModuleImpl::IsCodecRED(int index) { bool AudioCodingModuleImpl::IsCodecRED(int index) const {
return (IsCodecRED(ACMCodecDB::database_[index])); return (IsCodecRED(&ACMCodecDB::database_[index]));
} }
bool AudioCodingModuleImpl::IsCodecRED(CodecInst codec) { bool AudioCodingModuleImpl::IsCodecRED(const CodecInst* codec) const {
return (STR_CASE_CMP(codec.plname, "RED") == 0); return (STR_CASE_CMP(codec->plname, "RED") == 0);
} }
bool AudioCodingModuleImpl::IsCodecCN(int index) { bool AudioCodingModuleImpl::IsCodecCN(int index) const {
return (IsCodecCN(ACMCodecDB::database_[index])); return (IsCodecCN(&ACMCodecDB::database_[index]));
} }
bool AudioCodingModuleImpl::IsCodecCN(CodecInst codec) { bool AudioCodingModuleImpl::IsCodecCN(const CodecInst* codec) const {
return (STR_CASE_CMP(codec.plname, "CN") == 0); return (STR_CASE_CMP(codec->plname, "CN") == 0);
} }
int AudioCodingModuleImpl::InitStereoSlave() { int AudioCodingModuleImpl::InitStereoSlave() {

View File

@ -259,17 +259,17 @@ class AudioCodingModuleImpl : public AudioCodingModule {
// Returns true if the codec's |index| is registered with the master and // Returns true if the codec's |index| is registered with the master and
// is a stereo codec, RED or CN. // is a stereo codec, RED or CN.
bool IsCodecForSlave(int index); bool IsCodecForSlave(int index) const;
// Returns true if the |codec| is RED. // Returns true if the |codec| is RED.
bool IsCodecRED(CodecInst codec); bool IsCodecRED(const CodecInst* codec) const;
// ...or if its |index| is RED. // ...or if its |index| is RED.
bool IsCodecRED(int index); bool IsCodecRED(int index) const;
// Returns true if the |codec| is CN. // Returns true if the |codec| is CN.
bool IsCodecCN(int index); bool IsCodecCN(int index) const;
// ...or if its |index| is CN. // ...or if its |index| is CN.
bool IsCodecCN(CodecInst codec); bool IsCodecCN(const CodecInst* codec) const;
AudioPacketizationCallback* _packetizationCallback; AudioPacketizationCallback* _packetizationCallback;
WebRtc_Word32 _id; WebRtc_Word32 _id;