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

Commit 63296e3d authored by Eric Laurent's avatar Eric Laurent Committed by android-build-merger
Browse files

Merge "libaudiohal: fix get supported parameters queries in HIDL mode" into oc-dev

am: eaca4a18

Change-Id: Iabcdbdeddf20e11c3b815c2e7371177da83d810e
parents be08ba90 eaca4a18
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -31,10 +31,24 @@ status_t ConversionHelperHidl::keysFromHal(const String8& keys, hidl_vec<hidl_st
    AudioParameter halKeys(keys);
    if (halKeys.size() == 0) return BAD_VALUE;
    hidlKeys->resize(halKeys.size());
    //FIXME:  keyStreamSupportedChannels and keyStreamSupportedSamplingRates come with a
    // "keyFormat=<value>" pair. We need to transform it into a single key string so that it is
    // carried over to the legacy HAL via HIDL.
    String8 value;
    bool keepFormatValue = halKeys.size() == 2 &&
         (halKeys.get(String8(AudioParameter::keyStreamSupportedChannels), value) == NO_ERROR ||
         halKeys.get(String8(AudioParameter::keyStreamSupportedSamplingRates), value) == NO_ERROR);

    for (size_t i = 0; i < halKeys.size(); ++i) {
        String8 key;
        status_t status = halKeys.getAt(i, key);
        if (status != OK) return status;
        if (keepFormatValue && key == AudioParameter::keyFormat) {
            AudioParameter formatParam;
            halKeys.getAt(i, key, value);
            formatParam.add(key, value);
            key = formatParam.toString();
        }
        (*hidlKeys)[i] = key.string();
    }
    return OK;