Keep AudioHandlers alive until they can be safely deleted.

When an AudioNode is disposed, the handler is also disposed.  But add
the handler to the orphan list so that the handler stays alive until
the context can safely delete it.  If we don't do this, the handler
may get deleted while the audio thread is processing the handler (due
to, say, channel count changes and such).

For an realtime context, always save the handler just in case the
audio thread is running after the context is marked as closed (because
the audio thread doesn't instantly stop when requested).

For an offline context, only need to do this when the context is
running because the context is guaranteed to be stopped if we're not
in the running state.  Hence, there's no possibility of deleting the
handler while the graph is running.

This is a revert of
https://chromium-review.googlesource.com/c/chromium/src/+/860779, with
a fix for the leak.

Bug: 780919
Change-Id: Ifb6b5fcf3fbc373f5779256688731245771da33c
Reviewed-on: https://chromium-review.googlesource.com/862723
Reviewed-by: Hongchan Choi <hongchan@chromium.org>
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#528829}
1 file changed