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

Commit bd2dcc4d authored by cnx421's avatar cnx421 Committed by 恶魔 地狱
Browse files

Fix music output to speaker

This CL fixes a bug in audio policy where music switches to speaker when A2DP output mode switches from software encoder to offloaded encoder.

Bug: 153895044

Change-Id: I15f707c9e96294b6cd6f21c0821c795d0570c39a
parent 7c44826e
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -460,7 +460,16 @@ status_t AudioPolicyManager::handleDeviceConfigChange(audio_devices_t device,
            }
        }
    }

    auto musicStrategy = streamToStrategy(AUDIO_STREAM_MUSIC);
    for (size_t i = 0; i < mOutputs.size(); i++) {
       sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
       // mute media strategies and delay device switch by the largest
       // This avoid sending the music tail into the earpiece or headset.
       setStrategyMute(musicStrategy, true, desc);
       setStrategyMute(musicStrategy, false, desc, MUTE_TIME_MS,
          mEngine->getOutputDevicesForAttributes(attributes_initializer(AUDIO_USAGE_MEDIA),
                                              nullptr, true /*fromCache*/).types());
    }
    // Toggle the device state: UNAVAILABLE -> AVAILABLE
    // This will force reading again the device configuration
    status = setDeviceConnectionState(device,