Skip to content
Commit 261a9f94 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

AudioService: simplify/document locking

  In AudioDeviceBroker, mDeviceStateLock was the main lock and
was previously used almost as a global synchronization, present
on the handling of most messages, and numerous other methods
without actually protecting the only states it maintains. Note
that BtHelper and AudioDeviceInventory have their own sync
model, so they don't need to be protected by a lock from
AudioDeviceBroker.
  This CL renames mDeviceStateLock to mDeviceBrokerLock
specifically protecting:
- "force use" setting for communication
- Bluetooth A2DP enabled (coming from AudioManager API)
- all management of the message queue, both for enqueueing
  and removal (which was exposed to race condition since commit
  dc552e9d for A2DP (dis)connection.
It also removes the lock used to synchronize the audio mode
owner with the SCO operations: the only information AudioDeviceBroker
needed from AudioService regarding audio mode was the PID of the
mode owner. The new code uses an atomic integer to store/provide
this information, instead of relying on a shared lock amongst
multiple classes.
  Add test for behavior where media gets unmuted if it was muted
when the user connects an A2DP headset.

Bug: 140200704
Test: atest AudioDeviceBrokerTest ; atest AudioManagerTest
Change-Id: If6a98d8aad61da6eef4b54ef9c57dc80d74be593
parent 7bd4314e
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment