summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2012-02-15 18:40:31 -0800
committerEric Laurent <elaurent@google.com>2012-02-15 18:40:31 -0800
commitc5eb8b4a5d4395ce335bc7c3e6df2678fa47e2dd (patch)
treedbc68ad3c663b69a751c5b80104049fd907a5069
parent02243837e48475c89ec1bbd25e1af49f38d8558a (diff)
downloadhardware_libhardware_legacy-c5eb8b4a5d4395ce335bc7c3e6df2678fa47e2dd.zip
hardware_libhardware_legacy-c5eb8b4a5d4395ce335bc7c3e6df2678fa47e2dd.tar.gz
hardware_libhardware_legacy-c5eb8b4a5d4395ce335bc7c3e6df2678fa47e2dd.tar.bz2
Fix volume not restored when exiting silent mode
The change for volume per device introduced a problem where if a headset is plugged in while in silent mode, the sound will not be restored at the first press on volume up key but only at the second press. This is because when exiting silent mode, AudioService reapplies the last known volume for all devices in any order and the last volume applied prevails, even if it is for a device other than currently selected by audio policy manager. The fix consists in applying a new volume only if the device indicated matches currently selected device on an output. Change-Id: I778b90a9ec5a8b4a15e0333bd045f2dd327f388c
-rw-r--r--audio/AudioPolicyManagerBase.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/audio/AudioPolicyManagerBase.cpp b/audio/AudioPolicyManagerBase.cpp
index 6db942b..ae8fe5e 100644
--- a/audio/AudioPolicyManagerBase.cpp
+++ b/audio/AudioPolicyManagerBase.cpp
@@ -839,9 +839,13 @@ status_t AudioPolicyManagerBase::setStreamVolumeIndex(AudioSystem::stream_type s
// compute and apply stream volume on all outputs according to connected device
status_t status = NO_ERROR;
for (size_t i = 0; i < mOutputs.size(); i++) {
- status_t volStatus = checkAndSetVolume(stream, index, mOutputs.keyAt(i), mOutputs.valueAt(i)->device());
- if (volStatus != NO_ERROR) {
- status = volStatus;
+ audio_devices_t curDevice =
+ getDeviceForVolume((audio_devices_t)mOutputs.valueAt(i)->device());
+ if (device == curDevice) {
+ status_t volStatus = checkAndSetVolume(stream, index, mOutputs.keyAt(i), curDevice);
+ if (volStatus != NO_ERROR) {
+ status = volStatus;
+ }
}
}
return status;