Fix thread safety in libaudioclient tests

The code of the tests was prone to two classical issues:

 - lacking of synchronization when accessing shared data;
 - use of improper locking patterns leading to deadlocks.

The latter was the cause for the flakiness of audiorouting_tests.
Holding a lock in `AudioPlayback::stop` was deadlocking audio
thread stopping due to a call to `AudioPlayback::onBufferEnd`

Bug: 329261852
Bug: 329528237
Bug: 330520703
Bug: 343592164
Test: atest --iterations=100 audiorouting_tests
Test: atest --iterations=10 audiorecord_tests
Change-Id: I38224c49cb5583af5f1ba469f3bb956b3b600d57
7 files changed