Commit e4c27b50 authored by Hongchan Choi's avatar Hongchan Choi Committed by Commit Bot

Remove tear_down_mutex_ from BaseAudioContext

In favor of the self-referencing patch, this mutex can be safely
removed.

Test: Ran the patch on a repro case from crbug.com/1029462 and saw no crash after 20 min.
Bug: 1058555
Change-Id: I0335fa6c878f4ca7e52a03ed7eb6fc0891dfa3ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088491Reviewed-by: default avatarRaymond Toy <rtoy@chromium.org>
Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Hongchan Choi <hongchan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748376}
parent cf24a7aa
......@@ -150,8 +150,6 @@ void BaseAudioContext::Clear() {
void BaseAudioContext::Uninitialize() {
DCHECK(IsMainThread());
MutexLocker locker(GetTearDownMutex());
if (!IsDestinationInitialized())
return;
......
......@@ -328,8 +328,6 @@ class MODULES_EXPORT BaseAudioContext
void ReportDidCreate() final;
void ReportWillBeDestroyed() final;
Mutex& GetTearDownMutex() const { return tear_down_mutex_; }
protected:
enum ContextType { kRealtimeContext, kOfflineContext };
......@@ -431,12 +429,6 @@ class MODULES_EXPORT BaseAudioContext
// This cannot be nullptr once it is assigned from AudioWorkletThread until
// the BaseAudioContext goes away.
WorkerThread* audio_worklet_thread_ = nullptr;
// Due to the multi-threading architecture of WebAudio, it is possible that
// object allocated by the main thread still can be accessed by the audio
// rendering thread while this context is torn down (GCed) by
// |Uninitialize()|.
mutable Mutex tear_down_mutex_;
};
} // namespace blink
......
......@@ -293,33 +293,25 @@ bool OfflineAudioDestinationHandler::RenderIfNotSuspended(
return true;
}
{
MutexTryLocker try_locker(Context()->GetTearDownMutex());
if (try_locker.Locked()) {
DCHECK_GE(NumberOfInputs(), 1u);
// This will cause the node(s) connected to us to process, which in turn
// will pull on their input(s), all the way backwards through the
// rendering graph.
scoped_refptr<AudioBus> rendered_bus =
Input(0).Pull(destination_bus, number_of_frames);
if (!rendered_bus) {
destination_bus->Zero();
} else if (rendered_bus != destination_bus) {
// in-place processing was not possible - so copy
destination_bus->CopyFrom(*rendered_bus);
}
} else {
destination_bus->Zero();
}
DCHECK_GE(NumberOfInputs(), 1u);
// Process nodes which need a little extra help because they are not
// connected to anything, but still need to process.
Context()->GetDeferredTaskHandler().ProcessAutomaticPullNodes(
number_of_frames);
// This will cause the node(s) connected to us to process, which in turn will
// pull on their input(s), all the way backwards through the rendering graph.
scoped_refptr<AudioBus> rendered_bus =
Input(0).Pull(destination_bus, number_of_frames);
if (!rendered_bus) {
destination_bus->Zero();
} else if (rendered_bus != destination_bus) {
// in-place processing was not possible - so copy
destination_bus->CopyFrom(*rendered_bus);
}
// Process nodes which need a little extra help because they are not connected
// to anything, but still need to process.
Context()->GetDeferredTaskHandler().ProcessAutomaticPullNodes(
number_of_frames);
// Let the context take care of any business at the end of each render
// quantum.
Context()->HandlePostRenderTasks();
......
......@@ -198,35 +198,30 @@ void RealtimeAudioDestinationHandler::Render(
// Only pull on the audio graph if we have not stopped the destination. It
// takes time for the destination to stop, but we want to stop pulling before
// the destination has actually stopped.
{
MutexTryLocker try_locker(context->GetTearDownMutex());
if (try_locker.Locked() && IsPullingAudioGraphAllowed()) {
// Renders the graph by pulling all the inputs to this node. This will
// in turn pull on their inputs, all the way backwards through the graph.
scoped_refptr<AudioBus> rendered_bus =
Input(0).Pull(destination_bus, number_of_frames);
DCHECK(rendered_bus);
if (!rendered_bus) {
// AudioNodeInput might be in the middle of destruction. Then the
// internal summing bus will return as nullptr. Then zero out the
// output.
destination_bus->Zero();
} else if (rendered_bus != destination_bus) {
// In-place processing was not possible. Copy the rendererd result to
// the given |destination_bus| buffer.
destination_bus->CopyFrom(*rendered_bus);
}
} else {
if (IsPullingAudioGraphAllowed()) {
// Renders the graph by pulling all the inputs to this node. This will in
// turn pull on their inputs, all the way backwards through the graph.
scoped_refptr<AudioBus> rendered_bus =
Input(0).Pull(destination_bus, number_of_frames);
DCHECK(rendered_bus);
if (!rendered_bus) {
// AudioNodeInput might be in the middle of destruction. Then the internal
// summing bus will return as nullptr. Then zero out the output.
destination_bus->Zero();
} else if (rendered_bus != destination_bus) {
// In-place processing was not possible. Copy the rendered result to the
// given |destination_bus| buffer.
destination_bus->CopyFrom(*rendered_bus);
}
// Processes "automatic" nodes that are not connected to anything. This can
// be done after copying because it does not affect the rendered result.
context->GetDeferredTaskHandler().ProcessAutomaticPullNodes(
number_of_frames);
} else {
destination_bus->Zero();
}
// Processes "automatic" nodes that are not connected to anything. This can
// be done after copying because it does not affect the rendered result.
context->GetDeferredTaskHandler().ProcessAutomaticPullNodes(number_of_frames);
context->HandlePostRenderTasks();
context->HandleAudibility(destination_bus);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment