SoundPool: Fix StreamManager JavaThread shutdown

std::future destructor only blocks for ready when created by std::async,
so do a wait in the JavaThread destructor.

Do not signal that the thread is closed until we really are finished
with all member variable access.

This fixes a rare race condition.

Test: SoundPool stress test
Test: SoundPoolAacTest SoundPoolHapticTest SoundPoolMidiTest SoundPoolOggTest
Bug: 150517918
Change-Id: I412143726956ee100069f711dd39b1d59ac100b0
1 file changed