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

Commit d8622371 authored by Eric Laurent's avatar Eric Laurent Committed by Jean-Michel Trivi
Browse files

audiopolicy: fix output audio format selection

Fix two problems in output stream audio format selection
added by commit 1e693b55:
- flags must be set before picking the format.
- fix logic error in best format selection.

Change-Id: I6458b32725f771da5a08108932d64e71964ae9f1
parent 0fb47759
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4627,13 +4627,13 @@ AudioPolicyManager::AudioOutputDescriptor::AudioOutputDescriptor(
    }
    if (profile != NULL) {
        mAudioPort = profile;
        mFlags = profile->mFlags;
        mSamplingRate = profile->pickSamplingRate();
        mFormat = profile->pickFormat();
        mChannelMask = profile->pickChannelMask();
        if (profile->mGains.size() > 0) {
            profile->mGains[0]->getDefaultConfig(&mGain);
        }
        mFlags = profile->mFlags;
    }
}

@@ -5470,7 +5470,7 @@ audio_format_t AudioPolicyManager::AudioPort::pickFormat() const
    // limit format otherwise
    if ((mType != AUDIO_PORT_TYPE_MIX) ||
            ((mRole == AUDIO_PORT_ROLE_SOURCE) &&
             (((mFlags & (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) == 0)))) {
             (((mFlags & (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) != 0)))) {
        bestFormat = AUDIO_FORMAT_INVALID;
    }