AudioPolicyManager: fix setStreamVolumeIndex().
Fix bug in setStreamVolumeIndex causing default volume not
being applied on active streams.
Bug: 31489345
Change-Id: I7d54ab63a7473b211c26c28099fbe8d9440fced3
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 1ddfb4d..b2106cd 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -1903,19 +1903,21 @@
continue;
}
routing_strategy curStrategy = getStrategy((audio_stream_type_t)curStream);
- audio_devices_t curStreamDevice = getDeviceForStrategy(curStrategy, true /*fromCache*/);
- if ((curStreamDevice & device) == 0) {
+ audio_devices_t curStreamDevice = getDeviceForStrategy(curStrategy, false /*fromCache*/);
+ if ((device != AUDIO_DEVICE_OUT_DEFAULT_FOR_VOLUME) &&
+ ((curStreamDevice & device) == 0)) {
continue;
}
- bool applyDefault = false;
+ bool applyVolume;
if (device != AUDIO_DEVICE_OUT_DEFAULT_FOR_VOLUME) {
curStreamDevice |= device;
- } else if (!mVolumeCurves->hasVolumeIndexForDevice(
- stream, Volume::getDeviceForVolume(curStreamDevice))) {
- applyDefault = true;
+ applyVolume = (curDevice & curStreamDevice) != 0;
+ } else {
+ applyVolume = !mVolumeCurves->hasVolumeIndexForDevice(
+ stream, Volume::getDeviceForVolume(curStreamDevice));
}
- if (applyDefault || ((curDevice & curStreamDevice) != 0)) {
+ if (applyVolume) {
//FIXME: workaround for truncated touch sounds
// delayed volume change for system stream to be removed when the problem is
// handled by system UI