Fix tiny race condition when Vp9NonFlexMode_* tests were failing.

TSAN complained at each failure, which only added confusion.

Bug: webrtc:11243
Change-Id: Ic36ec13562699478be23050a7b723e1b9bb47f0e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/164528
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Commit-Queue: Yves Gerey <yvesg@google.com>
Cr-Commit-Position: refs/heads/master@{#30161}
This commit is contained in:
Yves Gerey
2020-01-03 17:12:49 +01:00
committed by Commit Bot
parent 27f4d325ad
commit 499de2d395

View File

@ -3149,9 +3149,14 @@ class Vp9HeaderObserver : public test::SendTest {
}
void PerformTest() override {
EXPECT_TRUE(Wait()) << "Test timed out waiting for VP9 packet, num frames "
bool wait = Wait();
{
// In case of time out, OnSendRtp might still access frames_sent_;
rtc::CritScope lock(&crit_);
EXPECT_TRUE(wait) << "Test timed out waiting for VP9 packet, num frames "
<< frames_sent_;
}
}
Action OnSendRtp(const uint8_t* packet, size_t length) override {
RtpPacket rtp_packet;
@ -3179,6 +3184,7 @@ class Vp9HeaderObserver : public test::SendTest {
++packets_sent_;
if (rtp_packet.Marker()) {
rtc::CritScope lock(&crit_);
++frames_sent_;
}
last_packet_marker_ = rtp_packet.Marker();
@ -3405,6 +3411,7 @@ class Vp9HeaderObserver : public test::SendTest {
uint32_t last_packet_timestamp_ = 0;
RTPVideoHeaderVP9 last_vp9_;
size_t packets_sent_;
rtc::CriticalSection crit_;
size_t frames_sent_;
int expected_width_;
int expected_height_;