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

Commit f9230d53 authored by Eric Laurent's avatar Eric Laurent
Browse files

audio policy: restrict spatialization criteria for stereo

Do not spatialize stereo audio if offload or direct mode
is explicitly requested or low latency performance is requested.

Bug: 303920722
Test: manual test with OboeTester
Change-Id: If1c008789dfa5a81416bf4be5d485021bd412dbf
parent 3634b6e6
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 =