diff options
| author | Jean-Michel Trivi <jmtrivi@google.com> | 2015-01-16 17:23:36 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-01-16 17:23:36 +0000 |
| commit | 6a64a9cd26cb8096f1ea67f7c7eee788370752b0 (patch) | |
| tree | 53f11dc764c60520c5185726c04d07dec0aa55cd /media | |
| parent | 0b486da65076c13c98ab3973128c64f452b4c589 (diff) | |
| parent | 4fe7795347851334ac52b925105f9dc8068f4809 (diff) | |
| download | frameworks_base-6a64a9cd26cb8096f1ea67f7c7eee788370752b0.zip frameworks_base-6a64a9cd26cb8096f1ea67f7c7eee788370752b0.tar.gz frameworks_base-6a64a9cd26cb8096f1ea67f7c7eee788370752b0.tar.bz2 | |
Merge "Prevent AudioService dead lock issue."
Diffstat (limited to 'media')
| -rw-r--r-- | media/java/android/media/AudioService.java | 19 |
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)); |
