audio policy: fix stream to volume source mapping
remove use of obsolete method streamToVolumeSource()
and replace it by toVolumeSource() which actually queries
the engine for stream to volume source mapping.
Bug: 129439600
Test: make
Change-Id: Ie4e4e93aa5925315078fa96a957bb3ed71e7dc76
diff --git a/services/audiopolicy/common/include/Volume.h b/services/audiopolicy/common/include/Volume.h
index 561f100..54c5c76 100644
--- a/services/audiopolicy/common/include/Volume.h
+++ b/services/audiopolicy/common/include/Volume.h
@@ -33,11 +33,6 @@
enum VolumeSource : std::underlying_type<volume_group_t>::type;
static const VolumeSource VOLUME_SOURCE_NONE = static_cast<VolumeSource>(VOLUME_GROUP_NONE);
-static inline VolumeSource streamToVolumeSource(audio_stream_type_t stream) {
- return static_cast<VolumeSource>(stream);
-}
-
-
} // namespace android
// Absolute min volume in dB (can be represented in single precision normal float value)
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
index 97b7a01..8a60cf2 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
@@ -137,9 +137,6 @@
sysTime = systemTime();
}
for (const auto &iter : mVolumeActivities) {
- if (iter.first == streamToVolumeSource(AUDIO_STREAM_PATCH)) {
- continue;
- }
if (iter.second.isActive(inPastMs, sysTime)) {
return true;
}
diff --git a/services/audiopolicy/engineconfigurable/src/Engine.cpp b/services/audiopolicy/engineconfigurable/src/Engine.cpp
index e59d983..cb45fcf 100644
--- a/services/audiopolicy/engineconfigurable/src/Engine.cpp
+++ b/services/audiopolicy/engineconfigurable/src/Engine.cpp
@@ -224,16 +224,16 @@
audio_devices_t devices = AUDIO_DEVICE_NONE;
if (ps == getProductStrategyForStream(AUDIO_STREAM_NOTIFICATION) &&
!is_state_in_call(getPhoneState()) &&
- !outputs.isActiveRemotely(streamToVolumeSource(AUDIO_STREAM_MUSIC),
+ !outputs.isActiveRemotely(toVolumeSource(AUDIO_STREAM_MUSIC),
SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY) &&
- outputs.isActive(streamToVolumeSource(AUDIO_STREAM_MUSIC),
+ outputs.isActive(toVolumeSource(AUDIO_STREAM_MUSIC),
SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY)) {
product_strategy_t strategyForMedia =
getProductStrategyForStream(AUDIO_STREAM_MUSIC);
devices = productStrategies.getDeviceTypesForProductStrategy(strategyForMedia);
} else if (ps == getProductStrategyForStream(AUDIO_STREAM_ACCESSIBILITY) &&
- (outputs.isActive(streamToVolumeSource(AUDIO_STREAM_RING)) ||
- outputs.isActive(streamToVolumeSource(AUDIO_STREAM_ALARM)))) {
+ (outputs.isActive(toVolumeSource(AUDIO_STREAM_RING)) ||
+ outputs.isActive(toVolumeSource(AUDIO_STREAM_ALARM)))) {
// do not route accessibility prompts to a digital output currently configured with a
// compressed format as they would likely not be mixed and dropped.
// Device For Sonification conf file has HDMI, SPDIF and HDMI ARC unreacheable.
diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
index 592a0b9..4135f01 100644
--- a/services/audiopolicy/enginedefault/src/Engine.cpp
+++ b/services/audiopolicy/enginedefault/src/Engine.cpp
@@ -153,16 +153,16 @@
break;
case STRATEGY_SONIFICATION_RESPECTFUL:
- if (isInCall() || outputs.isActiveLocally(streamToVolumeSource(AUDIO_STREAM_VOICE_CALL))) {
+ if (isInCall() || outputs.isActiveLocally(toVolumeSource(AUDIO_STREAM_VOICE_CALL))) {
device = getDeviceForStrategyInt(
STRATEGY_SONIFICATION, availableOutputDevices, availableInputDevices, outputs,
outputDeviceTypesToIgnore);
} else {
bool media_active_locally =
- outputs.isActiveLocally(streamToVolumeSource(AUDIO_STREAM_MUSIC),
+ outputs.isActiveLocally(toVolumeSource(AUDIO_STREAM_MUSIC),
SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY)
|| outputs.isActiveLocally(
- streamToVolumeSource(AUDIO_STREAM_ACCESSIBILITY),
+ toVolumeSource(AUDIO_STREAM_ACCESSIBILITY),
SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY);
// routing is same as media without the "remote" device
device = getDeviceForStrategyInt(STRATEGY_MEDIA,
@@ -297,7 +297,7 @@
// If incall, just select the STRATEGY_PHONE device
if (isInCall() ||
- outputs.isActiveLocally(streamToVolumeSource(AUDIO_STREAM_VOICE_CALL))) {
+ outputs.isActiveLocally(toVolumeSource(AUDIO_STREAM_VOICE_CALL))) {
device = getDeviceForStrategyInt(
STRATEGY_PHONE, availableOutputDevices, availableInputDevices, outputs,
outputDeviceTypesToIgnore);
@@ -370,8 +370,8 @@
}
availableOutputDevices =
availableOutputDevices.getDevicesFromTypeMask(availableOutputDevicesType);
- if (outputs.isActive(streamToVolumeSource(AUDIO_STREAM_RING)) ||
- outputs.isActive(streamToVolumeSource(AUDIO_STREAM_ALARM))) {
+ if (outputs.isActive(toVolumeSource(AUDIO_STREAM_RING)) ||
+ outputs.isActive(toVolumeSource(AUDIO_STREAM_ALARM))) {
return getDeviceForStrategyInt(
STRATEGY_SONIFICATION, availableOutputDevices, availableInputDevices, outputs,
outputDeviceTypesToIgnore);
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index b9cd7d0..6bd12c9 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -1596,7 +1596,7 @@
if (stream == AUDIO_STREAM_TTS) {
ALOGV("\t found BEACON stream");
if (!mTtsOutputAvailable && mOutputs.isAnyOutputActive(
- streamToVolumeSource(AUDIO_STREAM_TTS) /*sourceToIgnore*/)) {
+ toVolumeSource(AUDIO_STREAM_TTS) /*sourceToIgnore*/)) {
return INVALID_OPERATION;
} else {
beaconMuteLatency = handleEventForBeacon(STARTING_BEACON);
@@ -2634,7 +2634,7 @@
for (audio_io_handle_t output : outputs) {
sp<SwAudioOutputDescriptor> desc = mOutputs.valueFor(output);
- if (activeOnly && !desc->isActive(streamToVolumeSource(AUDIO_STREAM_MUSIC))) {
+ if (activeOnly && !desc->isActive(toVolumeSource(AUDIO_STREAM_MUSIC))) {
continue;
}
ALOGV("selectOutputForMusicEffects activeOnly %d output %d flags 0x%08x",
@@ -5242,7 +5242,7 @@
devices.merge(curDevices);
for (audio_io_handle_t output : getOutputsForDevices(curDevices, mOutputs)) {
sp<AudioOutputDescriptor> outputDesc = mOutputs.valueFor(output);
- if (outputDesc->isActive(streamToVolumeSource((audio_stream_type_t)curStream))) {
+ if (outputDesc->isActive(toVolumeSource(curStream))) {
activeDevices.merge(outputDesc->devices());
}
}