Bug 802661: Clean up getUserMedia MediaStream handling r=roc,anant

This commit is contained in:
Randell Jesup 2012-10-17 17:40:14 -04:00
parent 6fac36bac0
commit bb05ef58b2
3 changed files with 16 additions and 5 deletions

View File

@ -125,7 +125,12 @@ MediaEngineWebRTCAudioSource::Stop()
return NS_ERROR_FAILURE;
}
mState = kStopped;
{
ReentrantMonitorAutoEnter enter(mMonitor);
mState = kStopped;
mSource->EndTrack(mTrackID);
}
return NS_OK;
}
@ -224,6 +229,8 @@ MediaEngineWebRTCAudioSource::Process(const int channel,
const int length, const int samplingFreq, const bool isStereo)
{
ReentrantMonitorAutoEnter enter(mMonitor);
if (mState != kStarted)
return;
nsRefPtr<SharedBuffer> buffer = SharedBuffer::Create(length * sizeof(sample));

View File

@ -102,7 +102,6 @@ MediaEngineWebRTCVideoSource::NotifyPull(MediaStreamGraph* aGraph,
VideoSegment segment;
ReentrantMonitorAutoEnter enter(mMonitor);
if (mState != kStarted)
return;
@ -278,14 +277,16 @@ MediaEngineWebRTCVideoSource::Stop()
return NS_ERROR_FAILURE;
}
mSource->EndTrack(mTrackID);
mSource->Finish();
{
ReentrantMonitorAutoEnter enter(mMonitor);
mState = kStopped;
mSource->EndTrack(mTrackID);
}
mViERender->StopRender(mCaptureIndex);
mViERender->RemoveRenderer(mCaptureIndex);
mViECapture->StopCapture(mCaptureIndex);
mState = kStopped;
return NS_OK;
}

View File

@ -97,6 +97,9 @@ public:
mVideoSource->Stop();
mVideoSource->Deallocate();
}
// Do this after stopping all tracks with EndTrack()
mStream->GetStream()->AsSourceStream()->Finish();
nsCOMPtr<GetUserMediaNotificationEvent> event =
new GetUserMediaNotificationEvent(GetUserMediaNotificationEvent::STOPPING);