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

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

Merge "audio policy: restrict spatialization criteria for stereo" into main

parents 600685a1 f9230d53
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -1632,10 +1632,13 @@ audio_io_handle_t AudioPolicyManager::getOutputForDevices(
        *flags = (audio_output_flags_t)(*flags | AUDIO_OUTPUT_FLAG_ULTRASOUND);
    }

    // Use the spatializer output if the content can be spatialized, no preferred mixer
    // was specified and offload or direct playback is not explicitly requested.
    *isSpatialized = false;
    if (mSpatializerOutput != nullptr
            && canBeSpatializedInt(attr, config, devices.toTypeAddrVector())
            && prefMixerConfigInfo == nullptr) {
            && prefMixerConfigInfo == nullptr
            && ((*flags & (AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD | AUDIO_OUTPUT_FLAG_DIRECT)) == 0)) {
        *isSpatialized = true;
        return mSpatializerOutput->mIoHandle;
    }
@@ -6001,7 +6004,8 @@ bool AudioPolicyManager::canBeSpatializedInt(const audio_attributes_t *attr,
    // The caller can have the audio config criteria ignored by either passing a null ptr or
    // the AUDIO_CONFIG_INITIALIZER value.
    // If an audio config is specified, current policy is to only allow spatialization for
    // some positional channel masks and PCM format
    // some positional channel masks and PCM format and for stereo if low latency performance
    // mode is not requested.

    if (config != nullptr && *config != AUDIO_CONFIG_INITIALIZER) {
        const bool channel_mask_spatialized =
@@ -6014,6 +6018,10 @@ bool AudioPolicyManager::canBeSpatializedInt(const audio_attributes_t *attr,
        if (!audio_is_linear_pcm(config->format)) {
            return false;
        }
        if (config->channel_mask == AUDIO_CHANNEL_OUT_STEREO
                && ((attr->flags & AUDIO_FLAG_LOW_LATENCY) != 0)) {
            return false;
        }
    }

    sp<IOProfile> profile =