Visualizer: fix native crash when visualizer release

When the Visualizer effect is released, synchronous wait for the CaptureThread can
cause ANR in an app. This is why an asynchronous 'release' method is introduced which
is used by Visualizer.release() method on the Java side. Since CaptureThread may still
be running while the the last reference to the Visualizer instance is released,
CaptureThread now holds a strong reference to the Visualizer, which it releases
upon exit from the thread loop.

The 'release' method does not check for 'enabled' status because setEnabled(false)
may fail due to audioserver calling AudioFlinger::EffectHandle::setControl to
hold control.

Bug: 124833084
Test: CTS VisualizerTest
Change-Id: I8d936f0f79540345d3e3675f6129bb942a08e423
Merged-In: I8d936f0f79540345d3e3675f6129bb942a08e423
Signed-off-by: zengjing <zengjing@xiaomi.com>
2 files changed