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 751091 11d3c00e215045bb64f1745e842050e9967b8f19
parent 751090 1ba19c27797cac2c72ae422c6cffc50e434e4d9e
child 751092 a10549764b7c7cd043f151a6e4881e7d9f17364c
push id97847
push userbmo:apehrson@mozilla.com
push dateMon, 05 Feb 2018 10:00:19 +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
@@ -644,33 +644,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,
@@ -707,21 +697,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)