Bug 1547354 - Hold mMutex during stats calls; r=ng, a=RyanVM
authorDan Minor <dminor@mozilla.com>
Fri, 10 Jan 2020 15:08:04 +0000
changeset 524418 83b95131e4d6ea0c68b03f5f82f38de66147c99a
parent 524417 27f71a0b7aa25c9e17bd0e9eebbd9ffab2df6b81
child 524419 3b3f5444c5478582bc4a91237d1761b0868181ae
push id765
push userryanvm@gmail.com
push dateTue, 14 Jan 2020 22:56:39 +0000
treeherdermozilla-esr68@3b3f5444c547 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersng, RyanVM
bugs1547354, 1404992
milestone68.5.0
Bug 1547354 - Hold mMutex during stats calls; r=ng, a=RyanVM We did this for the VideoConduit in Bug 1404992, but not for the AudioConduit because of the ongoing webrtc.org upstream merge. Differential Revision: https://phabricator.services.mozilla.com/D59424
media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
--- a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
@@ -154,36 +154,39 @@ bool WebrtcAudioConduit::SetLocalMID(con
 void WebrtcAudioConduit::SetSyncGroup(const std::string& group) {
   MOZ_ASSERT(NS_IsMainThread());
   mRecvStreamConfig.sync_group = group;
 }
 
 bool WebrtcAudioConduit::GetSendPacketTypeStats(
     webrtc::RtcpPacketTypeCounter* aPacketCounts) {
   ASSERT_ON_THREAD(mStsThread);
+  MutexAutoLock lock(mMutex);
   if (!mSendStream) {
     return false;
   }
   return mSendChannelProxy->GetRTCPPacketTypeCounters(*aPacketCounts);
 }
 
 bool WebrtcAudioConduit::GetRecvPacketTypeStats(
     webrtc::RtcpPacketTypeCounter* aPacketCounts) {
   ASSERT_ON_THREAD(mStsThread);
+  MutexAutoLock lock(mMutex);
   if (!mEngineReceiving) {
     return false;
   }
   return mRecvChannelProxy->GetRTCPPacketTypeCounters(*aPacketCounts);
 }
 
 bool WebrtcAudioConduit::GetRTPReceiverStats(unsigned int* jitterMs,
                                              unsigned int* cumulativeLost) {
   ASSERT_ON_THREAD(mStsThread);
   *jitterMs = 0;
   *cumulativeLost = 0;
+  MutexAutoLock lock(mMutex);
   if (!mRecvStream) {
     return false;
   }
   auto stats = mRecvStream->GetStats();
   *jitterMs = stats.jitter_ms;
   *cumulativeLost = stats.packets_lost;
   return true;
 }
@@ -193,16 +196,17 @@ bool WebrtcAudioConduit::GetRTCPReceiver
                                                uint64_t* bytesReceived,
                                                uint32_t* cumulativeLost,
                                                Maybe<double>* aOutRttSec) {
   ASSERT_ON_THREAD(mStsThread);
   double fractionLost = 0.0;
   int64_t timestampTmp = 0;
   int64_t rttMsTmp = 0;
   bool res = false;
+  MutexAutoLock lock(mMutex);
   if (mSendChannelProxy) {
     res = mSendChannelProxy->GetRTCPReceiverStatistics(
         &timestampTmp, jitterMs, cumulativeLost, packetsReceived, bytesReceived,
         &fractionLost, &rttMsTmp);
   }
 
   const auto stats = mCall->Call()->GetStats();
   const auto rtt = stats.rtt_ms;
@@ -228,16 +232,17 @@ bool WebrtcAudioConduit::GetRTCPReceiver
   }
   *aOutRttSec = mRttSec;
   return res;
 }
 
 bool WebrtcAudioConduit::GetRTCPSenderReport(unsigned int* packetsSent,
                                              uint64_t* bytesSent) {
   ASSERT_ON_THREAD(mStsThread);
+  MutexAutoLock lock(mMutex);
   if (!mRecvChannelProxy) {
     return false;
   }
 
   webrtc::CallStatistics stats = mRecvChannelProxy->GetRTCPStatistics();
   *packetsSent = stats.rtcp_sender_packets_sent;
   *bytesSent = stats.rtcp_sender_octets_sent;
   return *packetsSent > 0 && *bytesSent > 0;