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

Commit 63938cea authored by Naresh Tanniru's avatar Naresh Tanniru Committed by Linux Build Service Account
Browse files

audiopolicy: Check if A2DP playback happens via primary output

Audio policy implementation assumes A2DP playback to happen
via HW module other than the primary HAL.This need not be true
always, since primary audio HAL can support A2DP playback too.

Add an api to check if A2DP playback is supported via primary HAL,
and if it is supported avoid suspendOutput.

Change-Id: I13bf8137ab64e257d84791dd77ee746dec39dec4
parent d546de6a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -176,6 +176,11 @@ public:
     */
    audio_io_handle_t getA2dpOutput() const;

    /**
     * return true if primary HAL supports A2DP Playback
     */
    bool isA2dpOnPrimary() const;

    sp<SwAudioOutputDescriptor> getOutputFromId(audio_port_handle_t id) const;

    sp<SwAudioOutputDescriptor> getPrimaryOutput() const;
+17 −0
Original line number Diff line number Diff line
@@ -485,6 +485,23 @@ audio_io_handle_t SwAudioOutputCollection::getA2dpOutput() const
    return 0;
}

bool SwAudioOutputCollection::isA2dpOnPrimary() const
{
    sp<SwAudioOutputDescriptor> primaryOutput = getPrimaryOutput();

    if ((primaryOutput != NULL) && (primaryOutput->mProfile != NULL)
        && (primaryOutput->mProfile->mModule != NULL)) {
        Vector <sp<IOProfile>> primaryOutputProfiles =
                               primaryOutput->mProfile->mModule->mOutputProfiles;
        for (size_t j = 0; j < primaryOutputProfiles.size(); j++) {
            if (primaryOutputProfiles[j]->supportDevice(AUDIO_DEVICE_OUT_ALL_A2DP)) {
                return true;
            }
        }
    }
    return false;
}

sp<SwAudioOutputDescriptor> SwAudioOutputCollection::getPrimaryOutput() const
{
    for (size_t i = 0; i < size(); i++) {
+3 −3
Original line number Diff line number Diff line
@@ -344,7 +344,7 @@ audio_devices_t Engine::getDeviceForStrategyInt(routing_strategy strategy,
            // when not in a phone call, phone strategy should route STREAM_VOICE_CALL to A2DP
            if (!isInCall() &&
                    (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA] != AUDIO_POLICY_FORCE_NO_BT_A2DP) &&
                    (outputs.getA2dpOutput() != 0)) {
                    (outputs.isA2dpOnPrimary() || (outputs.getA2dpOutput() != 0))) {
                device = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP;
                if (device) break;
                device = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES;
@@ -376,7 +376,7 @@ audio_devices_t Engine::getDeviceForStrategyInt(routing_strategy strategy,
            // A2DP speaker when forcing to speaker output
            if (!isInCall() &&
                    (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA] != AUDIO_POLICY_FORCE_NO_BT_A2DP) &&
                    (outputs.getA2dpOutput() != 0)) {
                    (outputs.isA2dpOnPrimary() || (outputs.getA2dpOutput() != 0))) {
                device = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER;
                if (device) break;
            }
@@ -474,7 +474,7 @@ audio_devices_t Engine::getDeviceForStrategyInt(routing_strategy strategy,
        }
        if ((device2 == AUDIO_DEVICE_NONE) &&
                (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA] != AUDIO_POLICY_FORCE_NO_BT_A2DP) &&
                (outputs.getA2dpOutput() != 0)) {
                (outputs.isA2dpOnPrimary() || (outputs.getA2dpOutput() != 0))) {
            device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP;
            if (device2 == AUDIO_DEVICE_NONE) {
                device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES;
+1 −1
Original line number Diff line number Diff line
@@ -4231,7 +4231,7 @@ void AudioPolicyManager::checkOutputForAllStrategies()
void AudioPolicyManager::checkA2dpSuspend()
{
    audio_io_handle_t a2dpOutput = mOutputs.getA2dpOutput();
    if (a2dpOutput == 0) {
    if (a2dpOutput == 0 || mOutputs.isA2dpOnPrimary()) {
        mA2dpSuspended = false;
        return;
    }