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

Commit 8ae85a7c authored by Phil Burk's avatar Phil Burk
Browse files

aaudio: do not use RAW flag for notifications, alarms

The RAW flag was preventing the RINGTONE, NOTIFICATION, ALARM
and other usages from using dual sinks in the low-latency, Legacy path.

Now, the RAW flag will only be used for USAGEs that require
the lowest possible latency, ie. MEDIA and GAME.

Bug: 315834972
Test: see repro steps at b/315834972#comment12
Change-Id: Ie253bbe11e965c358b0fbc35641183b145b8a0fc
parent 2d39b9e3
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: