Add lock annotations in StreamStatisticianImpl

Also consolidate lock operations to public methods only, moving one
CritScope out of UpdateCounters (private) up to IncomingPacket
(public).

Bug: webrtc:7135
Change-Id: I458857d3cfa49961fa34196ffe02cdefd83cec10
Reviewed-on: https://webrtc-review.googlesource.com/96122
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24443}
This commit is contained in:
Niels Möller
2018-08-27 12:32:21 +02:00
committed by Commit Bot
parent a1e4ae2371
commit b615d1af90
2 changed files with 29 additions and 21 deletions

View File

@ -57,7 +57,12 @@ StreamStatisticianImpl::~StreamStatisticianImpl() = default;
void StreamStatisticianImpl::IncomingPacket(const RTPHeader& header,
size_t packet_length,
bool retransmitted) {
auto counters = UpdateCounters(header, packet_length, retransmitted);
StreamDataCounters counters;
{
rtc::CritScope cs(&stream_lock_);
counters = UpdateCounters(header, packet_length, retransmitted);
}
rtp_callback_->DataCountersUpdated(counters, ssrc_);
}
@ -65,7 +70,6 @@ StreamDataCounters StreamStatisticianImpl::UpdateCounters(
const RTPHeader& header,
size_t packet_length,
bool retransmitted) {
rtc::CritScope cs(&stream_lock_);
bool in_order = InOrderPacketInternal(header.sequenceNumber);
RTC_DCHECK_EQ(ssrc_, header.ssrc);
incoming_bitrate_.Update(packet_length, clock_->TimeInMilliseconds());