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

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

Merge "audio policy: favor mixed over direct output for PCM format" into lmp-dev

parents 504de531 b732cf5a
Loading
Loading
Loading
Loading
+11 −1
Original line number Original line Diff line number Diff line
@@ -927,13 +927,21 @@ audio_io_handle_t AudioPolicyManager::getOutputForDevice(
        flags = (audio_output_flags_t)(flags | AUDIO_OUTPUT_FLAG_DIRECT);
        flags = (audio_output_flags_t)(flags | AUDIO_OUTPUT_FLAG_DIRECT);
    }
    }


    sp<IOProfile> profile;

    // skip direct output selection if the request can obviously be attached to a mixed output
    if (audio_is_linear_pcm(format) && samplingRate <= MAX_MIXER_SAMPLING_RATE &&
            audio_channel_count_from_out_mask(channelMask) <= 2) {
        goto non_direct_output;
    }

    // Do not allow offloading if one non offloadable effect is enabled. This prevents from
    // Do not allow offloading if one non offloadable effect is enabled. This prevents from
    // creating an offloaded track and tearing it down immediately after start when audioflinger
    // creating an offloaded track and tearing it down immediately after start when audioflinger
    // detects there is an active non offloadable effect.
    // detects there is an active non offloadable effect.
    // FIXME: We should check the audio session here but we do not have it in this context.
    // FIXME: We should check the audio session here but we do not have it in this context.
    // This may prevent offloading in rare situations where effects are left active by apps
    // This may prevent offloading in rare situations where effects are left active by apps
    // in the background.
    // in the background.
    sp<IOProfile> profile;

    if (((flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) == 0) ||
    if (((flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) == 0) ||
            !isNonOffloadableEffectEnabled()) {
            !isNonOffloadableEffectEnabled()) {
        profile = getProfileForDirectOutput(device,
        profile = getProfileForDirectOutput(device,
@@ -1016,6 +1024,8 @@ audio_io_handle_t AudioPolicyManager::getOutputForDevice(
        return output;
        return output;
    }
    }


non_direct_output:

    // ignoring channel mask due to downmix capability in mixer
    // ignoring channel mask due to downmix capability in mixer


    // open a non direct output
    // open a non direct output