Fix shutdown race for ViEEncoder when there is a frame in the encoder.
There is a potential race when deleting a channel and there is a frame in the encoder. ViEEncoder::SendData can be called after ViEEncoder::StopThreadsAndRemovePayloadRouter and payload_router is then already removed. Until we have the new API in place, use scoped_refptr in ViEChannel and ViEEncoder and deregister channel/encoder before deleting. BUG=769 R=stefan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/42019004 Cr-Commit-Position: refs/heads/master@{#8443} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8443 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/system_wrappers/interface/atomic32.h"
|
||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -68,6 +69,9 @@ class PayloadRouter {
|
||||
// and RTP headers.
|
||||
size_t MaxPayloadLength() const;
|
||||
|
||||
void AddRef() { ++ref_count_; }
|
||||
void Release() { if (--ref_count_ == 0) { delete this; } }
|
||||
|
||||
private:
|
||||
// TODO(mflodman): When the new video API has launched, remove crit_ and
|
||||
// assume rtp_modules_ will never change during a call.
|
||||
@ -77,6 +81,8 @@ class PayloadRouter {
|
||||
std::vector<RtpRtcp*> rtp_modules_ GUARDED_BY(crit_.get());
|
||||
bool active_ GUARDED_BY(crit_.get());
|
||||
|
||||
Atomic32 ref_count_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PayloadRouter);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user