Fix tsan failures on filevideocapturer.cc.
1) init start_time_ns_ before the file_read_thread_ is started to avoid data racing as the start_time_ns_ will also be read by the file_read_thread_. 2) add CriticalSection to protect |finished_| that is accessed by FileReadThread and the main thread Also remove the suppression for filemediaengine.cc, which has already been fixed in other cl. TBR=henrike@webrtc.org TEST=try bots and manual tsan v2 test BUG=2078 Review URL: https://webrtc-codereview.appspot.com/2509004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5018 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -28,6 +28,7 @@
|
||||
#include "talk/media/devices/filevideocapturer.h"
|
||||
|
||||
#include "talk/base/bytebuffer.h"
|
||||
#include "talk/base/criticalsection.h"
|
||||
#include "talk/base/logging.h"
|
||||
#include "talk/base/thread.h"
|
||||
|
||||
@ -121,6 +122,8 @@ class FileVideoCapturer::FileReadThread
|
||||
PostDelayed(waiting_time_ms, this);
|
||||
Thread::Run();
|
||||
}
|
||||
|
||||
talk_base::CritScope cs(&crit_);
|
||||
finished_ = true;
|
||||
}
|
||||
|
||||
@ -135,10 +138,14 @@ class FileVideoCapturer::FileReadThread
|
||||
}
|
||||
|
||||
// Check if Run() is finished.
|
||||
bool Finished() const { return finished_; }
|
||||
bool Finished() const {
|
||||
talk_base::CritScope cs(&crit_);
|
||||
return finished_;
|
||||
}
|
||||
|
||||
private:
|
||||
FileVideoCapturer* capturer_;
|
||||
mutable talk_base::CriticalSection crit_;
|
||||
bool finished_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(FileReadThread);
|
||||
@ -228,9 +235,9 @@ CaptureState FileVideoCapturer::Start(const VideoFormat& capture_format) {
|
||||
SetCaptureFormat(&capture_format);
|
||||
// Create a thread to read the file.
|
||||
file_read_thread_ = new FileReadThread(this);
|
||||
bool ret = file_read_thread_->Start();
|
||||
start_time_ns_ = kNumNanoSecsPerMilliSec *
|
||||
static_cast<int64>(talk_base::Time());
|
||||
bool ret = file_read_thread_->Start();
|
||||
if (ret) {
|
||||
LOG(LS_INFO) << "File video capturer '" << GetId() << "' started";
|
||||
return CS_RUNNING;
|
||||
|
||||
@ -15,11 +15,6 @@ race:webrtc/modules/audio_processing/aec/aec_rdft.c
|
||||
# See https://code.google.com/p/webrtc/issues/detail?id=1205
|
||||
race:talk/app/webrtc/test/fakeaudiocapturemodule.cc
|
||||
|
||||
# libjingle_media_unittest
|
||||
# See https://code.google.com/p/webrtc/issues/detail?id=2078
|
||||
race:talk/media/base/filemediaengine.cc
|
||||
race:talk/media/devices/filevideocapturer.cc
|
||||
|
||||
# libjingle_p2p_unittest
|
||||
# See https://code.google.com/p/webrtc/issues/detail?id=2079
|
||||
race:talk/base/messagequeue.cc
|
||||
|
||||
Reference in New Issue
Block a user