Remove usage of Atomic32Wrapper from a few places.

In these places, it doesn't make much sense to use an atomic variable we were using
Atomic32Wrapper::operator= anyway (which does not use atomic operations).
Review URL: https://webrtc-codereview.appspot.com/492005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2042 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tommi@webrtc.org
2012-04-17 13:33:28 +00:00
parent 52c0fec34c
commit 7ab51497a7
6 changed files with 39 additions and 71 deletions

View File

@ -52,7 +52,7 @@ MixHistory::~MixHistory()
WebRtc_Word32 MixHistory::IsMixed(bool& mixed) const WebRtc_Word32 MixHistory::IsMixed(bool& mixed) const
{ {
mixed = (_isMixed.Value() == 1); mixed = _isMixed;
return 0; return 0;
} }
@ -65,13 +65,13 @@ WebRtc_Word32 MixHistory::WasMixed(bool& wasMixed) const
WebRtc_Word32 MixHistory::SetIsMixed(const bool mixed) WebRtc_Word32 MixHistory::SetIsMixed(const bool mixed)
{ {
_isMixed = mixed ? 1 : 0; _isMixed = mixed;
return 0; return 0;
} }
void MixHistory::ResetMixedStatus() void MixHistory::ResetMixedStatus()
{ {
_isMixed = 0; _isMixed = false;
} }
AudioConferenceMixer* AudioConferenceMixer::Create(int id) AudioConferenceMixer* AudioConferenceMixer::Create(int id)

View File

@ -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 * 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 * that can be found in the LICENSE file in the root of the source
@ -11,7 +11,6 @@
#ifndef WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IMPL_H_ #ifndef WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IMPL_H_
#define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IMPL_H_ #define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IMPL_H_
#include "atomic32_wrapper.h"
#include "audio_conference_mixer.h" #include "audio_conference_mixer.h"
#include "engine_configurations.h" #include "engine_configurations.h"
#include "level_indicator.h" #include "level_indicator.h"
@ -44,7 +43,7 @@ public:
void ResetMixedStatus(); void ResetMixedStatus();
private: private:
Atomic32Wrapper _isMixed; // 0 = false, 1 = true bool _isMixed;
}; };
class AudioConferenceMixerImpl : public AudioConferenceMixer class AudioConferenceMixerImpl : public AudioConferenceMixer

View File

@ -2976,11 +2976,11 @@ WebRtc_Word32 AudioDeviceWindowsCore::StopRecording()
} }
} }
_UnLock();
// Reset the recording delay value. // Reset the recording delay value.
_sndCardRecDelay = 0; _sndCardRecDelay = 0;
_UnLock();
return err; return err;
} }
@ -3148,10 +3148,10 @@ WebRtc_Word32 AudioDeviceWindowsCore::StopPlayout()
"Recording should be stopped before playout when using the " "Recording should be stopped before playout when using the "
"built-in AEC"); "built-in AEC");
} }
} // critScoped
// Reset the playout delay value. // Reset the playout delay value.
_sndCardPlayDelay = 0; _sndCardPlayDelay = 0;
} // critScoped
return 0; return 0;
} }
@ -3162,7 +3162,8 @@ WebRtc_Word32 AudioDeviceWindowsCore::StopPlayout()
WebRtc_Word32 AudioDeviceWindowsCore::PlayoutDelay(WebRtc_UWord16& delayMS) const WebRtc_Word32 AudioDeviceWindowsCore::PlayoutDelay(WebRtc_UWord16& delayMS) const
{ {
delayMS = static_cast<WebRtc_UWord16>(_sndCardPlayDelay.Value()); CriticalSectionScoped critScoped(&_critSect);
delayMS = static_cast<WebRtc_UWord16>(_sndCardPlayDelay);
return 0; return 0;
} }
@ -3172,7 +3173,8 @@ WebRtc_Word32 AudioDeviceWindowsCore::PlayoutDelay(WebRtc_UWord16& delayMS) cons
WebRtc_Word32 AudioDeviceWindowsCore::RecordingDelay(WebRtc_UWord16& delayMS) const WebRtc_Word32 AudioDeviceWindowsCore::RecordingDelay(WebRtc_UWord16& delayMS) const
{ {
delayMS = static_cast<WebRtc_UWord16>(_sndCardRecDelay.Value()); CriticalSectionScoped critScoped(&_critSect);
delayMS = static_cast<WebRtc_UWord16>(_sndCardRecDelay);
return 0; return 0;
} }
@ -3209,21 +3211,18 @@ WebRtc_Word32 AudioDeviceWindowsCore::SetPlayoutBuffer(const AudioDeviceModule::
WebRtc_Word32 AudioDeviceWindowsCore::PlayoutBuffer(AudioDeviceModule::BufferType& type, WebRtc_UWord16& sizeMS) const WebRtc_Word32 AudioDeviceWindowsCore::PlayoutBuffer(AudioDeviceModule::BufferType& type, WebRtc_UWord16& sizeMS) const
{ {
{
CriticalSectionScoped lock(&_critSect); CriticalSectionScoped lock(&_critSect);
type = _playBufType; type = _playBufType;
}
if (type == AudioDeviceModule::kFixedBufferSize) if (type == AudioDeviceModule::kFixedBufferSize)
{ {
CriticalSectionScoped lock(&_critSect); sizeMS = _playBufDelayFixed;
sizeMS = _playBufDelayFixed; }
} else
else {
{ // Use same value as for PlayoutDelay
// Use same value as for PlayoutDelay sizeMS = static_cast<WebRtc_UWord16>(_sndCardPlayDelay);
sizeMS = static_cast<WebRtc_UWord16>(_sndCardPlayDelay.Value()); }
}
return 0; return 0;
} }
@ -4068,7 +4067,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread()
(((((UINT64)t1.QuadPart * _perfCounterFactor) - recTime) (((((UINT64)t1.QuadPart * _perfCounterFactor) - recTime)
/ 10000) + (10*syncBufIndex) / _recBlockSize - 10); / 10000) + (10*syncBufIndex) / _recBlockSize - 10);
WebRtc_UWord32 sndCardPlayDelay = WebRtc_UWord32 sndCardPlayDelay =
static_cast<WebRtc_UWord32>(_sndCardPlayDelay.Value()); static_cast<WebRtc_UWord32>(_sndCardPlayDelay);
_sndCardRecDelay = sndCardRecDelay; _sndCardRecDelay = sndCardRecDelay;

View File

@ -25,7 +25,6 @@
#include <mediaobj.h> // IMediaObject #include <mediaobj.h> // IMediaObject
#include <Mmdeviceapi.h> // MMDevice #include <Mmdeviceapi.h> // MMDevice
#include "atomic32_wrapper.h"
#include "critical_section_wrapper.h" #include "critical_section_wrapper.h"
#include "scoped_refptr.h" #include "scoped_refptr.h"
@ -326,7 +325,7 @@ private: // WASAPI
WebRtc_UWord32 _playBlockSize; WebRtc_UWord32 _playBlockSize;
WebRtc_UWord32 _devicePlayBlockSize; WebRtc_UWord32 _devicePlayBlockSize;
WebRtc_UWord32 _playChannels; WebRtc_UWord32 _playChannels;
Atomic32Wrapper _sndCardPlayDelay; WebRtc_UWord32 _sndCardPlayDelay;
UINT64 _writtenSamples; UINT64 _writtenSamples;
LONGLONG _playAcc; LONGLONG _playAcc;
@ -335,7 +334,7 @@ private: // WASAPI
WebRtc_UWord32 _recBlockSize; WebRtc_UWord32 _recBlockSize;
WebRtc_UWord32 _recChannels; WebRtc_UWord32 _recChannels;
UINT64 _readSamples; UINT64 _readSamples;
Atomic32Wrapper _sndCardRecDelay; WebRtc_UWord32 _sndCardRecDelay;
float _sampleDriftAt48kHz; float _sampleDriftAt48kHz;
float _driftAccumulator; float _driftAccumulator;

View File

@ -47,7 +47,7 @@ UdpSocket2Windows::UdpSocket2Windows(const WebRtc_Word32 id,
_terminate(false), _terminate(false),
_addedToMgr(false), _addedToMgr(false),
_safeTodelete(false), _safeTodelete(false),
_outstandingCallsDisabled(0), _outstandingCallsDisabled(false),
_clientHandle(NULL), _clientHandle(NULL),
_flowHandle(NULL), _flowHandle(NULL),
_filterHandle(NULL), _filterHandle(NULL),
@ -449,10 +449,10 @@ void UdpSocket2Windows::IOCompleted(PerIoContext* pIOContext,
!pIOContext->ioInitiatedByThreadWrapper && !pIOContext->ioInitiatedByThreadWrapper &&
(error == ERROR_OPERATION_ABORTED) && (error == ERROR_OPERATION_ABORTED) &&
(pIOContext->ioOperation == OP_READ) && (pIOContext->ioOperation == OP_READ) &&
_outstandingCallsDisabled.Value() == 1) _outstandingCallsDisabled)
{ {
// !pIOContext->initiatedIOByThreadWrapper indicate that the I/O // !pIOContext->initiatedIOByThreadWrapper indicate that the I/O
// was not initiaded by a ThreadWrapper thread. // was not initiated by a ThreadWrapper thread.
// This may happen if the thread that initiated receiving (e.g. // This may happen if the thread that initiated receiving (e.g.
// by calling StartListen())) is deleted before any packets have // by calling StartListen())) is deleted before any packets have
// been received. // been received.
@ -462,39 +462,10 @@ void UdpSocket2Windows::IOCompleted(PerIoContext* pIOContext,
// that is controlled by the socket implementation. // that is controlled by the socket implementation.
// Note 2: This is more likely to happen to RTCP packets as // Note 2: This is more likely to happen to RTCP packets as
// they are less frequent than RTP packets. // they are less frequent than RTP packets.
// Note 3: _outstandingCallsDisabled being false (= 1) indicates // Note 3: _outstandingCallsDisabled being false indicates
// that the socket isn't being shut down. // that the socket isn't being shut down.
// Note 4: This should only happen buffers set to recevie packets // Note 4: This should only happen buffers set to receive packets
// (OP_READ). // (OP_READ).
if (_outstandingCallsDisabled.Value() != 1)
{
WEBRTC_TRACE(
kTraceDebug,
kTraceTransport,
_id,
"UdpSocket2Windows::IOCompleted(pIOContext=%p,\
ioSize=%.lu, error=%.lu) Received operation aborted but continuing since\
pIOContext->ioInitiatedByThreadWrapper == false",
pIOContext,
ioSize,
error);
WebRtc_Word32 ioOp = pIOContext ?
(WebRtc_Word32)pIOContext->ioOperation : -1;
WebRtc_Word32 ioInit = pIOContext ?
(WebRtc_Word32)pIOContext->ioInitiatedByThreadWrapper : -1;
WEBRTC_TRACE(
kTraceDebug,
kTraceTransport,
_id,
"pIOContext->ioOperation=%d,\
pIOContext->ioInitiatedByThreadWrapper=%d, _outstandingCallsDisabled=%d,\
_incomingCb=%p, this=%p",
ioOp,
ioInit,
(WebRtc_Word32)_outstandingCallsDisabled.Value(),
_incomingCb,
this);
}
} else { } else {
if(pIOContext == NULL) if(pIOContext == NULL)
{ {
@ -1300,7 +1271,7 @@ WebRtc_Word32 UdpSocket2Windows::CreateFlowSpec(WebRtc_Word32 serviceType,
bool UdpSocket2Windows::NewOutstandingCall() bool UdpSocket2Windows::NewOutstandingCall()
{ {
assert(_outstandingCallsDisabled.Value() == 0); assert(!_outstandingCallsDisabled);
++_outstandingCalls; ++_outstandingCalls;
return true; return true;
@ -1310,9 +1281,9 @@ void UdpSocket2Windows::OutstandingCallCompleted()
{ {
_ptrDestRWLock->AcquireLockShared(); _ptrDestRWLock->AcquireLockShared();
++_outstandingCallComplete; ++_outstandingCallComplete;
if((--_outstandingCalls == 0) && (_outstandingCallsDisabled.Value() == 1)) if((--_outstandingCalls == 0) && _outstandingCallsDisabled)
{ {
// When there are no outstanding calls and new outstandning calls are // When there are no outstanding calls and new outstanding calls are
// disabled it is time to terminate. // disabled it is time to terminate.
_terminate = true; _terminate = true;
} }
@ -1332,13 +1303,13 @@ void UdpSocket2Windows::OutstandingCallCompleted()
void UdpSocket2Windows::DisableNewOutstandingCalls() void UdpSocket2Windows::DisableNewOutstandingCalls()
{ {
_ptrDestRWLock->AcquireLockExclusive(); _ptrDestRWLock->AcquireLockExclusive();
if(_outstandingCallsDisabled.Value() == 1) if(_outstandingCallsDisabled)
{ {
// Outstandning calls are already disabled. // Outstandning calls are already disabled.
_ptrDestRWLock->ReleaseLockExclusive(); _ptrDestRWLock->ReleaseLockExclusive();
return; return;
} }
_outstandingCallsDisabled = 1; _outstandingCallsDisabled = true;
const bool noOutstandingCalls = (_outstandingCalls.Value() == 0); const bool noOutstandingCalls = (_outstandingCalls.Value() == 0);
_ptrDestRWLock->ReleaseLockExclusive(); _ptrDestRWLock->ReleaseLockExclusive();
@ -1364,7 +1335,7 @@ void UdpSocket2Windows::WaitForOutstandingCalls()
void UdpSocket2Windows::RemoveSocketFromManager() void UdpSocket2Windows::RemoveSocketFromManager()
{ {
// New outstanding calls should be disabled at this point. // New outstanding calls should be disabled at this point.
assert(_outstandingCallsDisabled.Value() != 0); assert(_outstandingCallsDisabled);
if(_addedToMgr) if(_addedToMgr)
{ {

View File

@ -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 * 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 * that can be found in the LICENSE file in the root of the source
@ -139,7 +139,7 @@ private:
bool _safeTodelete; bool _safeTodelete;
RWLockWrapper* _ptrDestRWLock; RWLockWrapper* _ptrDestRWLock;
Atomic32Wrapper _outstandingCallsDisabled; // 0 = false, 1 = true bool _outstandingCallsDisabled;
bool NewOutstandingCall(); bool NewOutstandingCall();
void OutstandingCallCompleted(); void OutstandingCallCompleted();
void DisableNewOutstandingCalls(); void DisableNewOutstandingCalls();