From 7fa42778b4fc87d4319f418b2c7286e03c482ff7 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Wed, 28 Aug 2019 20:49:55 +0200 Subject: [PATCH] Fix for tsan failue in real time scenario tests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sink is only added once, but before this fix, the value was updated to the same value, causing a tsan failure. This CL adds a check so we don't update the value if it's set. Bug: webrtc:10909 Change-Id: I46c8f7044f1441c0155b18881d1b8e0aeb7568c6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150783 Reviewed-by: Åsa Persson Commit-Queue: Sebastian Jansson Cr-Commit-Position: refs/heads/master@{#28999} --- test/scenario/video_frame_matcher.cc | 4 +++- test/scenario/video_frame_matcher.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/scenario/video_frame_matcher.cc b/test/scenario/video_frame_matcher.cc index 912459183f..d2b0ee231f 100644 --- a/test/scenario/video_frame_matcher.cc +++ b/test/scenario/video_frame_matcher.cc @@ -158,7 +158,9 @@ void ForwardingCapturedFrameTap::OnDiscardedFrame() { void ForwardingCapturedFrameTap::AddOrUpdateSink( VideoSinkInterface* sink, const rtc::VideoSinkWants& wants) { - sink_ = sink; + if (!sink_) + sink_ = sink; + RTC_DCHECK_EQ(sink_, sink); source_->AddOrUpdateSink(this, wants); } void ForwardingCapturedFrameTap::RemoveSink( diff --git a/test/scenario/video_frame_matcher.h b/test/scenario/video_frame_matcher.h index 20a0ccca8b..f7f62436ac 100644 --- a/test/scenario/video_frame_matcher.h +++ b/test/scenario/video_frame_matcher.h @@ -114,7 +114,7 @@ class ForwardingCapturedFrameTap Clock* const clock_; VideoFrameMatcher* const matcher_; rtc::VideoSourceInterface* const source_; - VideoSinkInterface* sink_; + VideoSinkInterface* sink_ = nullptr; int discarded_count_ = 0; };