Fix deadlock on register/unregister observer while there is a an going callback.

BUG=2835
R=mallinath@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5421 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andresp@webrtc.org
2014-01-23 23:09:25 +00:00
parent a8910d2f88
commit 8d375c95b7
8 changed files with 61 additions and 84 deletions

View File

@@ -59,21 +59,16 @@ class FakeWebRtcVideoCaptureModule : public webrtc::VideoCaptureModule {
id_ = id;
return 0;
}
virtual int32_t RegisterCaptureDataCallback(
virtual void RegisterCaptureDataCallback(
webrtc::VideoCaptureDataCallback& callback) {
callback_ = &callback;
return 0;
}
virtual int32_t DeRegisterCaptureDataCallback() {
callback_ = NULL;
return 0;
virtual void DeRegisterCaptureDataCallback() { callback_ = NULL; }
virtual void RegisterCaptureCallback(webrtc::VideoCaptureFeedBack& callback) {
// Not implemented.
}
virtual int32_t RegisterCaptureCallback(
webrtc::VideoCaptureFeedBack& callback) {
return -1; // not implemented
}
virtual int32_t DeRegisterCaptureCallback() {
return 0;
virtual void DeRegisterCaptureCallback() {
// Not implemented.
}
virtual int32_t StartCapture(
const webrtc::VideoCaptureCapability& cap) {
@@ -98,13 +93,8 @@ class FakeWebRtcVideoCaptureModule : public webrtc::VideoCaptureModule {
settings = cap_;
return 0;
}
virtual int32_t SetCaptureDelay(int32_t delay) {
delay_ = delay;
return 0;
}
virtual int32_t CaptureDelay() {
return delay_;
}
virtual void SetCaptureDelay(int32_t delay) { delay_ = delay; }
virtual int32_t CaptureDelay() { return delay_; }
virtual int32_t SetCaptureRotation(
webrtc::VideoCaptureRotation rotation) {
return -1; // not implemented
@@ -113,11 +103,11 @@ class FakeWebRtcVideoCaptureModule : public webrtc::VideoCaptureModule {
const webrtc::VideoCodec& codec) {
return NULL; // not implemented
}
virtual int32_t EnableFrameRateCallback(const bool enable) {
return -1; // not implemented
virtual void EnableFrameRateCallback(const bool enable) {
// not implemented
}
virtual int32_t EnableNoPictureAlarm(const bool enable) {
return -1; // not implemented
virtual void EnableNoPictureAlarm(const bool enable) {
// not implemented
}
virtual int32_t AddRef() {
return 0;

View File

@@ -264,8 +264,8 @@ CaptureState WebRtcVideoCapturer::Start(const VideoFormat& capture_format) {
std::string camera_id(GetId());
uint32 start = talk_base::Time();
if (module_->RegisterCaptureDataCallback(*this) != 0 ||
module_->StartCapture(cap) != 0) {
module_->RegisterCaptureDataCallback(*this);
if (module_->StartCapture(cap) != 0) {
LOG(LS_ERROR) << "Camera '" << camera_id << "' failed to start";
return CS_FAILED;
}