Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 67336139 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "audio policy: fix stream to volume source mapping"

parents 0f56f0a9 83d17c20
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -33,11 +33,6 @@ namespace android {
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)
+0 −3
Original line number Diff line number Diff line
@@ -137,9 +137,6 @@ bool AudioOutputDescriptor::isActive(uint32_t inPastMs) const
        sysTime = systemTime();
    }
    for (const auto &iter : mVolumeActivities) {
        if (iter.first == streamToVolumeSource(AUDIO_STREAM_PATCH)) {
            continue;
        }
        if (iter.second.isActive(inPastMs, sysTime)) {
            return true;
        }
+4 −4
Original line number Diff line number Diff line
@@ -224,16 +224,16 @@ DeviceVector Engine::getDevicesForProductStrategy(product_strategy_t ps) const
    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.
+6 −6
Original line number Diff line number Diff line
@@ -153,16 +153,16 @@ audio_devices_t Engine::getDeviceForStrategyInt(legacy_strategy strategy,
        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 @@ audio_devices_t Engine::getDeviceForStrategyInt(legacy_strategy strategy,

        // 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 @@ audio_devices_t Engine::getDeviceForStrategyInt(legacy_strategy strategy,
            }
            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);
+3 −3
Original line number Diff line number Diff line
@@ -1596,7 +1596,7 @@ status_t AudioPolicyManager::startSource(const sp<SwAudioOutputDescriptor>& outp
    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 @@ audio_io_handle_t AudioPolicyManager::selectOutputForMusicEffects()

        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 @@ audio_devices_t AudioPolicyManager::getDevicesForStream(audio_stream_type_t stre
        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());
            }
        }