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

Commit 700993d0 authored by Andy Hung's avatar Andy Hung Committed by Automerger Merge Worker
Browse files

Merge "Spatializer: Respect FCC_LIMIT for input masks" am: 94af1643

parents 44f835d0 94af1643
Loading
Loading
Loading
Loading
+9 −4
Original line number Original line Diff line number Diff line
@@ -59,11 +59,13 @@ using namespace std::chrono_literals;
       if (!_tmp.ok()) return aidl_utils::binderStatusFromStatusT(_tmp.error()); \
       if (!_tmp.ok()) return aidl_utils::binderStatusFromStatusT(_tmp.error()); \
       std::move(_tmp.value()); })
       std::move(_tmp.value()); })


audio_channel_mask_t getMaxChannelMask(std::vector<audio_channel_mask_t> masks) {
static audio_channel_mask_t getMaxChannelMask(
        const std::vector<audio_channel_mask_t>& masks, size_t channelLimit = SIZE_MAX) {
    uint32_t maxCount = 0;
    uint32_t maxCount = 0;
    audio_channel_mask_t maxMask = AUDIO_CHANNEL_NONE;
    audio_channel_mask_t maxMask = AUDIO_CHANNEL_NONE;
    for (auto mask : masks) {
    for (auto mask : masks) {
        const size_t count = audio_channel_count_from_out_mask(mask);
        const size_t count = audio_channel_count_from_out_mask(mask);
        if (count > channelLimit) continue;  // ignore masks greater than channelLimit
        if (count > maxCount) {
        if (count > maxCount) {
            maxMask = mask;
            maxMask = mask;
            maxCount = count;
            maxCount = count;
@@ -238,10 +240,13 @@ sp<Spatializer> Spatializer::create(SpatializerPolicyCallback *callback) {
        spatializer = new Spatializer(descriptors[0], callback);
        spatializer = new Spatializer(descriptors[0], callback);
        if (spatializer->loadEngineConfiguration(effect) != NO_ERROR) {
        if (spatializer->loadEngineConfiguration(effect) != NO_ERROR) {
            spatializer.clear();
            spatializer.clear();
        }
            ALOGW("%s loadEngine error: %d  effect Id %" PRId64,
                    __func__, status, effect ? effect->effectId() : 0);
        } else {
            spatializer->mLocalLog.log("%s with effect Id %" PRId64, __func__,
            spatializer->mLocalLog.log("%s with effect Id %" PRId64, __func__,
                                       effect ? effect->effectId() : 0);
                                       effect ? effect->effectId() : 0);
        }
        }
    }


    return spatializer;
    return spatializer;
}
}
@@ -377,7 +382,7 @@ audio_config_base_t Spatializer::getAudioInConfig() const {
    std::lock_guard lock(mLock);
    std::lock_guard lock(mLock);
    audio_config_base_t config = AUDIO_CONFIG_BASE_INITIALIZER;
    audio_config_base_t config = AUDIO_CONFIG_BASE_INITIALIZER;
    // For now use highest supported channel count
    // For now use highest supported channel count
    config.channel_mask = getMaxChannelMask(mChannelMasks);
    config.channel_mask = getMaxChannelMask(mChannelMasks, FCC_LIMIT);
    return config;
    return config;
}
}