Remove use of CriticalSectionScoped(CriticalSectionWrapper& critsect) in VCM.

BUG=
TEST=

Review URL: http://webrtc-codereview.appspot.com/318005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1159 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
stefan@webrtc.org 2011-12-12 08:18:24 +00:00
parent 981d74ddf4
commit 7889a9b49a
15 changed files with 71 additions and 70 deletions

View File

@ -18,7 +18,7 @@ namespace webrtc {
VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming& timing)
:
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
_critSect(CriticalSectionWrapper::CreateCriticalSection()),
_receiveCallback(NULL),
_timing(timing),
_timestampMap(kDecoderFrameMemoryLength)
@ -27,7 +27,7 @@ _timestampMap(kDecoderFrameMemoryLength)
VCMDecodedFrameCallback::~VCMDecodedFrameCallback()
{
delete &_critSect;
delete _critSect;
}
void VCMDecodedFrameCallback::SetUserReceiveCallback(

View File

@ -48,12 +48,12 @@ public:
WebRtc_Word32 Pop(WebRtc_UWord32 timestamp);
private:
CriticalSectionWrapper& _critSect;
VideoFrame _frame;
VCMReceiveCallback* _receiveCallback;
VCMTiming& _timing;
VCMTimestampMap _timestampMap;
WebRtc_UWord64 _lastReceivedPictureID;
CriticalSectionWrapper* _critSect;
VideoFrame _frame;
VCMReceiveCallback* _receiveCallback;
VCMTiming& _timing;
VCMTimestampMap _timestampMap;
WebRtc_UWord64 _lastReceivedPictureID;
};

View File

@ -62,7 +62,7 @@ VCMJitterBuffer::VCMJitterBuffer(WebRtc_Word32 vcmId, WebRtc_Word32 receiverId,
_vcmId(vcmId),
_receiverId(receiverId),
_running(false),
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
_critSect(CriticalSectionWrapper::CreateCriticalSection()),
_master(master),
_frameEvent(),
_packetEvent(),
@ -113,7 +113,7 @@ VCMJitterBuffer::~VCMJitterBuffer()
delete _frameBuffers[i];
}
}
delete &_critSect;
delete _critSect;
}
void
@ -121,8 +121,8 @@ VCMJitterBuffer::CopyFrom(const VCMJitterBuffer& rhs)
{
if (this != &rhs)
{
_critSect.Enter();
rhs._critSect.Enter();
_critSect->Enter();
rhs._critSect->Enter();
_vcmId = rhs._vcmId;
_receiverId = rhs._receiverId;
_running = rhs._running;
@ -170,8 +170,8 @@ VCMJitterBuffer::CopyFrom(const VCMJitterBuffer& rhs)
_frameBuffersTSOrder.Insert(_frameBuffers[i]);
}
}
rhs._critSect.Leave();
_critSect.Leave();
rhs._critSect->Leave();
_critSect->Leave();
}
}
@ -211,7 +211,7 @@ VCMJitterBuffer::Start()
void
VCMJitterBuffer::Stop()
{
_critSect.Enter();
_critSect->Enter();
_running = false;
_lastDecodedTimeStamp = -1;
_lastDecodedSeqNum = -1;
@ -225,7 +225,7 @@ VCMJitterBuffer::Stop()
}
}
_critSect.Leave();
_critSect->Leave();
_frameEvent.Set(); // Make sure we exit from trying to get a frame to decoder
_packetEvent.Set(); // Make sure we exit from trying to get a sequence number
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(_vcmId,
@ -441,7 +441,7 @@ VCMJitterBuffer::GetFrame(const VCMPacket& packet, VCMEncodedFrame*& frame)
return VCM_UNINITIALIZED;
}
_critSect.Enter();
_critSect->Enter();
// Make sure that old empty packets are inserted.
if (LatestTimestamp(static_cast<WebRtc_UWord32>(_lastDecodedTimeStamp),
packet.timestamp, NULL) == _lastDecodedTimeStamp
@ -453,10 +453,10 @@ VCMJitterBuffer::GetFrame(const VCMPacket& packet, VCMEncodedFrame*& frame)
if (_numConsecutiveOldPackets > kMaxConsecutiveOldPackets)
{
FlushInternal();
_critSect.Leave();
_critSect->Leave();
return VCM_FLUSH_INDICATOR;
}
_critSect.Leave();
_critSect->Leave();
return VCM_OLD_PACKET_ERROR;
}
_numConsecutiveOldPackets = 0;
@ -464,7 +464,7 @@ VCMJitterBuffer::GetFrame(const VCMPacket& packet, VCMEncodedFrame*& frame)
frame = _frameBuffersTSOrder.FindFrame(FrameEqualTimestamp,
&packet.timestamp);
_critSect.Leave();
_critSect->Leave();
if (frame != NULL)
{
@ -478,9 +478,9 @@ VCMJitterBuffer::GetFrame(const VCMPacket& packet, VCMEncodedFrame*& frame)
return VCM_OK;
}
// No free frame! Try to reclaim some...
_critSect.Enter();
_critSect->Enter();
RecycleFramesUntilKeyFrame();
_critSect.Leave();
_critSect->Leave();
frame = GetEmptyFrame();
if (frame != NULL)
@ -511,7 +511,7 @@ VCMJitterBuffer::GetEmptyFrame()
return NULL;
}
_critSect.Enter();
_critSect->Enter();
for (int i = 0; i <_maxNumberOfFrames; ++i)
{
@ -519,7 +519,7 @@ VCMJitterBuffer::GetEmptyFrame()
{
// found a free buffer
_frameBuffers[i]->SetState(kStateEmpty);
_critSect.Leave();
_critSect->Leave();
return _frameBuffers[i];
}
}
@ -532,13 +532,13 @@ VCMJitterBuffer::GetEmptyFrame()
_frameBuffers[_maxNumberOfFrames] = ptrNewBuffer;
_maxNumberOfFrames++;
_critSect.Leave();
_critSect->Leave();
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding,
VCMId(_vcmId, _receiverId), "JB(0x%x) FB(0x%x): Jitter buffer "
"increased to:%d frames", this, ptrNewBuffer, _maxNumberOfFrames);
return ptrNewBuffer;
}
_critSect.Leave();
_critSect->Leave();
// We have reached max size, cannot increase JB size
return NULL;
@ -743,7 +743,7 @@ VCMJitterBuffer::GetCompleteFrameForDecoding(WebRtc_UWord32 maxWaitTimeMS)
return NULL;
}
_critSect.Enter();
_critSect->Enter();
CleanUpOldFrames();
CleanUpSizeZeroFrames();
@ -763,7 +763,7 @@ VCMJitterBuffer::GetCompleteFrameForDecoding(WebRtc_UWord32 maxWaitTimeMS)
{
if (maxWaitTimeMS == 0)
{
_critSect.Leave();
_critSect->Leave();
return NULL;
}
const WebRtc_Word64 endWaitTimeMs = VCMTickTime::MillisecondTimestamp()
@ -771,16 +771,16 @@ VCMJitterBuffer::GetCompleteFrameForDecoding(WebRtc_UWord32 maxWaitTimeMS)
WebRtc_Word64 waitTimeMs = maxWaitTimeMS;
while (waitTimeMs > 0)
{
_critSect.Leave();
_critSect->Leave();
const EventTypeWrapper ret =
_frameEvent.Wait(static_cast<WebRtc_UWord32>(waitTimeMs));
_critSect.Enter();
_critSect->Enter();
if (ret == kEventSignaled)
{
// are we closing down the Jitter buffer
if (!_running)
{
_critSect.Leave();
_critSect->Leave();
return NULL;
}
@ -805,7 +805,7 @@ VCMJitterBuffer::GetCompleteFrameForDecoding(WebRtc_UWord32 maxWaitTimeMS)
}
else
{
_critSect.Leave();
_critSect->Leave();
return NULL;
}
}
@ -820,7 +820,7 @@ VCMJitterBuffer::GetCompleteFrameForDecoding(WebRtc_UWord32 maxWaitTimeMS)
if (oldestFrame == NULL)
{
// Even after signaling we're still missing a complete continuous frame
_critSect.Leave();
_critSect->Leave();
return NULL;
}
@ -848,7 +848,7 @@ VCMJitterBuffer::GetCompleteFrameForDecoding(WebRtc_UWord32 maxWaitTimeMS)
_waitingForKeyFrame = false;
}
_critSect.Leave();
_critSect->Leave();
// We have a frame - store seqnum & timestamp
_lastDecodedSeqNum = oldestFrame->GetHighSeqNum();
@ -903,7 +903,7 @@ VCMJitterBuffer::GetNextTimeStamp(WebRtc_UWord32 maxWaitTimeMS,
return -1;
}
_critSect.Enter();
_critSect->Enter();
// Finding oldest frame ready for decoder, check sequence number and size
CleanUpOldFrames();
@ -914,7 +914,7 @@ VCMJitterBuffer::GetNextTimeStamp(WebRtc_UWord32 maxWaitTimeMS,
if (oldestFrame == NULL)
{
_packetEvent.Reset();
_critSect.Leave();
_critSect->Leave();
if (_packetEvent.Wait(maxWaitTimeMS) == kEventSignaled)
{
@ -923,7 +923,7 @@ VCMJitterBuffer::GetNextTimeStamp(WebRtc_UWord32 maxWaitTimeMS,
{
return -1;
}
_critSect.Enter();
_critSect->Enter();
CleanUpOldFrames();
CleanUpSizeZeroFrames();
@ -931,13 +931,13 @@ VCMJitterBuffer::GetNextTimeStamp(WebRtc_UWord32 maxWaitTimeMS,
}
else
{
_critSect.Enter();
_critSect->Enter();
}
}
if (oldestFrame == NULL)
{
_critSect.Leave();
_critSect->Leave();
return -1;
}
// we have a frame
@ -950,7 +950,7 @@ VCMJitterBuffer::GetNextTimeStamp(WebRtc_UWord32 maxWaitTimeMS,
const WebRtc_UWord32 timestamp = oldestFrame->TimeStamp();
_critSect.Leave();
_critSect->Leave();
// return current time
return timestamp;

View File

@ -195,7 +195,7 @@ private:
WebRtc_Word32 _receiverId;
// If we are running (have started) or not
bool _running;
CriticalSectionWrapper& _critSect;
CriticalSectionWrapper* _critSect;
bool _master;
// Event to signal when we have a frame ready for decoder
VCMEvent _frameEvent;

View File

@ -26,7 +26,7 @@ VCMReceiver::VCMReceiver(VCMTiming& timing,
WebRtc_Word32 receiverId,
bool master)
:
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
_critSect(CriticalSectionWrapper::CreateCriticalSection()),
_vcmId(vcmId),
_receiverId(receiverId),
_master(master),
@ -41,7 +41,7 @@ VCMReceiver::~VCMReceiver()
{
_renderWaitEvent.Set();
delete &_renderWaitEvent;
delete &_critSect;
delete _critSect;
}
void

View File

@ -81,7 +81,7 @@ private:
void UpdateState(VCMEncodedFrame& frame);
static WebRtc_Word32 GenerateReceiverId();
CriticalSectionWrapper& _critSect;
CriticalSectionWrapper* _critSect;
WebRtc_Word32 _vcmId;
WebRtc_Word32 _receiverId;
bool _master;

View File

@ -17,7 +17,7 @@ namespace webrtc {
VCMTimestampExtrapolator::VCMTimestampExtrapolator(WebRtc_Word32 vcmId, WebRtc_Word32 id)
:
_rwLock(*RWLockWrapper::CreateRWLock()),
_rwLock(RWLockWrapper::CreateRWLock()),
_vcmId(vcmId),
_id(id),
_startMs(0),
@ -40,13 +40,13 @@ _P11(1e10)
VCMTimestampExtrapolator::~VCMTimestampExtrapolator()
{
delete &_rwLock;
delete _rwLock;
}
void
VCMTimestampExtrapolator::Reset(const WebRtc_Word64 nowMs /* = -1 */)
{
WriteLockScoped wl(_rwLock);
WriteLockScoped wl(*_rwLock);
if (nowMs > -1)
{
_startMs = nowMs;
@ -74,14 +74,14 @@ void
VCMTimestampExtrapolator::Update(WebRtc_Word64 tMs, WebRtc_UWord32 ts90khz, bool trace)
{
_rwLock.AcquireLockExclusive();
_rwLock->AcquireLockExclusive();
if (tMs - _prevMs > 10e3)
{
// Ten seconds without a complete frame.
// Reset the extrapolator
_rwLock.ReleaseLockExclusive();
_rwLock->ReleaseLockExclusive();
Reset();
_rwLock.AcquireLockExclusive();
_rwLock->AcquireLockExclusive();
}
else
{
@ -97,7 +97,7 @@ VCMTimestampExtrapolator::Update(WebRtc_Word64 tMs, WebRtc_UWord32 ts90khz, bool
if (wrapAroundsSincePrev == 0 && ts90khz < _prevTs90khz)
{
_rwLock.ReleaseLockExclusive();
_rwLock->ReleaseLockExclusive();
return;
}
@ -150,13 +150,13 @@ VCMTimestampExtrapolator::Update(WebRtc_Word64 tMs, WebRtc_UWord32 ts90khz, bool
{
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, VCMId(_vcmId, _id), "w[0]=%f w[1]=%f ts=%u tMs=%u", _w[0], _w[1], ts90khz, tMs);
}
_rwLock.ReleaseLockExclusive();
_rwLock->ReleaseLockExclusive();
}
WebRtc_UWord32
VCMTimestampExtrapolator::ExtrapolateTimestamp(WebRtc_Word64 tMs) const
{
ReadLockScoped rl(_rwLock);
ReadLockScoped rl(*_rwLock);
WebRtc_UWord32 timestamp = 0;
if (_packetCount == 0)
{
@ -176,7 +176,7 @@ VCMTimestampExtrapolator::ExtrapolateTimestamp(WebRtc_Word64 tMs) const
WebRtc_Word64
VCMTimestampExtrapolator::ExtrapolateLocalTime(WebRtc_UWord32 timestamp90khz) const
{
ReadLockScoped rl(_rwLock);
ReadLockScoped rl(*_rwLock);
WebRtc_Word64 localTimeMs = 0;
if (_packetCount == 0)
{

View File

@ -30,7 +30,7 @@ public:
private:
void CheckForWrapArounds(WebRtc_UWord32 ts90khz);
bool DelayChangeDetection(double error, bool trace = true);
RWLockWrapper& _rwLock;
RWLockWrapper* _rwLock;
WebRtc_Word32 _vcmId;
WebRtc_Word32 _id;
bool _trace;

View File

@ -18,7 +18,7 @@ namespace webrtc {
VCMTiming::VCMTiming(WebRtc_Word32 vcmId, WebRtc_Word32 timingId, VCMTiming* masterTiming)
:
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
_critSect(CriticalSectionWrapper::CreateCriticalSection()),
_vcmId(vcmId),
_timingId(timingId),
_master(false),
@ -47,7 +47,7 @@ VCMTiming::~VCMTiming()
{
delete _tsExtrapolator;
}
delete &_critSect;
delete _critSect;
}
void

View File

@ -90,7 +90,7 @@ protected:
WebRtc_UWord32 TargetDelayInternal() const;
private:
CriticalSectionWrapper& _critSect;
CriticalSectionWrapper* _critSect;
WebRtc_Word32 _vcmId;
WebRtc_Word32 _timingId;
bool _master;

View File

@ -45,7 +45,7 @@ VCMProcessTimer::Processed()
VideoCodingModuleImpl::VideoCodingModuleImpl(const WebRtc_Word32 id)
:
_id(id),
_receiveCritSect(*CriticalSectionWrapper::CreateCriticalSection()),
_receiveCritSect(CriticalSectionWrapper::CreateCriticalSection()),
_receiverInited(false),
_timing(id, 1),
_dualTiming(id, 2, &_timing),
@ -64,7 +64,7 @@ _frameFromFile(),
_keyRequestMode(kKeyOnError),
_scheduleKeyRequest(false),
_sendCritSect(*CriticalSectionWrapper::CreateCriticalSection()),
_sendCritSect(CriticalSectionWrapper::CreateCriticalSection()),
_encoder(),
_encodedFrameCallback(),
_mediaOpt(id),
@ -96,8 +96,8 @@ VideoCodingModuleImpl::~VideoCodingModuleImpl()
{
_codecDataBase.ReleaseDecoder(_dualDecoder);
}
delete &_receiveCritSect;
delete &_sendCritSect;
delete _receiveCritSect;
delete _sendCritSect;
#ifdef DEBUG_DECODER_BIT_STREAM
fclose(_bitStreamBeforeDecoder);
#endif

View File

@ -259,7 +259,7 @@ protected:
private:
WebRtc_Word32 _id;
CriticalSectionWrapper& _receiveCritSect;
CriticalSectionWrapper* _receiveCritSect;
bool _receiverInited;
VCMTiming _timing;
VCMTiming _dualTiming;
@ -278,7 +278,7 @@ private:
VCMKeyRequestMode _keyRequestMode;
bool _scheduleKeyRequest;
CriticalSectionWrapper& _sendCritSect; // Critical section for send side
CriticalSectionWrapper* _sendCritSect; // Critical section for send side
VCMGenericEncoder* _encoder;
VCMEncodedFrameCallback _encodedFrameCallback;
FrameType _nextFrameType[kMaxSimulcastStreams];

View File

@ -151,7 +151,8 @@ VCMNTEncodeCompleteCallback::SkipCnt()
// Decoded Frame Callback Implementation
VCMNTDecodeCompleCallback::~VCMNTDecodeCompleCallback()
{
//
if (_decodedFile)
fclose(_decodedFile);
}
WebRtc_Word32
VCMNTDecodeCompleCallback::FrameToRender(webrtc::VideoFrame& videoFrame)

View File

@ -40,7 +40,7 @@ RawRtpPacket::~RawRtpPacket()
LostPackets::LostPackets()
:
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
_critSect(CriticalSectionWrapper::CreateCriticalSection()),
_lossCount(0),
_debugFile(NULL)
{
@ -64,7 +64,7 @@ LostPackets::~LostPackets()
Erase(item);
item = First();
}
delete &_critSect;
delete _critSect;
}
WebRtc_UWord32 LostPackets::AddPacket(WebRtc_UWord8* rtpData, WebRtc_UWord16 rtpLen)

View File

@ -46,10 +46,10 @@ public:
WebRtc_UWord32 TotalNumberOfLosses() const { return _lossCount; };
WebRtc_UWord32 NumberOfPacketsToResend() const;
void ResentPacket(WebRtc_UWord16 seqNo);
void Lock() {_critSect.Enter();};
void Unlock() {_critSect.Leave();};
void Lock() {_critSect->Enter();};
void Unlock() {_critSect->Leave();};
private:
webrtc::CriticalSectionWrapper& _critSect;
webrtc::CriticalSectionWrapper* _critSect;
WebRtc_UWord32 _lossCount;
FILE* _debugFile;
};