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

Commit 1ed7bc80 authored by Phil Burk's avatar Phil Burk Committed by Android (Google) Code Review
Browse files

Merge "aaudio: do not use RAW flag for notifications, alarms" into main

parents 4c7c4065 8ae85a7c
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -69,16 +69,24 @@ aaudio_result_t AudioStreamTrack::open(const AudioStreamBuilder& builder)
    audio_channel_mask_t channelMask =
            AAudio_getChannelMaskForOpen(getChannelMask(), getSamplesPerFrame(), false /*isInput*/);

    // Set flags based on selected parameters.
    audio_output_flags_t flags;
    aaudio_performance_mode_t perfMode = getPerformanceMode();
    switch(perfMode) {
        case AAUDIO_PERFORMANCE_MODE_LOW_LATENCY:
        case AAUDIO_PERFORMANCE_MODE_LOW_LATENCY: {
            // Bypass the normal mixer and go straight to the FAST mixer.
            // If the app asks for a sessionId then it means they want to use effects.
            // So don't use RAW flag.
            flags = (audio_output_flags_t) ((requestedSessionId == AAUDIO_SESSION_ID_NONE)
            // Some Usages need RAW mode so they can get the lowest possible latency.
            // Other Usages should avoid RAW because it can interfere with
            // dual sink routing or other features.
            bool usageBenefitsFromRaw = getUsage() == AAUDIO_USAGE_GAME ||
                    getUsage() == AAUDIO_USAGE_MEDIA;
            // If an app does not ask for a sessionId then there will be no effects.
            // So we can use the use RAW flag.
            flags = (audio_output_flags_t) (((requestedSessionId == AAUDIO_SESSION_ID_NONE)
                                             && usageBenefitsFromRaw)
                                            ? (AUDIO_OUTPUT_FLAG_FAST | AUDIO_OUTPUT_FLAG_RAW)
                                            : (AUDIO_OUTPUT_FLAG_FAST));
        }
            break;

        case AAUDIO_PERFORMANCE_MODE_POWER_SAVING: