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

Commit 6a3d2565 authored by Eric Laurent's avatar Eric Laurent
Browse files

audioservice: fix hasMediaDynamicPolicy() for loopback and render policies

Exclude mixes with LOOPBACK + RENDER flags when looking for dynamic
policies matching media usage. As this is only used in the context
of sending becoming noisy intent we want to send the intent when playback
capture is active.

Bug: 137055231
Test: enable live caption and disconnect headset while music is playing
Change-Id: Ib3cd38f58c2ff78a2f2f13c5c22b637f9701e345
parent 22110bae
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -5577,6 +5577,7 @@ public class AudioService extends IAudioService.Stub

    /**
     * @return true if there is currently a registered dynamic mixing policy that affects media
     * and is not a render + loopback policy
     */
    /*package*/ boolean hasMediaDynamicPolicy() {
        synchronized (mAudioPolicies) {
@@ -5585,7 +5586,8 @@ public class AudioService extends IAudioService.Stub
            }
            final Collection<AudioPolicyProxy> appColl = mAudioPolicies.values();
            for (AudioPolicyProxy app : appColl) {
                if (app.hasMixAffectingUsage(AudioAttributes.USAGE_MEDIA)) {
                if (app.hasMixAffectingUsage(AudioAttributes.USAGE_MEDIA,
                        AudioMix.ROUTE_FLAG_LOOP_BACK_RENDER)) {
                    return true;
                }
            }
@@ -7348,9 +7350,10 @@ public class AudioService extends IAudioService.Stub
            Binder.restoreCallingIdentity(identity);
        }

        boolean hasMixAffectingUsage(int usage) {
        boolean hasMixAffectingUsage(int usage, int excludedFlags) {
            for (AudioMix mix : mMixes) {
                if (mix.isAffectingUsage(usage)) {
                if (mix.isAffectingUsage(usage)
                        && ((mix.getRouteFlags() & excludedFlags) != excludedFlags)) {
                    return true;
                }
            }