Commit 279360c0 authored by Raymond Toy's avatar Raymond Toy Committed by Commit Bot

Check finished handlers when making a connection

When a connection is made, we remove the node from the list of tail
processing nodes.  But we didn't remove the node from the list of
finished handlers.  This is needed too because if we don't, when the
finished handlers are processed, they'll disable their outputs
incorrectly.

Bug: 849189
Test: 
Change-Id: I11a5467d8ed42d9819b19a63c27e7838225f39e1
Reviewed-on: https://chromium-review.googlesource.com/1087725Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565013}
parent 9c9040c1
...@@ -413,6 +413,14 @@ void AudioHandler::EnableOutputsIfNecessary() { ...@@ -413,6 +413,14 @@ void AudioHandler::EnableOutputsIfNecessary() {
// outputs later on when the tail processing time has elapsed. // outputs later on when the tail processing time has elapsed.
Context()->GetDeferredTaskHandler().RemoveTailProcessingHandler(this, false); Context()->GetDeferredTaskHandler().RemoveTailProcessingHandler(this, false);
#if DEBUG_AUDIONODE_REFERENCES > 1
fprintf(stderr,
"[%16p]: %16p: %2d: EnableOutputsIfNecessary: is_disabled %d count "
"%d output size %zu\n",
Context(), this, GetNodeType(), is_disabled_, connection_ref_count_,
outputs_.size());
#endif
if (is_disabled_ && connection_ref_count_ > 0) { if (is_disabled_ && connection_ref_count_ > 0) {
is_disabled_ = false; is_disabled_ = false;
for (auto& output : outputs_) for (auto& output : outputs_)
...@@ -537,9 +545,10 @@ void AudioHandler::PrintNodeCounts() { ...@@ -537,9 +545,10 @@ void AudioHandler::PrintNodeCounts() {
#endif // DEBUG_AUDIONODE_REFERENCES #endif // DEBUG_AUDIONODE_REFERENCES
#if DEBUG_AUDIONODE_REFERENCES > 1 #if DEBUG_AUDIONODE_REFERENCES > 1
void AudioHandler::TailProcessingDebug(const char* note) { void AudioHandler::TailProcessingDebug(const char* note, bool flag) {
fprintf(stderr, "[%16p]: %16p: %2d: %s %d @%.15g", Context(), this, fprintf(stderr, "[%16p]: %16p: %2d: %s %d @%.15g flag=%d", Context(), this,
GetNodeType(), note, connection_ref_count_, Context()->currentTime()); GetNodeType(), note, connection_ref_count_, Context()->currentTime(),
flag);
// If we're on the audio thread, we can print out the tail and // If we're on the audio thread, we can print out the tail and
// latency times (because these methods can only be called from the // latency times (because these methods can only be called from the
...@@ -553,11 +562,11 @@ void AudioHandler::TailProcessingDebug(const char* note) { ...@@ -553,11 +562,11 @@ void AudioHandler::TailProcessingDebug(const char* note) {
} }
void AudioHandler::AddTailProcessingDebug() { void AudioHandler::AddTailProcessingDebug() {
TailProcessingDebug("addTail"); TailProcessingDebug("addTail", false);
} }
void AudioHandler::RemoveTailProcessingDebug() { void AudioHandler::RemoveTailProcessingDebug(bool disable_outputs) {
TailProcessingDebug("remTail"); TailProcessingDebug("remTail", disable_outputs);
} }
#endif // DEBUG_AUDIONODE_REFERENCES > 1 #endif // DEBUG_AUDIONODE_REFERENCES > 1
...@@ -587,8 +596,9 @@ AudioNode::AudioNode(BaseAudioContext& context) ...@@ -587,8 +596,9 @@ AudioNode::AudioNode(BaseAudioContext& context)
void AudioNode::Dispose() { void AudioNode::Dispose() {
DCHECK(IsMainThread()); DCHECK(IsMainThread());
#if DEBUG_AUDIONODE_REFERENCES #if DEBUG_AUDIONODE_REFERENCES
fprintf(stderr, "[%16p]: %16p: %2d: AudioNode::dispose %16p\n", context(), fprintf(stderr, "[%16p]: %16p: %2d: AudioNode::dispose %16p @%g\n", context(),
this, Handler().GetNodeType(), handler_.get()); this, Handler().GetNodeType(), handler_.get(),
context()->currentTime());
#endif #endif
BaseAudioContext::GraphAutoLocker locker(context()); BaseAudioContext::GraphAutoLocker locker(context());
Handler().Dispose(); Handler().Dispose();
......
...@@ -182,9 +182,9 @@ class MODULES_EXPORT AudioHandler : public ThreadSafeRefCounted<AudioHandler> { ...@@ -182,9 +182,9 @@ class MODULES_EXPORT AudioHandler : public ThreadSafeRefCounted<AudioHandler> {
static void PrintNodeCounts(); static void PrintNodeCounts();
#endif #endif
#if DEBUG_AUDIONODE_REFERENCES > 1 #if DEBUG_AUDIONODE_REFERENCES > 1
void TailProcessingDebug(const char* debug_note); void TailProcessingDebug(const char* debug_note, bool flag);
void AddTailProcessingDebug(); void AddTailProcessingDebug();
void RemoveTailProcessingDebug(); void RemoveTailProcessingDebug(bool disable_outputs);
#endif #endif
// True if the node has a tail time or latency time that requires // True if the node has a tail time or latency time that requires
......
...@@ -190,7 +190,7 @@ void DeferredTaskHandler::RemoveTailProcessingHandler( ...@@ -190,7 +190,7 @@ void DeferredTaskHandler::RemoveTailProcessingHandler(
size_t index = tail_processing_handlers_.Find(handler); size_t index = tail_processing_handlers_.Find(handler);
if (index != kNotFound) { if (index != kNotFound) {
#if DEBUG_AUDIONODE_REFERENCES > 1 #if DEBUG_AUDIONODE_REFERENCES > 1
handler->RemoveTailProcessingDebug(); handler->RemoveTailProcessingDebug(disable_outputs);
#endif #endif
if (disable_outputs) { if (disable_outputs) {
...@@ -199,6 +199,19 @@ void DeferredTaskHandler::RemoveTailProcessingHandler( ...@@ -199,6 +199,19 @@ void DeferredTaskHandler::RemoveTailProcessingHandler(
finished_tail_processing_handlers_.push_back(handler); finished_tail_processing_handlers_.push_back(handler);
} }
tail_processing_handlers_.EraseAt(index); tail_processing_handlers_.EraseAt(index);
return;
}
// Check finished tail handlers and remove this handler from the list so that
// we don't disable outputs later when these are processed.
index = finished_tail_processing_handlers_.Find(handler);
if (index != kNotFound) {
#if DEBUG_AUDIONODE_REFERENCES > 1
handler->RemoveTailProcessingDebug(disable_outputs);
#endif
finished_tail_processing_handlers_.EraseAt(index);
return;
} }
} }
...@@ -351,7 +364,12 @@ void DeferredTaskHandler::DisableOutputsForTailProcessing() { ...@@ -351,7 +364,12 @@ void DeferredTaskHandler::DisableOutputsForTailProcessing() {
// disable their outputs to indicate to downstream nodes that they're done. // disable their outputs to indicate to downstream nodes that they're done.
// This has to be done in the main thread because DisableOutputs() can cause // This has to be done in the main thread because DisableOutputs() can cause
// summing juctions to go away, which must be done on the main thread. // summing juctions to go away, which must be done on the main thread.
for (auto& handler : finished_tail_processing_handlers_) { for (auto handler : finished_tail_processing_handlers_) {
#if DEBUG_AUDIONODE_REFERENCES > 1
fprintf(stderr, "[%16p]: %16p: %2d: DisableOutputsForTailProcessing @%g\n",
handler->Context(), handler.get(), handler->GetNodeType(),
handler->Context()->currentTime());
#endif
handler->DisableOutputs(); handler->DisableOutputs();
} }
finished_tail_processing_handlers_.clear(); finished_tail_processing_handlers_.clear();
......
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