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

Commit f6e27133 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes I7e5aa57e,Iefcc3db8,I1493ccdd into main am: ed9b9d4b

parents 80ebc028 ed9b9d4b
Loading
Loading
Loading
Loading
+39 −24
Original line number Diff line number Diff line
@@ -374,6 +374,7 @@ status_t AudioPolicyManager::setDeviceConnectionStateInt(const sp<DeviceDescript
        checkLeBroadcastRoutes(wasLeUnicastActive, nullptr, 0);

        mpClientInterface->onAudioPortListUpdate();
        ALOGV("%s() completed for device: %s", __func__, device->toString().c_str());
        return NO_ERROR;
    }  // end if is output device

@@ -389,6 +390,8 @@ status_t AudioPolicyManager::setDeviceConnectionStateInt(const sp<DeviceDescript
                return INVALID_OPERATION;
            }

            ALOGV("%s() connecting device %s", __func__, device->toString().c_str());

            if (mAvailableInputDevices.add(device) < 0) {
                return NO_MEMORY;
            }
@@ -461,6 +464,7 @@ status_t AudioPolicyManager::setDeviceConnectionStateInt(const sp<DeviceDescript
        }

        mpClientInterface->onAudioPortListUpdate();
        ALOGV("%s() completed for device: %s", __func__, device->toString().c_str());
        return NO_ERROR;
    } // end if is input device

@@ -1549,7 +1553,7 @@ status_t AudioPolicyManager::openDirectOutput(audio_stream_type_t stream,
                (config->channel_mask == desc->getChannelMask()) &&
                (session == desc->mDirectClientSession)) {
                desc->mDirectOpenCount++;
                ALOGV("%s reusing direct output %d for session %d", __func__,
                ALOGI("%s reusing direct output %d for session %d", __func__,
                    mOutputs.keyAt(i), session);
                *output = mOutputs.keyAt(i);
                return NO_ERROR;
@@ -1559,17 +1563,23 @@ status_t AudioPolicyManager::openDirectOutput(audio_stream_type_t stream,

    if (!profile->canOpenNewIo()) {
        if (!com::android::media::audioserver::direct_track_reprioritization()) {
            ALOGW("%s profile %s can't open new output maxOpenCount reached", __func__,
                  profile->getName().c_str());
            return NAME_NOT_FOUND;
        } else if ((profile->getFlags() & AUDIO_OUTPUT_FLAG_MMAP_NOIRQ) != 0) {
            // MMAP gracefully handles lack of an exclusive track resource by mixing
            // above the audio framework. For AAudio to know that the limit is reached,
            // return an error.
            ALOGW("%s profile %s can't open new mmap output maxOpenCount reached", __func__,
                  profile->getName().c_str());
            return NAME_NOT_FOUND;
        } else {
            // Close outputs on this profile, if available, to free resources for this request
            for (int i = 0; i < mOutputs.size() && !profile->canOpenNewIo(); i++) {
                const auto desc = mOutputs.valueAt(i);
                if (desc->mProfile == profile) {
                    ALOGV("%s closeOutput %d to prioritize session %d on profile %s", __func__,
                          desc->mIoHandle, session, profile->getName().c_str());
                    closeOutput(desc->mIoHandle);
                }
            }
@@ -1578,6 +1588,8 @@ status_t AudioPolicyManager::openDirectOutput(audio_stream_type_t stream,

    // Unable to close streams to find free resources for this request
    if (!profile->canOpenNewIo()) {
        ALOGW("%s profile %s can't open new output maxOpenCount reached", __func__,
              profile->getName().c_str());
        return NAME_NOT_FOUND;
    }

@@ -3424,8 +3436,8 @@ status_t AudioPolicyManager::setStreamVolumeIndex(audio_stream_type_t stream,
        ALOGW("%s: no group for stream %s, bailing out", __func__, toString(stream).c_str());
        return NO_ERROR;
    }
    ALOGV("%s: stream %s attributes=%s", __func__,
          toString(stream).c_str(), toString(attributes).c_str());
    ALOGV("%s: stream %s attributes=%s, index %d , device 0x%X", __func__,
          toString(stream).c_str(), toString(attributes).c_str(), index, device);
    return setVolumeIndexForAttributes(attributes, index, device);
}

@@ -3603,8 +3615,8 @@ status_t AudioPolicyManager::setVolumeCurveIndex(int index,
    bool hasVoice = hasVoiceStream(volumeCurves.getStreamTypes());
    if (((index < volumeCurves.getVolumeIndexMin()) && !(hasVoice && index == 0)) ||
            (index > volumeCurves.getVolumeIndexMax())) {
        ALOGD("%s: wrong index %d min=%d max=%d", __FUNCTION__, index,
              volumeCurves.getVolumeIndexMin(), volumeCurves.getVolumeIndexMax());
        ALOGE("%s: wrong index %d min=%d max=%d, device 0x%X", __FUNCTION__, index,
              volumeCurves.getVolumeIndexMin(), volumeCurves.getVolumeIndexMax(), device);
        return BAD_VALUE;
    }
    if (!audio_is_output_device(device)) {
@@ -6649,9 +6661,9 @@ void AudioPolicyManager::onNewAudioModulesAvailableInt(DeviceVector *newDevices)
                                              (audio_input_flags_t) inProfile->getFlags(),
                                              &input);
            if (status != NO_ERROR) {
                ALOGW("Cannot open input stream for device %s on hw module %s",
                      availProfileDevices.toString().c_str(),
                      hwModule->getName());
                ALOGW("%s: Cannot open input stream for device %s for profile %s on hw module %s",
                        __func__, availProfileDevices.toString().c_str(),
                        inProfile->getTagName().c_str(), hwModule->getName());
                continue;
            }
            for (const auto &device : availProfileDevices) {
@@ -6759,8 +6771,8 @@ status_t AudioPolicyManager::checkOutputsForDevice(const sp<DeviceDescriptor>& d
                sp<IOProfile> profile = hwModule->getOutputProfiles()[j];
                if (profile->supportsDevice(device)) {
                    profiles.add(profile);
                    ALOGV("checkOutputsForDevice(): adding profile %zu from module %s",
                          j, hwModule->getName());
                    ALOGV("%s(): adding profile %s from module %s",
                            __func__, profile->getTagName().c_str(), hwModule->getName());
                }
            }
        }
@@ -6858,9 +6870,8 @@ status_t AudioPolicyManager::checkOutputsForDevice(const sp<DeviceDescriptor>& d
                if (!profile->supportsDevice(device)) {
                    continue;
                }
                ALOGV("checkOutputsForDevice(): "
                        "clearing direct output profile %zu on module %s",
                        j, hwModule->getName());
                ALOGV("%s(): clearing direct output profile %s on module %s",
                        __func__, profile->getTagName().c_str(), hwModule->getName());
                profile->clearAudioProfiles();
                if (!profile->hasDynamicAudioProfile()) {
                    continue;
@@ -6915,8 +6926,8 @@ status_t AudioPolicyManager::checkInputsForDevice(const sp<DeviceDescriptor>& de

                if (profile->supportsDevice(device)) {
                    profiles.add(profile);
                    ALOGV("checkInputsForDevice(): adding profile %zu from module %s",
                          profile_index, hwModule->getName());
                    ALOGV("%s : adding profile %s from module %s", __func__,
                          profile->getTagName().c_str(), hwModule->getName());
                }
            }
        }
@@ -6954,13 +6965,14 @@ status_t AudioPolicyManager::checkInputsForDevice(const sp<DeviceDescriptor>& de
                continue;
            }
            if (!profile->canOpenNewIo()) {
                ALOGW("Max Input number %u already opened for this profile %s",
                      profile->maxOpenCount, profile->getTagName().c_str());
                ALOGW("%s Max Input number %u already opened for this profile %s",
                      __func__, profile->maxOpenCount, profile->getTagName().c_str());
                continue;
            }

            desc = new AudioInputDescriptor(profile, mpClientInterface);
            audio_io_handle_t input = AUDIO_IO_HANDLE_NONE;
            ALOGV("%s opening input for profile %s", __func__, profile->getTagName().c_str());
            status = desc->open(nullptr, device, AUDIO_SOURCE_MIC,
                                (audio_input_flags_t) profile->getFlags(), &input);

@@ -6973,7 +6985,8 @@ status_t AudioPolicyManager::checkInputsForDevice(const sp<DeviceDescriptor>& de
                }
                updateAudioProfiles(device, input, profile);
                if (!profile->hasValidAudioProfile()) {
                    ALOGW("checkInputsForDevice() direct input missing param");
                    ALOGW("%s direct input missing param for profile %s", __func__,
                            profile->getTagName().c_str());
                    desc->close();
                    input = AUDIO_IO_HANDLE_NONE;
                }
@@ -6984,18 +6997,20 @@ status_t AudioPolicyManager::checkInputsForDevice(const sp<DeviceDescriptor>& de
            } // endif input != 0

            if (input == AUDIO_IO_HANDLE_NONE) {
                ALOGW("%s could not open input for device %s", __func__,
                       device->toString().c_str());
                ALOGW("%s could not open input for device %s on profile %s", __func__,
                       device->toString().c_str(), profile->getTagName().c_str());
                profiles.removeAt(profile_index);
                profile_index--;
            } else {
                if (audio_device_is_digital(device->type())) {
                    device->importAudioPortAndPickAudioProfile(profile);
                }
                ALOGV("checkInputsForDevice(): adding input %d", input);
                ALOGV("%s: adding input %d for profile %s", __func__,
                        input, profile->getTagName().c_str());

                if (checkCloseInput(desc)) {
                    ALOGV("%s closing input %d", __func__, input);
                    ALOGV("%s: closing input %d for profile %s", __func__,
                            input, profile->getTagName().c_str());
                    closeInput(input);
                }
            }
@@ -7014,8 +7029,8 @@ status_t AudioPolicyManager::checkInputsForDevice(const sp<DeviceDescriptor>& de
                 profile_index++) {
                sp<IOProfile> profile = hwModule->getInputProfiles()[profile_index];
                if (profile->supportsDevice(device)) {
                    ALOGV("checkInputsForDevice(): clearing direct input profile %zu on module %s",
                            profile_index, hwModule->getName());
                    ALOGV("%s: clearing direct input profile %s on module %s", __func__,
                            profile->getTagName().c_str(), hwModule->getName());
                    profile->clearAudioProfiles();
                }
            }