Fix potential VCMReceiver crash.

BUG=
TEST=

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1578 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
stefan@webrtc.org 2012-01-31 10:49:08 +00:00
parent 2919e95c2a
commit 91c630851a

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
@ -8,17 +8,17 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "receiver.h" #include "modules/video_coding/main/source/receiver.h"
#include "encoded_frame.h"
#include "internal_defines.h"
#include "media_opt_util.h"
#include "tick_time_base.h"
#include "trace.h"
#include "video_coding.h"
#include <assert.h> #include <assert.h>
#include "modules/video_coding/main/interface/video_coding.h"
#include "modules/video_coding/main/source/encoded_frame.h"
#include "modules/video_coding/main/source/internal_defines.h"
#include "modules/video_coding/main/source/media_opt_util.h"
#include "modules/video_coding/main/source/tick_time_base.h"
#include "system_wrappers/interface/trace.h"
namespace webrtc { namespace webrtc {
VCMReceiver::VCMReceiver(VCMTiming& timing, VCMReceiver::VCMReceiver(VCMTiming& timing,
@ -26,18 +26,15 @@ VCMReceiver::VCMReceiver(VCMTiming& timing,
WebRtc_Word32 vcmId, WebRtc_Word32 vcmId,
WebRtc_Word32 receiverId, WebRtc_Word32 receiverId,
bool master) bool master)
: : _critSect(CriticalSectionWrapper::CreateCriticalSection()),
_critSect(CriticalSectionWrapper::CreateCriticalSection()), _vcmId(vcmId),
_vcmId(vcmId), _clock(clock),
_clock(clock), _receiverId(receiverId),
_receiverId(receiverId), _master(master),
_master(master), _jitterBuffer(_clock, vcmId, receiverId, master),
_jitterBuffer(_clock, vcmId, receiverId, master), _timing(timing),
_timing(timing), _renderWaitEvent(*new VCMEvent()),
_renderWaitEvent(*new VCMEvent()), _state(kPassive) {}
_state(kPassive)
{
}
VCMReceiver::~VCMReceiver() VCMReceiver::~VCMReceiver()
{ {
@ -98,11 +95,11 @@ VCMReceiver::InsertPacket(const VCMPacket& packet,
{ {
return VCM_OK; return VCM_OK;
} }
else if (error < 0) else if (error != VCM_OK)
{ {
return error; return error;
} }
assert(buffer);
{ {
CriticalSectionScoped cs(_critSect); CriticalSectionScoped cs(_critSect);
@ -193,9 +190,10 @@ VCMReceiver::InsertPacket(const VCMPacket& packet,
return VCM_OK; return VCM_OK;
} }
VCMEncodedFrame* VCMEncodedFrame* VCMReceiver::FrameForDecoding(WebRtc_UWord16 maxWaitTimeMs,
VCMReceiver::FrameForDecoding(WebRtc_UWord16 maxWaitTimeMs, WebRtc_Word64& nextRenderTimeMs, WebRtc_Word64& nextRenderTimeMs,
bool renderTiming, VCMReceiver* dualReceiver) bool renderTiming,
VCMReceiver* dualReceiver)
{ {
// No need to enter the critical section here since the jitter buffer // No need to enter the critical section here since the jitter buffer
// is thread-safe. // is thread-safe.