Commit bec98d73 authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

Have the DeferredTaskHandler be the source of whether tail processing handlers can be added.

Bug: 884059
Change-Id: Iaee6daa6003c4956e6dba6d5351621b10bc0b5e1
Reviewed-on: https://chromium-review.googlesource.com/c/1332254Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608073}
parent 085b7a32
......@@ -450,10 +450,9 @@ void AudioHandler::DisableOutputsIfNecessary() {
// the outputs so that the tail for the node can be output.
// Otherwise, we can disable the outputs right away.
if (RequiresTailProcessing()) {
if (Context()->ContextState() !=
BaseAudioContext::AudioContextState::kClosed) {
Context()->GetDeferredTaskHandler().AddTailProcessingHandler(this);
}
auto& deferred_task_handler = Context()->GetDeferredTaskHandler();
if (deferred_task_handler.AcceptsTailProcessing())
deferred_task_handler.AddTailProcessingHandler(this);
} else {
DisableOutputs();
}
......
......@@ -612,6 +612,9 @@ void BaseAudioContext::SetContextState(AudioContextState new_state) {
WrapPersistent(this)));
}
if (new_state == kClosed)
GetDeferredTaskHandler().StopAcceptingTailProcessing();
// Notify context that state changed
if (GetExecutionContext()) {
GetExecutionContext()
......
......@@ -167,6 +167,7 @@ void DeferredTaskHandler::ProcessAutomaticPullNodes(size_t frames_to_process) {
void DeferredTaskHandler::AddTailProcessingHandler(
scoped_refptr<AudioHandler> handler) {
DCHECK(accepts_tail_processing_);
AssertGraphOwner();
if (!tail_processing_handlers_.Contains(handler)) {
......
......@@ -109,6 +109,9 @@ class MODULES_EXPORT DeferredTaskHandler final
void RequestToDeleteHandlersOnMainThread();
void ClearHandlersToBeDeleted();
bool AcceptsTailProcessing() const { return accepts_tail_processing_; }
void StopAcceptingTailProcessing() { accepts_tail_processing_ = false; }
// If |node| requires tail processing, add it to the list of tail
// nodes so the tail is processed.
void AddTailProcessingHandler(scoped_refptr<AudioHandler>);
......@@ -228,11 +231,16 @@ class MODULES_EXPORT DeferredTaskHandler final
// Nodes that are processing its tail.
Vector<scoped_refptr<AudioHandler>> tail_processing_handlers_;
// Tail processing nodes that are now finished and want the output to be
// disabled. This is updated in the audio thread (with the graph lock). The
// main thread will disable the outputs.
Vector<scoped_refptr<AudioHandler>> finished_tail_processing_handlers_;
// Once the associated context closes, new tail processing handlers are not
// accepted.
bool accepts_tail_processing_ = true;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
// Graph locking.
......
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