Bug 1435673 - Do some cleanup that was meant to happen earlier. r?padenot draft
authorAndreas Pehrson <pehrsons@mozilla.com>
Mon, 05 Feb 2018 10:54:10 +0100
changeset 751120 3894ada58a10001b1ea7b658118474f25436f1e6
parent 751119 38ef97e16e0397ade3cce0b7d1f198406b00115c
child 751121 fe17834d1c44c4e84658ff38389fd7ccf1f70b34
push id97865
push userbmo:apehrson@mozilla.com
push dateMon, 05 Feb 2018 13:47:03 +0000
reviewerspadenot
bugs1435673
milestone60.0a1
Bug 1435673 - Do some cleanup that was meant to happen earlier. r?padenot MozReview-Commit-ID: 1v07YH1hKiG
dom/media/webrtc/MediaEngineWebRTCAudio.cpp
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -639,33 +639,23 @@ MediaEngineWebRTCMicrophoneSource::SetTr
   // from opening an already-open device.  If it's the same tab, they
   // will share a Graph(), and we can allow it.
   if (!mAllocations.IsEmpty() &&
       mAllocations[0].mStream &&
       mAllocations[0].mStream->Graph() != aStream->Graph()) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
-  Allocation* allocation = nullptr;
-  for (Allocation& a : mAllocations) {
-    if (!a.mStream) {
-      // This assumes Allocate() is always followed by Start() before another
-      // Allocate(). But this is changing in one of the coming patches anyway.
-      allocation = &a;
-      break;
-    }
-  }
-  MOZ_ASSERT(allocation);
-  // size_t i = mAllocations.IndexOf(aHandle, 0, AllocationHandleComparator());
-  // MOZ_ASSERT(i != mAllocations.NoIndex);
+  size_t i = mAllocations.IndexOf(aHandle, 0, AllocationHandleComparator());
+  MOZ_ASSERT(i != mAllocations.NoIndex);
   {
     MutexAutoLock lock(mMutex);
-    allocation->mStream = aStream;
-    allocation->mTrackID = aTrackID;
-    allocation->mPrincipal = aPrincipal;
+    mAllocations[i].mStream = aStream;
+    mAllocations[i].mTrackID = aTrackID;
+    mAllocations[i].mPrincipal = aPrincipal;
   }
 
   AudioSegment* segment = new AudioSegment();
 
   aStream->AddAudioTrack(aTrackID,
                          aStream->GraphRate(),
                          0,
                          segment,
@@ -702,21 +692,17 @@ MediaEngineWebRTCMicrophoneSource::Start
     }
 
     // Make sure logger starts before capture
     AsyncLatencyLogger::Get(true);
 
     // Must be *before* StartSend() so it will notice we selected external input (full_duplex)
     mAudioInput->StartRecording(allocation.mStream, mListener);
 
-    if (mState == kStarted) {
-      return NS_OK;
-    }
-    MOZ_ASSERT(mState == kAllocated || mState == kStopped);
-
+    MOZ_ASSERT(mState != kReleased);
     mState = kStarted;
   }
 
   return NS_OK;
 }
 
 nsresult
 MediaEngineWebRTCMicrophoneSource::Stop(const RefPtr<const AllocationHandle>& aHandle)