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

Commit 6f70d97f authored by Robert Wu's avatar Robert Wu Committed by Android (Google) Code Review
Browse files

Merge "APM: Valid sr and ch shouldn't be overriden"

parents 65fde0b4 b98ff1b0
Loading
Loading
Loading
Loading
+18 −8
Original line number Original line Diff line number Diff line
@@ -1325,10 +1325,15 @@ status_t AudioPolicyManager::getOutputForAttrInt(
        AudioProfileVector profiles;
        AudioProfileVector profiles;
        status_t ret = getProfilesForDevices(outputDevices, profiles, *flags, false /*isInput*/);
        status_t ret = getProfilesForDevices(outputDevices, profiles, *flags, false /*isInput*/);
        if (ret == NO_ERROR && !profiles.empty()) {
        if (ret == NO_ERROR && !profiles.empty()) {
            config->channel_mask = profiles[0]->getChannels().empty() ? config->channel_mask
            const auto channels = profiles[0]->getChannels();
                    : *profiles[0]->getChannels().begin();
            if (!channels.empty() && (channels.find(config->channel_mask) == channels.end())) {
            config->sample_rate = profiles[0]->getSampleRates().empty() ? config->sample_rate
                config->channel_mask = *channels.begin();
                    : *profiles[0]->getSampleRates().begin();
            }
            const auto sampleRates = profiles[0]->getSampleRates();
            if (!sampleRates.empty() &&
                    (sampleRates.find(config->sample_rate) == sampleRates.end())) {
                config->sample_rate = *sampleRates.begin();
            }
            config->format = profiles[0]->getFormat();
            config->format = profiles[0]->getFormat();
        }
        }
        return INVALID_OPERATION;
        return INVALID_OPERATION;
@@ -2774,10 +2779,15 @@ status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr,
        status_t ret = getProfilesForDevices(
        status_t ret = getProfilesForDevices(
                DeviceVector(device), profiles, flags, true /*isInput*/);
                DeviceVector(device), profiles, flags, true /*isInput*/);
        if (ret == NO_ERROR && !profiles.empty()) {
        if (ret == NO_ERROR && !profiles.empty()) {
            config->channel_mask = profiles[0]->getChannels().empty() ? config->channel_mask
            const auto channels = profiles[0]->getChannels();
                    : *profiles[0]->getChannels().begin();
            if (!channels.empty() && (channels.find(config->channel_mask) == channels.end())) {
            config->sample_rate = profiles[0]->getSampleRates().empty() ? config->sample_rate
                config->channel_mask = *channels.begin();
                    : *profiles[0]->getSampleRates().begin();
            }
            const auto sampleRates = profiles[0]->getSampleRates();
            if (!sampleRates.empty() &&
                    (sampleRates.find(config->sample_rate) == sampleRates.end())) {
                config->sample_rate = *sampleRates.begin();
            }
            config->format = profiles[0]->getFormat();
            config->format = profiles[0]->getFormat();
        }
        }
        goto error;
        goto error;