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

Commit b64316da authored by François Gaffie's avatar François Gaffie Committed by Automerger Merge Worker
Browse files

[AudioServer][Strategies] Fix Min/Max index overwritting am: 176dc1fc am:...

[AudioServer][Strategies] Fix Min/Max index overwritting am: 176dc1fc am: 10fc23b9 am: 5cc28e26 am: c51ee20a

Change-Id: I0e795f17b8cd3c12116fbfe5b2fed31d4dd56f41
parents 9d0e7e2d c51ee20a
Loading
Loading
Loading
Loading
+17 −4
Original line number Original line Diff line number Diff line
@@ -85,10 +85,23 @@ static jint convertAudioProductStrategiesFromNative(
    jStrategyId = static_cast<jint>(strategy.getId());
    jStrategyId = static_cast<jint>(strategy.getId());


    // Audio Attributes Group array
    // Audio Attributes Group array
    std::map<int, std::vector<AudioAttributes> > groups;
    int attrGroupIndex = 0;
    std::map<int /**attributesGroupIndex*/, std::vector<AudioAttributes> > groups;
    for (const auto &attr : strategy.getAudioAttributes()) {
    for (const auto &attr : strategy.getAudioAttributes()) {
        int attrGroupId = attr.getGroupId();
        int groupId = attr.getGroupId();
        groups[attrGroupId].push_back(attr);
        int streamType = attr.getStreamType();
        const auto &iter = std::find_if(begin(groups), end(groups),
                                        [groupId, streamType](const auto &iter) {
            const auto &frontAttr = iter.second.front();
            return frontAttr.getGroupId() == groupId && frontAttr.getStreamType() == streamType;
        });
        // Same Volume Group Id and same stream type
        if (iter != end(groups)) {
             groups[iter->first].push_back(attr);
        } else {
            // Add a new Group of AudioAttributes for this product strategy
            groups[attrGroupIndex++].push_back(attr);
        }
    }
    }
    numAttributesGroups = groups.size();
    numAttributesGroups = groups.size();


@@ -97,7 +110,7 @@ static jint convertAudioProductStrategiesFromNative(
    for (const auto &iter : groups) {
    for (const auto &iter : groups) {
        std::vector<AudioAttributes> audioAttributesGroups = iter.second;
        std::vector<AudioAttributes> audioAttributesGroups = iter.second;
        jint numAttributes = audioAttributesGroups.size();
        jint numAttributes = audioAttributesGroups.size();
        jint jGroupId = iter.first;
        jint jGroupId = audioAttributesGroups.front().getGroupId();
        jint jLegacyStreamType = audioAttributesGroups.front().getStreamType();
        jint jLegacyStreamType = audioAttributesGroups.front().getStreamType();


        jStatus = JNIAudioAttributeHelper::getJavaArray(env, &jAudioAttributes, numAttributes);
        jStatus = JNIAudioAttributeHelper::getJavaArray(env, &jAudioAttributes, numAttributes);