зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1541467 - Handle situations where the document is not available from the AudioContext. r=karlt
Differential Revision: https://phabricator.services.mozilla.com/D25955 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c09ea2d6a7
Коммит
cbccf7ece3
|
@ -3288,9 +3288,16 @@ MediaStreamGraph* MediaStreamGraph::CreateNonRealtimeInstance(
|
|||
TrackRate aSampleRate, nsPIDOMWindowInner* aWindow) {
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Main thread only");
|
||||
|
||||
AbstractThread* mainThread = AbstractThread::MainThread();
|
||||
// aWindow can be null when the document is being unlinked, so this works when
|
||||
// with a generic main thread if that's the case.
|
||||
if (aWindow) {
|
||||
mainThread =
|
||||
aWindow->AsGlobal()->AbstractMainThreadFor(TaskCategory::Other);
|
||||
}
|
||||
|
||||
MediaStreamGraphImpl* graph = new MediaStreamGraphImpl(
|
||||
OFFLINE_THREAD_DRIVER, DIRECT_DRIVER, aSampleRate,
|
||||
aWindow->AsGlobal()->AbstractMainThreadFor(TaskCategory::Other));
|
||||
OFFLINE_THREAD_DRIVER, DIRECT_DRIVER, aSampleRate, mainThread);
|
||||
|
||||
LOG(LogLevel::Debug, ("Starting up Offline MediaStreamGraph %p", graph));
|
||||
|
||||
|
|
|
@ -336,6 +336,8 @@ AudioDestinationNode::AudioDestinationNode(AudioContext* aContext,
|
|||
return;
|
||||
}
|
||||
|
||||
// GetParentObject can return nullptr here. This will end up creating another
|
||||
// MediaStreamGraph
|
||||
MediaStreamGraph* graph = MediaStreamGraph::GetInstance(
|
||||
MediaStreamGraph::AUDIO_THREAD_DRIVER, aContext->GetParentObject(),
|
||||
aContext->SampleRate());
|
||||
|
@ -377,6 +379,8 @@ AudioNodeStream* AudioDestinationNode::Stream() {
|
|||
|
||||
MOZ_ASSERT(mIsOffline, "Realtime streams are created in constructor");
|
||||
|
||||
// GetParentObject can return nullptr here when the document has been
|
||||
// unlinked.
|
||||
MediaStreamGraph* graph = MediaStreamGraph::CreateNonRealtimeInstance(
|
||||
context->SampleRate(), context->GetParentObject());
|
||||
AudioNodeEngine* engine = new OfflineDestinationNodeEngine(this);
|
||||
|
|
|
@ -232,7 +232,10 @@ BiquadFilterNode::BiquadFilterNode(AudioContext* aContext)
|
|||
new AudioParam(this, BiquadFilterNodeEngine::DETUNE, "detune", 0.f)),
|
||||
mQ(new AudioParam(this, BiquadFilterNodeEngine::Q, "Q", 1.f)),
|
||||
mGain(new AudioParam(this, BiquadFilterNodeEngine::GAIN, "gain", 0.f)) {
|
||||
uint64_t windowID = aContext->GetParentObject()->WindowID();
|
||||
uint64_t windowID = 0;
|
||||
if (aContext->GetParentObject()) {
|
||||
windowID = aContext->GetParentObject()->WindowID();
|
||||
}
|
||||
BiquadFilterNodeEngine* engine =
|
||||
new BiquadFilterNodeEngine(this, aContext->Destination(), windowID);
|
||||
mStream = AudioNodeStream::Create(
|
||||
|
|
|
@ -385,7 +385,14 @@ ConvolverNode::ConvolverNode(AudioContext* aContext)
|
|||
: AudioNode(aContext, 2, ChannelCountMode::Clamped_max,
|
||||
ChannelInterpretation::Speakers),
|
||||
mNormalize(true) {
|
||||
uint64_t windowID = aContext->GetParentObject()->WindowID();
|
||||
uint64_t windowID;
|
||||
if (aContext->GetParentObject()) {
|
||||
windowID = aContext->GetParentObject()->WindowID();
|
||||
} else {
|
||||
// This is used to send a message to the developer console, but the page is
|
||||
// being closed so it doesn't matter too much.
|
||||
windowID = 0;
|
||||
}
|
||||
ConvolverNodeEngine* engine =
|
||||
new ConvolverNodeEngine(this, mNormalize, windowID);
|
||||
mStream = AudioNodeStream::Create(
|
||||
|
|
|
@ -148,7 +148,10 @@ IIRFilterNode::IIRFilterNode(AudioContext* aContext,
|
|||
// We check that this is exactly equal to one later in blink/IIRFilter.cpp
|
||||
elements[0] = 1.0;
|
||||
|
||||
uint64_t windowID = aContext->GetParentObject()->WindowID();
|
||||
uint64_t windowID = 0;
|
||||
if (aContext->GetParentObject()) {
|
||||
windowID = aContext->GetParentObject()->WindowID();
|
||||
}
|
||||
IIRFilterNodeEngine* engine = new IIRFilterNodeEngine(
|
||||
this, aContext->Destination(), mFeedforward, mFeedback, windowID);
|
||||
mStream = AudioNodeStream::Create(
|
||||
|
|
|
@ -71,10 +71,18 @@ MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode(
|
|||
ChannelInterpretation::Speakers),
|
||||
mDOMStream(DOMAudioNodeMediaStream::CreateTrackUnionStreamAsInput(
|
||||
GetOwner(), this, aContext->Graph())) {
|
||||
// Ensure an audio track with the correct ID is exposed to JS
|
||||
Document* doc = aContext->GetParentObject()->GetExtantDoc();
|
||||
// Ensure an audio track with the correct ID is exposed to JS. If we can't get
|
||||
// a principal here because the document is not available, pass in a null
|
||||
// principal. This happens in edge cases when the document is being unloaded
|
||||
// and it does not matter too much to have something working as long as it's
|
||||
// not dangerous.
|
||||
nsCOMPtr<nsIPrincipal> principal = nullptr;
|
||||
if (aContext->GetParentObject()) {
|
||||
Document* doc = aContext->GetParentObject()->GetExtantDoc();
|
||||
principal = doc->NodePrincipal();
|
||||
}
|
||||
RefPtr<MediaStreamTrackSource> source =
|
||||
new AudioDestinationTrackSource(this, doc->NodePrincipal());
|
||||
new AudioDestinationTrackSource(this, principal);
|
||||
RefPtr<MediaStreamTrack> track = mDOMStream->CreateDOMTrack(
|
||||
AudioNodeStream::AUDIO_TRACK, MediaSegment::AUDIO, source,
|
||||
MediaTrackConstraints());
|
||||
|
|
Загрузка…
Ссылка в новой задаче