Change CriticalSectionScoped to use pointer constructor
BUG=issue183 TEST=audio_coding_module_test Review URL: https://webrtc-codereview.appspot.com/638005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2384 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
276dc1872a
commit
fa7138f889
@ -61,7 +61,7 @@ _callbackCritSect(CriticalSectionWrapper::CreateCriticalSection())
|
||||
|
||||
ACMNetEQ::~ACMNetEQ() {
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
RemoveNetEQSafe(0); // Master.
|
||||
RemoveSlavesSafe();
|
||||
}
|
||||
@ -81,7 +81,7 @@ ACMNetEQ::~ACMNetEQ() {
|
||||
WebRtc_Word32
|
||||
ACMNetEQ::Init()
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
|
||||
for(WebRtc_Word16 idx = 0; idx < _numSlaves + 1; idx++)
|
||||
{
|
||||
@ -227,7 +227,7 @@ ACMNetEQ::AllocatePacketBuffer(
|
||||
// the following has to be int otherwise we will have compiler error
|
||||
// if not casted
|
||||
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
for(WebRtc_Word16 idx = 0; idx < _numSlaves + 1; idx++)
|
||||
{
|
||||
if(AllocatePacketBufferByIdxSafe(usedCodecs, noOfCodecs, idx) < 0)
|
||||
@ -295,7 +295,7 @@ WebRtc_Word32
|
||||
ACMNetEQ::SetExtraDelay(
|
||||
const WebRtc_Word32 delayInMS)
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
|
||||
for(WebRtc_Word16 idx = 0; idx < _numSlaves + 1; idx++)
|
||||
{
|
||||
@ -320,7 +320,7 @@ WebRtc_Word32
|
||||
ACMNetEQ::SetAVTPlayout(
|
||||
const bool enable)
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
if (_avtPlayout != enable)
|
||||
{
|
||||
for(WebRtc_Word16 idx = 0; idx < _numSlaves + 1; idx++)
|
||||
@ -346,14 +346,14 @@ ACMNetEQ::SetAVTPlayout(
|
||||
bool
|
||||
ACMNetEQ::AVTPlayout() const
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
return _avtPlayout;
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
ACMNetEQ::CurrentSampFreqHz() const
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
if(!_isInitialized[0])
|
||||
{
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
|
||||
@ -368,7 +368,7 @@ WebRtc_Word32
|
||||
ACMNetEQ::SetPlayoutMode(
|
||||
const AudioPlayoutMode mode)
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
if(_playoutMode != mode)
|
||||
{
|
||||
for(WebRtc_Word16 idx = 0; idx < _numSlaves + 1; idx++)
|
||||
@ -408,7 +408,7 @@ ACMNetEQ::SetPlayoutMode(
|
||||
AudioPlayoutMode
|
||||
ACMNetEQ::PlayoutMode() const
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
return _playoutMode;
|
||||
}
|
||||
|
||||
@ -418,7 +418,7 @@ ACMNetEQ::NetworkStatistics(
|
||||
ACMNetworkStatistics* statistics) const
|
||||
{
|
||||
WebRtcNetEQ_NetworkStatistics stats;
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
if(!_isInitialized[0])
|
||||
{
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
|
||||
@ -502,7 +502,7 @@ ACMNetEQ::RecIn(
|
||||
netEqRTPInfo.SSRC = rtpInfo.header.ssrc;
|
||||
netEqRTPInfo.markerBit = rtpInfo.header.markerBit;
|
||||
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
// Down-cast the time to (32-6)-bit since we only care about
|
||||
// the least significant bits. (32-6) bits cover 2^(32-6) = 67108864 ms.
|
||||
// we masked 6 most significant bits of 32-bit so we don't loose resolution
|
||||
@ -574,7 +574,7 @@ ACMNetEQ::RecOut(
|
||||
|
||||
WebRtc_Word16 payloadLenSampleSlave;
|
||||
|
||||
CriticalSectionScoped lockNetEq(*_netEqCritSect);
|
||||
CriticalSectionScoped lockNetEq(_netEqCritSect);
|
||||
|
||||
if(!_receivedStereo)
|
||||
{
|
||||
@ -766,7 +766,7 @@ ACMNetEQ::AddCodec(
|
||||
"ACMNetEQ::AddCodec: error, codecDef is NULL");
|
||||
return -1;
|
||||
}
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
|
||||
WebRtc_Word16 idx;
|
||||
if(toMaster)
|
||||
@ -869,7 +869,7 @@ ACMNetEQ::RTPPack(
|
||||
WebRtc_Word16
|
||||
ACMNetEQ::EnableVAD()
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
if (_vadStatus)
|
||||
{
|
||||
return 0;
|
||||
@ -899,7 +899,7 @@ ACMNetEQ::EnableVAD()
|
||||
ACMVADMode
|
||||
ACMNetEQ::VADMode() const
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
return _vadMode;
|
||||
}
|
||||
|
||||
@ -908,7 +908,7 @@ WebRtc_Word16
|
||||
ACMNetEQ::SetVADMode(
|
||||
const ACMVADMode mode)
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
if((mode < VADNormal) || (mode > VADVeryAggr))
|
||||
{
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
|
||||
@ -940,7 +940,7 @@ ACMNetEQ::SetVADMode(
|
||||
WebRtc_Word32
|
||||
ACMNetEQ::FlushBuffers()
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
for(WebRtc_Word16 idx = 0; idx < _numSlaves + 1; idx++)
|
||||
{
|
||||
if(!_isInitialized[idx])
|
||||
@ -1003,7 +1003,7 @@ ACMNetEQ::RemoveCodec(
|
||||
"RemoveCodec: NetEq error: could not Remove Codec, codec index out of range");
|
||||
return -1;
|
||||
}
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
if(!_isInitialized[0])
|
||||
{
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
|
||||
@ -1033,7 +1033,7 @@ WebRtc_Word16
|
||||
ACMNetEQ::SetBackgroundNoiseMode(
|
||||
const ACMBackgroundNoiseMode mode)
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
for(WebRtc_Word16 idx = 0; idx < _numSlaves + 1; idx++)
|
||||
{
|
||||
if(!_isInitialized[idx])
|
||||
@ -1056,7 +1056,7 @@ ACMNetEQ::BackgroundNoiseMode(
|
||||
ACMBackgroundNoiseMode& mode)
|
||||
{
|
||||
WebRtcNetEQBGNMode myMode;
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
if(!_isInitialized[0])
|
||||
{
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
|
||||
@ -1079,7 +1079,7 @@ void
|
||||
ACMNetEQ::SetUniqueId(
|
||||
WebRtc_Word32 id)
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
_id = id;
|
||||
}
|
||||
|
||||
@ -1109,7 +1109,7 @@ WebRtc_Word32
|
||||
ACMNetEQ::PlayoutTimestamp(
|
||||
WebRtc_UWord32& timestamp)
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
if(WebRtcNetEQ_GetSpeechTimeStamp(_inst[0], ×tamp) < 0)
|
||||
{
|
||||
LogError("GetSpeechTimeStamp", 0);
|
||||
@ -1122,7 +1122,7 @@ ACMNetEQ::PlayoutTimestamp(
|
||||
}
|
||||
|
||||
void ACMNetEQ::RemoveSlaves() {
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
RemoveSlavesSafe();
|
||||
}
|
||||
|
||||
@ -1158,7 +1158,7 @@ ACMNetEQ::AddSlave(
|
||||
const WebRtcNetEQDecoder* usedCodecs,
|
||||
WebRtc_Word16 noOfCodecs)
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
const WebRtc_Word16 slaveIdx = 1;
|
||||
if(_numSlaves < 1)
|
||||
{
|
||||
@ -1263,14 +1263,14 @@ void
|
||||
ACMNetEQ::SetReceivedStereo(
|
||||
bool receivedStereo)
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
_receivedStereo = receivedStereo;
|
||||
}
|
||||
|
||||
WebRtc_UWord8
|
||||
ACMNetEQ::NumSlaves()
|
||||
{
|
||||
CriticalSectionScoped lock(*_netEqCritSect);
|
||||
CriticalSectionScoped lock(_netEqCritSect);
|
||||
return _numSlaves;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
@ -11,73 +11,62 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "acm_resampler.h"
|
||||
|
||||
#include "critical_section_wrapper.h"
|
||||
#include "resampler.h"
|
||||
#include "signal_processing_library.h"
|
||||
#include "trace.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
namespace webrtc {
|
||||
|
||||
ACMResampler::ACMResampler():
|
||||
|
||||
_resamplerCritSect(*CriticalSectionWrapper::CreateCriticalSection())
|
||||
{
|
||||
ACMResampler::ACMResampler()
|
||||
: _resamplerCritSect(CriticalSectionWrapper::CreateCriticalSection()) {
|
||||
}
|
||||
|
||||
ACMResampler::~ACMResampler()
|
||||
{
|
||||
|
||||
delete &_resamplerCritSect;
|
||||
ACMResampler::~ACMResampler() {
|
||||
delete _resamplerCritSect;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMResampler::Resample10Msec(const WebRtc_Word16* inAudio,
|
||||
WebRtc_Word32 inFreqHz,
|
||||
WebRtc_Word16* outAudio,
|
||||
WebRtc_Word32 outFreqHz,
|
||||
WebRtc_UWord8 numAudioChannels) {
|
||||
CriticalSectionScoped cs(_resamplerCritSect);
|
||||
|
||||
WebRtc_Word16
|
||||
ACMResampler::Resample10Msec(
|
||||
const WebRtc_Word16* inAudio,
|
||||
WebRtc_Word32 inFreqHz,
|
||||
WebRtc_Word16* outAudio,
|
||||
WebRtc_Word32 outFreqHz,
|
||||
WebRtc_UWord8 numAudioChannels)
|
||||
{
|
||||
if (inFreqHz == outFreqHz) {
|
||||
size_t length = static_cast<size_t>(inFreqHz * numAudioChannels / 100);
|
||||
memcpy(outAudio, inAudio, length * sizeof(WebRtc_Word16));
|
||||
return static_cast<WebRtc_Word16>(inFreqHz / 100);
|
||||
}
|
||||
|
||||
CriticalSectionScoped cs(_resamplerCritSect);
|
||||
// |maxLen| is maximum number of samples for 10ms at 48kHz.
|
||||
int maxLen = 480 * numAudioChannels;
|
||||
int lengthIn = (WebRtc_Word16)(inFreqHz / 100) * numAudioChannels;
|
||||
int outLen;
|
||||
|
||||
if(inFreqHz == outFreqHz)
|
||||
{
|
||||
size_t length = static_cast<size_t>(inFreqHz * numAudioChannels / 100);
|
||||
memcpy(outAudio, inAudio, length * sizeof(WebRtc_Word16));
|
||||
return static_cast<WebRtc_Word16>(inFreqHz / 100);
|
||||
}
|
||||
WebRtc_Word32 ret;
|
||||
ResamplerType type;
|
||||
type = (numAudioChannels == 1) ? kResamplerSynchronous :
|
||||
kResamplerSynchronousStereo;
|
||||
|
||||
int maxLen = 480 * numAudioChannels; //max number of samples for 10ms at 48kHz
|
||||
int lengthIn = (WebRtc_Word16)(inFreqHz / 100) * numAudioChannels;
|
||||
int outLen;
|
||||
ret = _resampler.ResetIfNeeded(inFreqHz, outFreqHz, type);
|
||||
if (ret < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, 0,
|
||||
"Error in reset of resampler");
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ret;
|
||||
ResamplerType type;
|
||||
type = (numAudioChannels == 1)? kResamplerSynchronous:kResamplerSynchronousStereo;
|
||||
ret = _resampler.Push(inAudio, lengthIn, outAudio, maxLen, outLen);
|
||||
if (ret < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, 0,
|
||||
"Error in resampler: resampler.Push");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = _resampler.ResetIfNeeded(inFreqHz,outFreqHz,type);
|
||||
if (ret < 0)
|
||||
{
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, 0,
|
||||
"Error in reset of resampler");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = _resampler.Push(inAudio, lengthIn, outAudio, maxLen, outLen);
|
||||
if (ret < 0 )
|
||||
{
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, 0,
|
||||
"Error in resampler: resampler.Push");
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 outAudioLenSmpl = (WebRtc_Word16) outLen / numAudioChannels;
|
||||
|
||||
return outAudioLenSmpl;
|
||||
WebRtc_Word16 outAudioLenSmpl = (WebRtc_Word16) outLen / numAudioChannels;
|
||||
|
||||
return outAudioLenSmpl;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
} // namespace webrtc
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
@ -18,26 +18,23 @@ namespace webrtc {
|
||||
|
||||
class CriticalSectionWrapper;
|
||||
|
||||
class ACMResampler
|
||||
{
|
||||
public:
|
||||
ACMResampler();
|
||||
~ACMResampler();
|
||||
class ACMResampler {
|
||||
public:
|
||||
ACMResampler();
|
||||
~ACMResampler();
|
||||
|
||||
WebRtc_Word16 Resample10Msec(
|
||||
const WebRtc_Word16* inAudio,
|
||||
const WebRtc_Word32 inFreqHz,
|
||||
WebRtc_Word16* outAudio,
|
||||
const WebRtc_Word32 outFreqHz,
|
||||
WebRtc_UWord8 numAudioChannels);
|
||||
WebRtc_Word16 Resample10Msec(const WebRtc_Word16* inAudio,
|
||||
const WebRtc_Word32 inFreqHz,
|
||||
WebRtc_Word16* outAudio,
|
||||
const WebRtc_Word32 outFreqHz,
|
||||
WebRtc_UWord8 numAudioChannels);
|
||||
|
||||
private:
|
||||
|
||||
//Use the Resampler class
|
||||
Resampler _resampler;
|
||||
CriticalSectionWrapper& _resamplerCritSect;
|
||||
private:
|
||||
// Use the Resampler class.
|
||||
Resampler _resampler;
|
||||
CriticalSectionWrapper* _resamplerCritSect;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_
|
||||
|
@ -137,7 +137,7 @@ AudioCodingModuleImpl::AudioCodingModuleImpl(const WebRtc_Word32 id)
|
||||
|
||||
AudioCodingModuleImpl::~AudioCodingModuleImpl() {
|
||||
{
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
_currentSendCodecIdx = -1;
|
||||
|
||||
for (int i = 0; i < ACMCodecDB::kMaxNumCodecs; i++) {
|
||||
@ -211,7 +211,7 @@ AudioCodingModuleImpl::~AudioCodingModuleImpl() {
|
||||
|
||||
WebRtc_Word32 AudioCodingModuleImpl::ChangeUniqueId(const WebRtc_Word32 id) {
|
||||
{
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
_id = id;
|
||||
|
||||
#ifdef ACM_QA_TEST
|
||||
@ -246,7 +246,7 @@ WebRtc_Word32 AudioCodingModuleImpl::ChangeUniqueId(const WebRtc_Word32 id) {
|
||||
// Returns the number of milliseconds until the module want a
|
||||
// worker thread to call Process.
|
||||
WebRtc_Word32 AudioCodingModuleImpl::TimeUntilNextProcess() {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
if (!HaveValidEncoder("TimeUntilNextProcess")) {
|
||||
return -1;
|
||||
@ -271,7 +271,7 @@ WebRtc_Word32 AudioCodingModuleImpl::Process() {
|
||||
|
||||
// Keep the scope of the ACM critical section limited.
|
||||
{
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
if (!HaveValidEncoder("Process")) {
|
||||
return -1;
|
||||
}
|
||||
@ -428,7 +428,7 @@ WebRtc_Word32 AudioCodingModuleImpl::Process() {
|
||||
}
|
||||
|
||||
if (has_data_to_send) {
|
||||
CriticalSectionScoped lock(*_callbackCritSect);
|
||||
CriticalSectionScoped lock(_callbackCritSect);
|
||||
#ifdef ACM_QA_TEST
|
||||
if(_outgoingPL != NULL) {
|
||||
if (fwrite(&rtp_timestamp, sizeof(WebRtc_UWord32), 1, _outgoingPL) != 1) {
|
||||
@ -476,7 +476,7 @@ WebRtc_Word32 AudioCodingModuleImpl::Process() {
|
||||
|
||||
// Initialize send codec.
|
||||
WebRtc_Word32 AudioCodingModuleImpl::InitializeSender() {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
// Start with invalid values.
|
||||
_sendCodecRegistered = false;
|
||||
@ -512,7 +512,7 @@ WebRtc_Word32 AudioCodingModuleImpl::InitializeSender() {
|
||||
}
|
||||
|
||||
WebRtc_Word32 AudioCodingModuleImpl::ResetEncoder() {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
if (!HaveValidEncoder("ResetEncoder")) {
|
||||
return -1;
|
||||
}
|
||||
@ -520,7 +520,7 @@ WebRtc_Word32 AudioCodingModuleImpl::ResetEncoder() {
|
||||
}
|
||||
|
||||
void AudioCodingModuleImpl::UnregisterSendCodec() {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
_sendCodecRegistered = false;
|
||||
_currentSendCodecIdx = -1;
|
||||
return;
|
||||
@ -557,7 +557,7 @@ WebRtc_Word32 AudioCodingModuleImpl::RegisterSendCodec(
|
||||
int mirror_id;
|
||||
int codec_id = ACMCodecDB::CodecNumber(&send_codec, &mirror_id, error_message,
|
||||
sizeof(error_message));
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
// Check for reported errors from function CodecNumber().
|
||||
if (codec_id < 0) {
|
||||
@ -815,7 +815,7 @@ WebRtc_Word32 AudioCodingModuleImpl::SendCodec(
|
||||
CodecInst& current_codec) const {
|
||||
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, _id,
|
||||
"SendCodec()");
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
if (!_sendCodecRegistered) {
|
||||
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, _id,
|
||||
@ -835,7 +835,7 @@ WebRtc_Word32 AudioCodingModuleImpl::SendCodec(
|
||||
WebRtc_Word32 AudioCodingModuleImpl::SendFrequency() const {
|
||||
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, _id,
|
||||
"SendFrequency()");
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
if (!_sendCodecRegistered) {
|
||||
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, _id,
|
||||
@ -851,7 +851,7 @@ WebRtc_Word32 AudioCodingModuleImpl::SendFrequency() const {
|
||||
// Adaptive rate codecs return their current encode target rate, while other
|
||||
// codecs return there longterm avarage or their fixed rate.
|
||||
WebRtc_Word32 AudioCodingModuleImpl::SendBitrate() const {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
if (!_sendCodecRegistered) {
|
||||
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, _id,
|
||||
@ -877,7 +877,7 @@ WebRtc_Word32 AudioCodingModuleImpl::SetReceivedEstimatedBandwidth(
|
||||
// the encoded buffers.
|
||||
WebRtc_Word32 AudioCodingModuleImpl::RegisterTransportCallback(
|
||||
AudioPacketizationCallback* transport) {
|
||||
CriticalSectionScoped lock(*_callbackCritSect);
|
||||
CriticalSectionScoped lock(_callbackCritSect);
|
||||
_packetizationCallback = transport;
|
||||
return 0;
|
||||
}
|
||||
@ -896,12 +896,12 @@ WebRtc_Word32 AudioCodingModuleImpl::RegisterIncomingMessagesCallback(
|
||||
|
||||
// Enter the critical section for callback.
|
||||
{
|
||||
CriticalSectionScoped lock(*_callbackCritSect);
|
||||
CriticalSectionScoped lock(_callbackCritSect);
|
||||
_dtmfCallback = incoming_message;
|
||||
}
|
||||
// Enter the ACM critical section to set up the DTMF class.
|
||||
{
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
// Check if the call is to disable or enable the callback.
|
||||
if (incoming_message == NULL) {
|
||||
// Callback is disabled, delete DTMF-detector class.
|
||||
@ -932,7 +932,7 @@ WebRtc_Word32 AudioCodingModuleImpl::RegisterIncomingMessagesCallback(
|
||||
// Check if we failed in setting up the DTMF-detector class.
|
||||
if ((status < 0)) {
|
||||
// We failed, we cannot have the callback.
|
||||
CriticalSectionScoped lock(*_callbackCritSect);
|
||||
CriticalSectionScoped lock(_callbackCritSect);
|
||||
_dtmfCallback = NULL;
|
||||
}
|
||||
|
||||
@ -944,7 +944,7 @@ WebRtc_Word32 AudioCodingModuleImpl::RegisterIncomingMessagesCallback(
|
||||
WebRtc_Word32 AudioCodingModuleImpl::Add10MsData(
|
||||
const AudioFrame& audio_frame) {
|
||||
// Do we have a codec registered?
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
if (!HaveValidEncoder("Add10MsData")) {
|
||||
return -1;
|
||||
}
|
||||
@ -1058,7 +1058,7 @@ WebRtc_Word32 AudioCodingModuleImpl::Add10MsData(
|
||||
//
|
||||
|
||||
bool AudioCodingModuleImpl::FECStatus() const {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
return _fecEnabled;
|
||||
}
|
||||
|
||||
@ -1067,7 +1067,7 @@ WebRtc_Word32
|
||||
AudioCodingModuleImpl::SetFECStatus(
|
||||
#ifdef WEBRTC_CODEC_RED
|
||||
const bool enable_fec) {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
if (_fecEnabled != enable_fec) {
|
||||
// Reset the RED buffer.
|
||||
@ -1104,7 +1104,7 @@ AudioCodingModuleImpl::SetFECStatus(
|
||||
WebRtc_Word32 AudioCodingModuleImpl::SetVAD(const bool enable_dtx,
|
||||
const bool enable_vad,
|
||||
const ACMVADMode mode) {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
// Sanity check of the mode.
|
||||
if ((mode != VADNormal) && (mode != VADLowBitrate)
|
||||
@ -1149,7 +1149,7 @@ WebRtc_Word32 AudioCodingModuleImpl::SetVAD(const bool enable_dtx,
|
||||
// Get VAD/DTX settings.
|
||||
WebRtc_Word32 AudioCodingModuleImpl::VAD(bool& dtx_enabled, bool& vad_enabled,
|
||||
ACMVADMode& mode) const {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
dtx_enabled = _dtxEnabled;
|
||||
vad_enabled = _vadEnabled;
|
||||
@ -1163,7 +1163,7 @@ WebRtc_Word32 AudioCodingModuleImpl::VAD(bool& dtx_enabled, bool& vad_enabled,
|
||||
//
|
||||
|
||||
WebRtc_Word32 AudioCodingModuleImpl::InitializeReceiver() {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
return InitializeReceiverSafe();
|
||||
}
|
||||
|
||||
@ -1213,7 +1213,7 @@ WebRtc_Word32 AudioCodingModuleImpl::InitializeReceiverSafe() {
|
||||
|
||||
// Reset the decoder state.
|
||||
WebRtc_Word32 AudioCodingModuleImpl::ResetDecoder() {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
for (int id = 0; id < ACMCodecDB::kMaxNumCodecs; id++) {
|
||||
if ((_codecs[id] != NULL) && (_registeredPlTypes[id] != -1)) {
|
||||
@ -1233,7 +1233,7 @@ WebRtc_Word32 AudioCodingModuleImpl::ReceiveFrequency() const {
|
||||
"ReceiveFrequency()");
|
||||
WebRtcACMCodecParams codec_params;
|
||||
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
if (DecoderParamByPlType(_lastRecvAudioCodecPlType, codec_params) < 0) {
|
||||
return _netEq.CurrentSampFreqHz();
|
||||
} else {
|
||||
@ -1246,7 +1246,7 @@ WebRtc_Word32 AudioCodingModuleImpl::PlayoutFrequency() const {
|
||||
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, _id,
|
||||
"PlayoutFrequency()");
|
||||
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
return _netEq.CurrentSampFreqHz();
|
||||
}
|
||||
@ -1255,7 +1255,7 @@ WebRtc_Word32 AudioCodingModuleImpl::PlayoutFrequency() const {
|
||||
// for codecs, CNG (NB, WB and SWB), DTMF, RED.
|
||||
WebRtc_Word32 AudioCodingModuleImpl::RegisterReceiveCodec(
|
||||
const CodecInst& receive_codec) {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
if (receive_codec.channels > 2) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
|
||||
@ -1456,7 +1456,7 @@ WebRtc_Word32 AudioCodingModuleImpl::RegisterRecCodecMSSafe(
|
||||
WebRtc_Word32 AudioCodingModuleImpl::ReceiveCodec(
|
||||
CodecInst& current_codec) const {
|
||||
WebRtcACMCodecParams decoderParam;
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
for (int id = 0; id < ACMCodecDB::kMaxNumCodecs; id++) {
|
||||
if (_codecs[id] != NULL) {
|
||||
@ -1493,7 +1493,7 @@ WebRtc_Word32 AudioCodingModuleImpl::IncomingPacket(
|
||||
{
|
||||
// Store the payload Type. This will be used to retrieve "received codec"
|
||||
// and "received frequency."
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
#ifdef ACM_QA_TEST
|
||||
if(_incomingPL != NULL) {
|
||||
if (fwrite(&rtp_info.header.timestamp, sizeof(WebRtc_UWord32),
|
||||
@ -1763,7 +1763,7 @@ WebRtc_Word32 AudioCodingModuleImpl::PlayoutData10Ms(
|
||||
|
||||
// Limit the scope of ACM Critical section.
|
||||
{
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
if ((receive_freq != desired_freq_hz) && (desired_freq_hz != -1)) {
|
||||
// Resample payloadData.
|
||||
@ -1844,7 +1844,7 @@ WebRtc_Word32 AudioCodingModuleImpl::PlayoutData10Ms(
|
||||
|
||||
if (tone_detected) {
|
||||
// We will deal with callback here, so enter callback critical section.
|
||||
CriticalSectionScoped lock(*_callbackCritSect);
|
||||
CriticalSectionScoped lock(_callbackCritSect);
|
||||
|
||||
if (_dtmfCallback != NULL) {
|
||||
if (tone != kACMToneEnd) {
|
||||
@ -1936,7 +1936,7 @@ WebRtc_Word32 AudioCodingModuleImpl::RegisterVADCallback(
|
||||
ACMVADCallback* vad_callback) {
|
||||
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceAudioCoding, _id,
|
||||
"RegisterVADCallback()");
|
||||
CriticalSectionScoped lock(*_callbackCritSect);
|
||||
CriticalSectionScoped lock(_callbackCritSect);
|
||||
_vadCallback = vad_callback;
|
||||
return 0;
|
||||
}
|
||||
@ -2017,7 +2017,7 @@ WebRtc_Word32 AudioCodingModuleImpl::IncomingPayload(
|
||||
WebRtc_Word16 AudioCodingModuleImpl::DecoderParamByPlType(
|
||||
const WebRtc_UWord8 payload_type,
|
||||
WebRtcACMCodecParams& codec_params) const {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
for (WebRtc_Word16 id = 0; id < ACMCodecDB::kMaxNumCodecs;
|
||||
id++) {
|
||||
if (_codecs[id] != NULL) {
|
||||
@ -2041,7 +2041,7 @@ WebRtc_Word16 AudioCodingModuleImpl::DecoderParamByPlType(
|
||||
WebRtc_Word16 AudioCodingModuleImpl::DecoderListIDByPlName(
|
||||
const char* name, const WebRtc_UWord16 frequency) const {
|
||||
WebRtcACMCodecParams codec_params;
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
for (WebRtc_Word16 id = 0; id < ACMCodecDB::kMaxNumCodecs; id++) {
|
||||
if ((_codecs[id] != NULL)) {
|
||||
if (_codecs[id]->DecoderInitialized()) {
|
||||
@ -2071,7 +2071,7 @@ WebRtc_Word16 AudioCodingModuleImpl::DecoderListIDByPlName(
|
||||
|
||||
WebRtc_Word32 AudioCodingModuleImpl::LastEncodedTimestamp(
|
||||
WebRtc_UWord32& timestamp) const {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
if (!HaveValidEncoder("LastEncodedTimestamp")) {
|
||||
return -1;
|
||||
}
|
||||
@ -2081,7 +2081,7 @@ WebRtc_Word32 AudioCodingModuleImpl::LastEncodedTimestamp(
|
||||
|
||||
WebRtc_Word32 AudioCodingModuleImpl::ReplaceInternalDTXWithWebRtc(
|
||||
bool use_webrtc_dtx) {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
if (!HaveValidEncoder("ReplaceInternalDTXWithWebRtc")) {
|
||||
WEBRTC_TRACE(
|
||||
@ -2107,7 +2107,7 @@ WebRtc_Word32 AudioCodingModuleImpl::ReplaceInternalDTXWithWebRtc(
|
||||
|
||||
WebRtc_Word32 AudioCodingModuleImpl::IsInternalDTXReplacedWithWebRtc(
|
||||
bool& uses_webrtc_dtx) {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
if (!HaveValidEncoder("IsInternalDTXReplacedWithWebRtc")) {
|
||||
return -1;
|
||||
@ -2121,7 +2121,7 @@ WebRtc_Word32 AudioCodingModuleImpl::IsInternalDTXReplacedWithWebRtc(
|
||||
|
||||
WebRtc_Word32 AudioCodingModuleImpl::SetISACMaxRate(
|
||||
const WebRtc_UWord32 max_bit_per_sec) {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
if (!HaveValidEncoder("SetISACMaxRate")) {
|
||||
return -1;
|
||||
@ -2132,7 +2132,7 @@ WebRtc_Word32 AudioCodingModuleImpl::SetISACMaxRate(
|
||||
|
||||
WebRtc_Word32 AudioCodingModuleImpl::SetISACMaxPayloadSize(
|
||||
const WebRtc_UWord16 max_size_bytes) {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
if (!HaveValidEncoder("SetISACMaxPayloadSize")) {
|
||||
return -1;
|
||||
@ -2146,7 +2146,7 @@ WebRtc_Word32 AudioCodingModuleImpl::ConfigISACBandwidthEstimator(
|
||||
const WebRtc_UWord8 frame_size_ms,
|
||||
const WebRtc_UWord16 rate_bit_per_sec,
|
||||
const bool enforce_frame_size) {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
|
||||
if (!HaveValidEncoder("ConfigISACBandwidthEstimator")) {
|
||||
return -1;
|
||||
@ -2201,7 +2201,7 @@ bool AudioCodingModuleImpl::HaveValidEncoder(const char* caller_name) const {
|
||||
|
||||
WebRtc_Word32 AudioCodingModuleImpl::UnregisterReceiveCodec(
|
||||
const WebRtc_Word16 payload_type) {
|
||||
CriticalSectionScoped lock(*_acmCritSect);
|
||||
CriticalSectionScoped lock(_acmCritSect);
|
||||
int id;
|
||||
|
||||
// Search through the list of registered payload types.
|
||||
|
Loading…
x
Reference in New Issue
Block a user