Bug 1517710 - Avoid calling SetPullingEnabled on a destroyed MediaStream. r=padenot

Differential Revision: https://phabricator.services.mozilla.com/D15798

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Pehrson 2019-01-07 08:24:08 +00:00
Родитель 0f512a6434
Коммит 97ca0d12ba
1 изменённых файлов: 7 добавлений и 11 удалений

Просмотреть файл

@ -570,17 +570,15 @@ nsresult MediaEngineWebRTCMicrophoneSource::Start(
mTrackID, mPrincipal);
RefPtr<MediaEngineWebRTCMicrophoneSource> that = this;
RefPtr<MediaStreamGraphImpl> gripGraph = mStream->GraphImpl();
NS_DispatchToMainThread(
media::NewRunnableFrom([that, graph = std::move(gripGraph), deviceID,
stream = mStream, track = mTrackID]() {
if (graph) {
NS_DispatchToMainThread(media::NewRunnableFrom(
[that, deviceID, stream = mStream, track = mTrackID]() {
if (MediaStreamGraphImpl* graph = stream->GraphImpl()) {
graph->AppendMessage(MakeUnique<StartStopMessage>(
that->mInputProcessing, StartStopMessage::Start));
stream->SetPullingEnabled(track, true);
}
stream->OpenAudioInput(deviceID, that->mInputProcessing);
stream->SetPullingEnabled(track, true);
return NS_OK;
}));
@ -606,11 +604,10 @@ nsresult MediaEngineWebRTCMicrophoneSource::Stop(
}
RefPtr<MediaEngineWebRTCMicrophoneSource> that = this;
RefPtr<MediaStreamGraphImpl> gripGraph = mStream->GraphImpl();
NS_DispatchToMainThread(
media::NewRunnableFrom([that, graph = std::move(gripGraph),
stream = mStream, track = mTrackID]() {
if (graph) {
media::NewRunnableFrom([that, stream = mStream, track = mTrackID]() {
if (MediaStreamGraphImpl* graph = stream->GraphImpl()) {
stream->SetPullingEnabled(track, false);
graph->AppendMessage(MakeUnique<StartStopMessage>(
that->mInputProcessing, StartStopMessage::Stop));
}
@ -618,7 +615,6 @@ nsresult MediaEngineWebRTCMicrophoneSource::Stop(
CubebUtils::AudioDeviceID deviceID = that->mDeviceInfo->DeviceID();
Maybe<CubebUtils::AudioDeviceID> id = Some(deviceID);
stream->CloseAudioInput(id, that->mInputProcessing);
stream->SetPullingEnabled(track, false);
return NS_OK;
}));