AudioService: fix notifications with A2DP abs volume

When A2DP absolute volume is enabled, the music stream
software volume is maxed out because the headset applies
the volume.

We must also max out other streams playing over A2DP otherwise
they are attenuated twice and are barely audible.

Bug: 11316102.
Change-Id: I7e58c74cb683ad1d6f3b68abb0ef967c817fbf4f
This commit is contained in:
Eric Laurent
2013-10-30 18:31:07 -07:00
parent 17d28ca3d7
commit cd772d0434

View File

@@ -2913,12 +2913,10 @@ public class AudioService extends IAudioService.Stub {
int index;
if (isMuted()) {
index = 0;
} else if (mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_MUSIC &&
(device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0 &&
} else if ((device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0 &&
mAvrcpAbsVolSupported) {
index = (mIndexMax + 5)/10;
}
else {
} else {
index = (getIndex(device) + 5)/10;
}
AudioSystem.setStreamVolumeIndex(mStreamType, index, device);
@@ -2943,6 +2941,9 @@ public class AudioService extends IAudioService.Stub {
if (device != AudioSystem.DEVICE_OUT_DEFAULT) {
if (isMuted()) {
index = 0;
} else if ((device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0 &&
mAvrcpAbsVolSupported) {
index = (mIndexMax + 5)/10;
} else {
index = ((Integer)entry.getValue() + 5)/10;
}
@@ -3215,7 +3216,14 @@ public class AudioService extends IAudioService.Stub {
for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
if (streamType != streamState.mStreamType &&
mStreamVolumeAlias[streamType] == streamState.mStreamType) {
mStreamStates[streamType].applyDeviceVolume(getDeviceForStream(streamType));
// Make sure volume is also maxed out on A2DP device for aliased stream
// that may have a different device selected
int streamDevice = getDeviceForStream(streamType);
if ((device != streamDevice) && mAvrcpAbsVolSupported &&
((device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0)) {
mStreamStates[streamType].applyDeviceVolume(device);
}
mStreamStates[streamType].applyDeviceVolume(streamDevice);
}
}
@@ -3843,9 +3851,12 @@ public class AudioService extends IAudioService.Stub {
// address is not used for now, but may be used when multiple a2dp devices are supported
synchronized (mA2dpAvrcpLock) {
mAvrcpAbsVolSupported = support;
VolumeStreamState streamState = mStreamStates[AudioSystem.STREAM_MUSIC];
sendMsg(mAudioHandler, MSG_SET_DEVICE_VOLUME, SENDMSG_QUEUE,
AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, 0, streamState, 0);
AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, 0,
mStreamStates[AudioSystem.STREAM_MUSIC], 0);
sendMsg(mAudioHandler, MSG_SET_DEVICE_VOLUME, SENDMSG_QUEUE,
AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, 0,
mStreamStates[AudioSystem.STREAM_RING], 0);
}
}