Bug 1435673 - Do some cleanup that was meant to happen earlier. r?padenot
MozReview-Commit-ID: 1v07YH1hKiG
--- 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)