Changing non-const reference arguments to pointers, ACM

Part of refactoring of ACM, and recent lint-warnings.
This CL changes non-const references in the ACM API to pointers.

BUG=issue1372

Committed: https://code.google.com/p/webrtc/source/detail?r=3543

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3555 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tina.legrand@webrtc.org
2013-02-21 10:27:48 +00:00
parent f61e02c81f
commit 7a7a008031
20 changed files with 214 additions and 207 deletions

View File

@ -34,15 +34,15 @@ WebRtc_UWord8 AudioCodingModule::NumberOfCodecs() {
}
// Get supported codec param with id
WebRtc_Word32 AudioCodingModule::Codec(const WebRtc_UWord8 list_id,
CodecInst& codec) {
WebRtc_Word32 AudioCodingModule::Codec(WebRtc_UWord8 list_id,
CodecInst* codec) {
// Get the codec settings for the codec with the given list ID
return ACMCodecDB::Codec(list_id, &codec);
return ACMCodecDB::Codec(list_id, codec);
}
// Get supported codec Param with name, frequency and number of channels.
WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
CodecInst& codec, int sampling_freq_hz,
CodecInst* codec, int sampling_freq_hz,
int channels) {
int codec_id;
@ -51,20 +51,20 @@ WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
if (codec_id < 0) {
// We couldn't find a matching codec, set the parameterss to unacceptable
// values and return.
codec.plname[0] = '\0';
codec.pltype = -1;
codec.pacsize = 0;
codec.rate = 0;
codec.plfreq = 0;
codec->plname[0] = '\0';
codec->pltype = -1;
codec->pacsize = 0;
codec->rate = 0;
codec->plfreq = 0;
return -1;
}
// Get default codec settings.
ACMCodecDB::Codec(codec_id, &codec);
ACMCodecDB::Codec(codec_id, codec);
// Keep the number of channels from the function call. For most codecs it
// will be the same value as in defaul codec settings, but not for all.
codec.channels = channels;
codec->channels = channels;
return 0;
}

View File

@ -1171,11 +1171,12 @@ WebRtc_Word32 AudioCodingModuleImpl::RegisterSendCodec(
// Get current send codec.
WebRtc_Word32 AudioCodingModuleImpl::SendCodec(
CodecInst& current_codec) const {
CodecInst* current_codec) const {
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_,
"SendCodec()");
CriticalSectionScoped lock(acm_crit_sect_);
assert(current_codec);
if (!send_codec_registered_) {
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_,
"SendCodec Failed, no codec is registered");
@ -1185,7 +1186,7 @@ WebRtc_Word32 AudioCodingModuleImpl::SendCodec(
WebRtcACMCodecParams encoder_param;
codecs_[current_send_codec_idx_]->EncoderParams(&encoder_param);
encoder_param.codec_inst.pltype = send_codec_inst_.pltype;
memcpy(&current_codec, &(encoder_param.codec_inst), sizeof(CodecInst));
memcpy(current_codec, &(encoder_param.codec_inst), sizeof(CodecInst));
return 0;
}
@ -1597,13 +1598,14 @@ int AudioCodingModuleImpl::SetVADSafe(bool enable_dtx,
}
// Get VAD/DTX settings.
WebRtc_Word32 AudioCodingModuleImpl::VAD(bool& dtx_enabled, bool& vad_enabled,
ACMVADMode& mode) const {
// TODO(tlegrand): Change this method to void.
WebRtc_Word32 AudioCodingModuleImpl::VAD(bool* dtx_enabled, bool* vad_enabled,
ACMVADMode* mode) const {
CriticalSectionScoped lock(acm_crit_sect_);
dtx_enabled = dtx_enabled_;
vad_enabled = vad_enabled_;
mode = vad_mode_;
*dtx_enabled = dtx_enabled_;
*vad_enabled = vad_enabled_;
*mode = vad_mode_;
return 0;
}
@ -1931,7 +1933,7 @@ WebRtc_Word32 AudioCodingModuleImpl::RegisterRecCodecMSSafe(
// Get current received codec.
WebRtc_Word32 AudioCodingModuleImpl::ReceiveCodec(
CodecInst& current_codec) const {
CodecInst* current_codec) const {
WebRtcACMCodecParams decoder_param;
CriticalSectionScoped lock(acm_crit_sect_);
@ -1940,7 +1942,7 @@ WebRtc_Word32 AudioCodingModuleImpl::ReceiveCodec(
if (codecs_[id]->DecoderInitialized()) {
if (codecs_[id]->DecoderParams(&decoder_param,
last_recv_audio_codec_pltype_)) {
memcpy(&current_codec, &decoder_param.codec_inst,
memcpy(current_codec, &decoder_param.codec_inst,
sizeof(CodecInst));
return 0;
}
@ -1950,7 +1952,7 @@ WebRtc_Word32 AudioCodingModuleImpl::ReceiveCodec(
// If we are here then we haven't found any codec. Set codec pltype to -1 to
// indicate that the structure is invalid and return -1.
current_codec.pltype = -1;
current_codec->pltype = -1;
return -1;
}
@ -2222,10 +2224,10 @@ AudioPlayoutMode AudioCodingModuleImpl::PlayoutMode() const {
// Get 10 milliseconds of raw audio data to play out.
// Automatic resample to the requested frequency.
WebRtc_Word32 AudioCodingModuleImpl::PlayoutData10Ms(
const WebRtc_Word32 desired_freq_hz, AudioFrame& audio_frame) {
WebRtc_Word32 desired_freq_hz, AudioFrame* audio_frame) {
bool stereo_mode;
if (GetSilence(desired_freq_hz, &audio_frame))
if (GetSilence(desired_freq_hz, audio_frame))
return 0; // Silence is generated, return.
// RecOut always returns 10 ms.
@ -2235,9 +2237,9 @@ WebRtc_Word32 AudioCodingModuleImpl::PlayoutData10Ms(
return -1;
}
audio_frame.num_channels_ = audio_frame_.num_channels_;
audio_frame.vad_activity_ = audio_frame_.vad_activity_;
audio_frame.speech_type_ = audio_frame_.speech_type_;
audio_frame->num_channels_ = audio_frame_.num_channels_;
audio_frame->vad_activity_ = audio_frame_.vad_activity_;
audio_frame->speech_type_ = audio_frame_.speech_type_;
stereo_mode = (audio_frame_.num_channels_ > 1);
// For stereo playout:
@ -2256,7 +2258,7 @@ WebRtc_Word32 AudioCodingModuleImpl::PlayoutData10Ms(
if ((receive_freq != desired_freq_hz) && (desired_freq_hz != -1)) {
// Resample payload_data.
WebRtc_Word16 temp_len = output_resampler_.Resample10Msec(
audio_frame_.data_, receive_freq, audio_frame.data_,
audio_frame_.data_, receive_freq, audio_frame->data_,
desired_freq_hz, audio_frame_.num_channels_);
if (temp_len < 0) {
@ -2266,40 +2268,40 @@ WebRtc_Word32 AudioCodingModuleImpl::PlayoutData10Ms(
}
// Set the payload data length from the resampler.
audio_frame.samples_per_channel_ = (WebRtc_UWord16) temp_len;
audio_frame->samples_per_channel_ = (WebRtc_UWord16) temp_len;
// Set the sampling frequency.
audio_frame.sample_rate_hz_ = desired_freq_hz;
audio_frame->sample_rate_hz_ = desired_freq_hz;
} else {
memcpy(audio_frame.data_, audio_frame_.data_,
audio_frame_.samples_per_channel_ * audio_frame.num_channels_
memcpy(audio_frame->data_, audio_frame_.data_,
audio_frame_.samples_per_channel_ * audio_frame->num_channels_
* sizeof(WebRtc_Word16));
// Set the payload length.
audio_frame.samples_per_channel_ =
audio_frame->samples_per_channel_ =
audio_frame_.samples_per_channel_;
// Set the sampling frequency.
audio_frame.sample_rate_hz_ = receive_freq;
audio_frame->sample_rate_hz_ = receive_freq;
}
// Tone detection done for master channel.
if (dtmf_detector_ != NULL) {
// Dtmf Detection.
if (audio_frame.sample_rate_hz_ == 8000) {
// Use audio_frame.data_ then Dtmf detector doesn't
if (audio_frame->sample_rate_hz_ == 8000) {
// Use audio_frame->data_ then Dtmf detector doesn't
// need resampling.
if (!stereo_mode) {
dtmf_detector_->Detect(audio_frame.data_,
audio_frame.samples_per_channel_,
audio_frame.sample_rate_hz_, tone_detected,
dtmf_detector_->Detect(audio_frame->data_,
audio_frame->samples_per_channel_,
audio_frame->sample_rate_hz_, tone_detected,
tone);
} else {
// We are in 8 kHz so the master channel needs only 80 samples.
WebRtc_Word16 master_channel[80];
for (int n = 0; n < 80; n++) {
master_channel[n] = audio_frame.data_[n << 1];
master_channel[n] = audio_frame->data_[n << 1];
}
dtmf_detector_->Detect(master_channel,
audio_frame.samples_per_channel_,
audio_frame.sample_rate_hz_, tone_detected,
audio_frame->samples_per_channel_,
audio_frame->sample_rate_hz_, tone_detected,
tone);
}
} else {
@ -2346,9 +2348,9 @@ WebRtc_Word32 AudioCodingModuleImpl::PlayoutData10Ms(
}
}
audio_frame.id_ = id_;
audio_frame.energy_ = -1;
audio_frame.timestamp_ = 0;
audio_frame->id_ = id_;
audio_frame->energy_ = -1;
audio_frame->timestamp_ = 0;
return 0;
}
@ -2373,9 +2375,9 @@ WebRtc_Word16 AudioCodingModuleImpl::SetReceiveVADMode(const ACMVADMode mode) {
//
WebRtc_Word32 AudioCodingModuleImpl::NetworkStatistics(
ACMNetworkStatistics& statistics) const {
ACMNetworkStatistics* statistics) const {
WebRtc_Word32 status;
status = neteq_.NetworkStatistics(&statistics);
status = neteq_.NetworkStatistics(statistics);
return status;
}
@ -2594,13 +2596,13 @@ WebRtc_Word32 AudioCodingModuleImpl::ReplaceInternalDTXWithWebRtc(
}
WebRtc_Word32 AudioCodingModuleImpl::IsInternalDTXReplacedWithWebRtc(
bool& uses_webrtc_dtx) {
bool* uses_webrtc_dtx) {
CriticalSectionScoped lock(acm_crit_sect_);
if (!HaveValidEncoder("IsInternalDTXReplacedWithWebRtc")) {
return -1;
}
if (codecs_[current_send_codec_idx_]->IsInternalDTXReplaced(&uses_webrtc_dtx)
if (codecs_[current_send_codec_idx_]->IsInternalDTXReplaced(uses_webrtc_dtx)
< 0) {
return -1;
}
@ -2655,19 +2657,19 @@ WebRtc_Word32 AudioCodingModuleImpl::SetBackgroundNoiseMode(
}
WebRtc_Word32 AudioCodingModuleImpl::BackgroundNoiseMode(
ACMBackgroundNoiseMode& mode) {
return neteq_.BackgroundNoiseMode(mode);
ACMBackgroundNoiseMode* mode) {
return neteq_.BackgroundNoiseMode(*mode);
}
WebRtc_Word32 AudioCodingModuleImpl::PlayoutTimestamp(
WebRtc_UWord32& timestamp) {
WebRtc_UWord32* timestamp) {
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_,
"PlayoutTimestamp()");
if (track_neteq_buffer_) {
timestamp = playout_ts_;
*timestamp = playout_ts_;
return 0;
} else {
return neteq_.PlayoutTimestamp(timestamp);
return neteq_.PlayoutTimestamp(*timestamp);
}
}

View File

@ -68,7 +68,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
int SecondarySendCodec(CodecInst* secondary_codec) const;
// Get current send codec.
WebRtc_Word32 SendCodec(CodecInst& current_codec) const;
WebRtc_Word32 SendCodec(CodecInst* current_codec) const;
// Get current send frequency.
WebRtc_Word32 SendFrequency() const;
@ -99,7 +99,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
WebRtc_Word32 SetBackgroundNoiseMode(const ACMBackgroundNoiseMode mode);
// Get current background noise mode.
WebRtc_Word32 BackgroundNoiseMode(ACMBackgroundNoiseMode& mode);
WebRtc_Word32 BackgroundNoiseMode(ACMBackgroundNoiseMode* mode);
/////////////////////////////////////////
// (FEC) Forward Error Correction
@ -121,8 +121,8 @@ class AudioCodingModuleImpl : public AudioCodingModule {
const bool enable_vad = false,
const ACMVADMode mode = VADNormal);
WebRtc_Word32 VAD(bool& dtx_enabled, bool& vad_enabled,
ACMVADMode& mode) const;
WebRtc_Word32 VAD(bool* dtx_enabled, bool* vad_enabled,
ACMVADMode* mode) const;
WebRtc_Word32 RegisterVADCallback(ACMVADCallback* vad_callback);
@ -153,7 +153,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
WebRtc_Word32 RegisterReceiveCodec(const CodecInst& receive_codec);
// Get current received codec.
WebRtc_Word32 ReceiveCodec(CodecInst& current_codec) const;
WebRtc_Word32 ReceiveCodec(CodecInst* current_codec) const;
// Incoming packet from network parsed and ready for decode.
WebRtc_Word32 IncomingPacket(const WebRtc_UWord8* incoming_payload,
@ -189,18 +189,18 @@ class AudioCodingModuleImpl : public AudioCodingModule {
AudioPlayoutMode PlayoutMode() const;
// Get playout timestamp.
WebRtc_Word32 PlayoutTimestamp(WebRtc_UWord32& timestamp);
WebRtc_Word32 PlayoutTimestamp(WebRtc_UWord32* timestamp);
// Get 10 milliseconds of raw audio data to play out, and
// automatic resample to the requested frequency if > 0.
WebRtc_Word32 PlayoutData10Ms(const WebRtc_Word32 desired_freq_hz,
AudioFrame &audio_frame);
WebRtc_Word32 PlayoutData10Ms(WebRtc_Word32 desired_freq_hz,
AudioFrame* audio_frame);
/////////////////////////////////////////
// Statistics
//
WebRtc_Word32 NetworkStatistics(ACMNetworkStatistics& statistics) const;
WebRtc_Word32 NetworkStatistics(ACMNetworkStatistics* statistics) const;
void DestructEncoderInst(void* inst);
@ -221,7 +221,7 @@ class AudioCodingModuleImpl : public AudioCodingModule {
WebRtc_Word32 ReplaceInternalDTXWithWebRtc(const bool use_webrtc_dtx);
WebRtc_Word32 IsInternalDTXReplacedWithWebRtc(bool& uses_webrtc_dtx);
WebRtc_Word32 IsInternalDTXReplacedWithWebRtc(bool* uses_webrtc_dtx);
WebRtc_Word32 SetISACMaxRate(const WebRtc_UWord32 max_bit_per_sec);