summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorseunghwan.hong <seunghwan.hong@lge.com>2014-10-29 17:43:20 +0900
committerseunghwan.hong <seunghwan.hong@lge.com>2015-01-13 08:22:26 +0900
commit4fe7795347851334ac52b925105f9dc8068f4809 (patch)
tree3d58d4d4dc30410cd150d03fd14d8349ba04aa42 /media
parent9a6c45eedd112313e5b24111f23bc309a3dc5df6 (diff)
downloadframeworks_base-4fe7795347851334ac52b925105f9dc8068f4809.zip
frameworks_base-4fe7795347851334ac52b925105f9dc8068f4809.tar.gz
frameworks_base-4fe7795347851334ac52b925105f9dc8068f4809.tar.bz2
Prevent AudioService dead lock issue.
Dead lock sequence: 1. called onSetA2dpConnectionState() 1-1. synchronized(mConnectedDevices) 2. called onServiceDisconnected() 2-1. synchronized(mA2DPAvrcpLock) 3. waiting to lock(mConnectedDevices) in onServiceDisconnected() 4. waiting to lock(mA2DPAvrcpLock) in onSetA2dpConnectionState() ======================================================================================== - watchdog issue ----- pid 3306 at 2014-10-14 16:15:12 ----- Cmd line: system_server "main" prio=5 tid=1 MONITOR - waiting to lock <0x4343e9b0> (a java.util.HashMap) held by tid=46 (AudioService) at android.bluetooth.BluetoothA2dp$2.onServiceDisconnected(BluetoothA2dp.java:529) "AudioService" prio=5 tid=46 MONITOR - waiting to lock <0x42ab7a58> (a java.lang.Object) held by tid=1 (main) ======================================================================================== Signed-off-by: Seunghwan Hong <seunghwan.hong@lge.com> Change-Id: I99e061c07be01aabcd26786ef2ebb71f46717b93
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioService.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index b0bf4a1..8a78a8f 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -508,6 +508,7 @@ public class AudioService extends IAudioService.Stub {
// Reference to BluetoothA2dp to query for AbsoluteVolume.
private BluetoothA2dp mA2dp;
+ // lock always taken synchronized on mConnectedDevices
private final Object mA2dpAvrcpLock = new Object();
// If absolute volume is supported in AVRCP device
private boolean mAvrcpAbsVolSupported = false;
@@ -2731,12 +2732,12 @@ public class AudioService extends IAudioService.Stub {
List<BluetoothDevice> deviceList;
switch(profile) {
case BluetoothProfile.A2DP:
- synchronized (mA2dpAvrcpLock) {
- mA2dp = (BluetoothA2dp) proxy;
- deviceList = mA2dp.getConnectedDevices();
- if (deviceList.size() > 0) {
- btDevice = deviceList.get(0);
- synchronized (mConnectedDevices) {
+ synchronized (mConnectedDevices) {
+ synchronized (mA2dpAvrcpLock) {
+ mA2dp = (BluetoothA2dp) proxy;
+ deviceList = mA2dp.getConnectedDevices();
+ if (deviceList.size() > 0) {
+ btDevice = deviceList.get(0);
int state = mA2dp.getConnectionState(btDevice);
int delay = checkSendBecomingNoisyIntent(
AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
@@ -2831,9 +2832,9 @@ public class AudioService extends IAudioService.Stub {
public void onServiceDisconnected(int profile) {
switch(profile) {
case BluetoothProfile.A2DP:
- synchronized (mA2dpAvrcpLock) {
- mA2dp = null;
- synchronized (mConnectedDevices) {
+ synchronized (mConnectedDevices) {
+ synchronized (mA2dpAvrcpLock) {
+ mA2dp = null;
if (mConnectedDevices.containsKey(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP)) {
makeA2dpDeviceUnavailableNow(
mConnectedDevices.get(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP));