summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eric Laurent <elaurent@google.com> 2016-04-07 14:04:23 -0700
committer Eric Laurent <elaurent@google.com> 2016-04-08 13:44:00 -0700
commitd9ac2be3e32472b042d1e977a86e2bad083cea16 (patch)
tree4b207b2c2a394b5ed7336db1c521b37b0651f089
parent8eb8a32f98915bc5fc009130d79d00021ef7a7c9 (diff)
audio service: fix volume burst on user switch
Change the convention on use of default device volume with audio policy manager: Now setting the default device volume on a stream does not reset all specific device volumes. The default volume is just used by audio policy manager if no specific device volume is present for a given selected device. Bug: 27557733 Change-Id: I1edd9530ccafc615d9353b9b06489c688e21f719
-rw-r--r--services/core/java/com/android/server/audio/AudioService.java24
1 files changed, 12 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index f471af6be143..58db9858b0d4 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -3954,25 +3954,16 @@ public class AudioService extends IAudioService.Stub {
public void applyAllVolumes() {
synchronized (VolumeStreamState.class) {
- // apply default volume first: by convention this will reset all
- // devices volumes in audio policy manager to the supplied value
+ // apply device specific volumes first
int index;
- if (mIsMuted) {
- index = 0;
- } else {
- index = (getIndex(AudioSystem.DEVICE_OUT_DEFAULT) + 5)/10;
- }
- AudioSystem.setStreamVolumeIndex(mStreamType, index, AudioSystem.DEVICE_OUT_DEFAULT);
- // then apply device specific volumes
for (int i = 0; i < mIndexMap.size(); i++) {
- int device = mIndexMap.keyAt(i);
+ final int device = mIndexMap.keyAt(i);
if (device != AudioSystem.DEVICE_OUT_DEFAULT) {
if (mIsMuted) {
index = 0;
} else if (((device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0 &&
mAvrcpAbsVolSupported)
- || ((device & mFullVolumeDevices) != 0))
- {
+ || ((device & mFullVolumeDevices) != 0)) {
index = (mIndexMax + 5)/10;
} else {
index = (mIndexMap.valueAt(i) + 5)/10;
@@ -3980,6 +3971,15 @@ public class AudioService extends IAudioService.Stub {
AudioSystem.setStreamVolumeIndex(mStreamType, index, device);
}
}
+ // apply default volume last: by convention , default device volume will be used
+ // by audio policy manager if no explicit volume is present for a given device type
+ if (mIsMuted) {
+ index = 0;
+ } else {
+ index = (getIndex(AudioSystem.DEVICE_OUT_DEFAULT) + 5)/10;
+ }
+ AudioSystem.setStreamVolumeIndex(
+ mStreamType, index, AudioSystem.DEVICE_OUT_DEFAULT);
}
}