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

Commit 3ed9daf7 authored by Eric Laurent's avatar Eric Laurent
Browse files

libaudiohal: fix get supported parameters queries in HIDL mode

Add a special case for keyStreamSupportedChannels and
keyStreamSupportedSamplingRates in ConversionHelperHidl::keysFromHal().
In this case, the query also contains a key=value pair specifying
the audio format to consider and it must be passed to the audio
HAL including the value.

Bug: 38326193
Test: verify format specifier is sent to HAL for supported sampling
rates and channels queries

Change-Id: I14ac40da920122ec0242ab027a2a4ac1d92381c8
parent 38ad5e22
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;