From 5aaa9faa9b93136699f907150992a64fed34a4db Mon Sep 17 00:00:00 2001 From: isheriff Date: Tue, 14 Jun 2016 10:55:36 -0700 Subject: [PATCH] Remove thread_checker in playout_delay_oracle It appears there the encode and send operation can happen over multiple threads. Also, padding data itself may be sent on a different thread. Remove thread checker and protect all data with crit_sect. BUG=webrtc:5998 TBR=stefan@webrtc.org Review-Url: https://codereview.webrtc.org/2066863002 Cr-Commit-Position: refs/heads/master@{#13137} --- .../rtp_rtcp/source/playout_delay_oracle.cc | 6 ++---- .../rtp_rtcp/source/playout_delay_oracle.h | 19 +++++++------------ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/webrtc/modules/rtp_rtcp/source/playout_delay_oracle.cc b/webrtc/modules/rtp_rtcp/source/playout_delay_oracle.cc index ed3af3f2c4..24cdf533ac 100644 --- a/webrtc/modules/rtp_rtcp/source/playout_delay_oracle.cc +++ b/webrtc/modules/rtp_rtcp/source/playout_delay_oracle.cc @@ -22,16 +22,14 @@ PlayoutDelayOracle::PlayoutDelayOracle() send_playout_delay_(false), ssrc_(0), min_playout_delay_ms_(-1), - max_playout_delay_ms_(-1) { - thread_checker_.DetachFromThread(); -} + max_playout_delay_ms_(-1) {} + PlayoutDelayOracle::~PlayoutDelayOracle() {} void PlayoutDelayOracle::UpdateRequest(uint32_t ssrc, PlayoutDelay playout_delay, uint16_t seq_num) { rtc::CritScope lock(&crit_sect_); - RTC_DCHECK_RUN_ON(&thread_checker_); RTC_DCHECK_LE(playout_delay.min_ms, kPlayoutDelayMaxMs); RTC_DCHECK_LE(playout_delay.max_ms, kPlayoutDelayMaxMs); RTC_DCHECK_LE(playout_delay.min_ms, playout_delay.max_ms); diff --git a/webrtc/modules/rtp_rtcp/source/playout_delay_oracle.h b/webrtc/modules/rtp_rtcp/source/playout_delay_oracle.h index 8ee135e1b8..90677e786f 100644 --- a/webrtc/modules/rtp_rtcp/source/playout_delay_oracle.h +++ b/webrtc/modules/rtp_rtcp/source/playout_delay_oracle.h @@ -13,7 +13,6 @@ #include "webrtc/base/basictypes.h" #include "webrtc/base/criticalsection.h" -#include "webrtc/base/thread_checker.h" #include "webrtc/base/thread_annotations.h" #include "webrtc/modules/include/module_common_types.h" #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" @@ -45,13 +44,13 @@ class PlayoutDelayOracle { // Returns current minimum playout delay in milliseconds. int min_playout_delay_ms() const { - RTC_DCHECK_RUN_ON(&thread_checker_); + rtc::CritScope lock(&crit_sect_); return min_playout_delay_ms_; } // Returns current maximum playout delay in milliseconds. int max_playout_delay_ms() const { - RTC_DCHECK_RUN_ON(&thread_checker_); + rtc::CritScope lock(&crit_sect_); return max_playout_delay_ms_; } @@ -64,10 +63,9 @@ class PlayoutDelayOracle { void OnReceivedRtcpReportBlocks(const ReportBlockList& report_blocks); private: - // The playout delay information is updated from the encoder thread or - // a thread controlled by application in case of external encoder. + // The playout delay information is updated from the encoder thread(s). // The sequence number feedback is updated from the worker thread. - // Guards access to data across the two threads. + // Guards access to data across multiple threads. rtc::CriticalSection crit_sect_; // The current highest sequence number on which playout delay has been sent. int64_t high_sequence_number_ GUARDED_BY(crit_sect_); @@ -75,15 +73,12 @@ class PlayoutDelayOracle { bool send_playout_delay_ GUARDED_BY(crit_sect_); // Sender ssrc. uint32_t ssrc_ GUARDED_BY(crit_sect_); - - // Data in this section is accessed on the sending/encoder thread alone. - rtc::ThreadChecker thread_checker_; // Sequence number unwrapper. - SequenceNumberUnwrapper unwrapper_ GUARDED_BY(thread_checker_); + SequenceNumberUnwrapper unwrapper_ GUARDED_BY(crit_sect_); // Min playout delay value on the next frame if |send_playout_delay_| is set. - int min_playout_delay_ms_ GUARDED_BY(thread_checker_); + int min_playout_delay_ms_ GUARDED_BY(crit_sect_); // Max playout delay value on the next frame if |send_playout_delay_| is set. - int max_playout_delay_ms_ GUARDED_BY(thread_checker_); + int max_playout_delay_ms_ GUARDED_BY(crit_sect_); RTC_DISALLOW_COPY_AND_ASSIGN(PlayoutDelayOracle); };