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

Commit 80ebc028 authored by Jaideep Sharma's avatar Jaideep Sharma Committed by Automerger Merge Worker
Browse files

audiopolicy: skip opening mmap profile during new device connection am: 44824a24

parents 9a9c052c 44824a24
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -282,6 +282,11 @@ public:

    const AudioProfileVector& getSupportedProfiles() { return mSupportedProfiles; }

    /**
     * @brief checks if all devices in device vector are attached to the HwModule or not
     * @return true if all the devices in device vector are attached, otherwise false
     */
    bool areAllDevicesAttached() const;
    // Return a string to describe the DeviceVector. The sensitive information will only be
    // added to the string if `includeSensitiveInfo` is true.
    std::string toString(bool includeSensitiveInfo = false) const;
+10 −0
Original line number Diff line number Diff line
@@ -541,4 +541,14 @@ DeviceVector DeviceVector::filterForEngine() const
    return filteredDevices;
}

bool DeviceVector::areAllDevicesAttached() const
{
    for (const auto &device : *this) {
        if (!device->isAttached()) {
            return false;
        }
    }
    return true;
}

} // namespace android
+26 −1
Original line number Diff line number Diff line
@@ -6564,6 +6564,14 @@ void AudioPolicyManager::onNewAudioModulesAvailableInt(DeviceVector *newDevices)
            if (!mConfig->getOutputDevices().contains(supportedDevice)) {
                continue;
            }

            if (outProfile->isMmap() && !outProfile->hasDynamicAudioProfile()
                && availProfileDevices.areAllDevicesAttached()) {
                ALOGV("%s skip opening output for mmap profile %s", __func__,
                        outProfile->getTagName().c_str());
                continue;
            }

            sp<SwAudioOutputDescriptor> outputDesc = new SwAudioOutputDescriptor(outProfile,
                                                                                 mpClientInterface);
            audio_io_handle_t output = AUDIO_IO_HANDLE_NONE;
@@ -6623,6 +6631,14 @@ void AudioPolicyManager::onNewAudioModulesAvailableInt(DeviceVector *newDevices)
                    __func__, inProfile->getTagName().c_str());
                continue;
            }

            if (inProfile->isMmap() && !inProfile->hasDynamicAudioProfile()
                && availProfileDevices.areAllDevicesAttached()) {
                ALOGV("%s skip opening input for mmap profile %s", __func__,
                        inProfile->getTagName().c_str());
                continue;
            }

            sp<AudioInputDescriptor> inputDesc =
                    new AudioInputDescriptor(inProfile, mpClientInterface);

@@ -6777,7 +6793,11 @@ status_t AudioPolicyManager::checkOutputsForDevice(const sp<DeviceDescriptor>& d
            if (j != outputs.size()) {
                continue;
            }

            if (profile->isMmap() && !profile->hasDynamicAudioProfile()) {
                ALOGV("%s skip opening output for mmap profile %s",
                      __func__, profile->getTagName().c_str());
                continue;
            }
            if (!profile->canOpenNewIo()) {
                ALOGW("Max Output number %u already opened for this profile %s",
                      profile->maxOpenCount, profile->getTagName().c_str());
@@ -6928,6 +6948,11 @@ status_t AudioPolicyManager::checkInputsForDevice(const sp<DeviceDescriptor>& de
                continue;
            }

            if (profile->isMmap() && !profile->hasDynamicAudioProfile()) {
                ALOGV("%s skip opening input for mmap profile %s",
                      __func__, profile->getTagName().c_str());
                continue;
            }
            if (!profile->canOpenNewIo()) {
                ALOGW("Max Input number %u already opened for this profile %s",
                      profile->maxOpenCount, profile->getTagName().c_str());