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

Commit 6512b605 authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Audio V4: some legacy getSupported can return NOT_SUPPORTED



Legacy implementation through getParameter can not return a status_t.
This is problematic for
 - getSupportedChannelMasks(format)
 - getSupportedSampleRate(format)
as they should be able to return NOT_SUPPORTED if they do not support
the provided format.

In that case, allow the legacy implementation to return an empty string
that will be converted to NOT_SUPPORTED.

Test: atest VtsHalAudioV4_0TargetTest
Bug: 77307068
Change-Id: I78c37caf059885e3d33e6a308876dbc0e3ef7145
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent 16d65479
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -101,11 +101,15 @@ Return<void> Stream::getSupportedSampleRates(AudioFormat format,
        halSampleRates =
            samplingRatesFromString(halListValue.string(), AudioParameter::valueListSeparator);
        sampleRates.setToExternal(halSampleRates.editArray(), halSampleRates.size());
        // Legacy get_parameter does not return a status_t, thus can not advertise of failure.
        // Note that this method must succeed (non empty list) if the format is supported.
        if (sampleRates.size() == 0) {
            result = Result::NOT_SUPPORTED;
        }
    }
#ifdef AUDIO_HAL_VERSION_2_0
    _hidl_cb(sampleRates);
#endif
#ifdef AUDIO_HAL_VERSION_4_0
#elif AUDIO_HAL_VERSION_4_0
    _hidl_cb(result, sampleRates);
#endif
    return Void();
@@ -126,6 +130,11 @@ Return<void> Stream::getSupportedChannelMasks(AudioFormat format,
        for (size_t i = 0; i < halChannelMasks.size(); ++i) {
            channelMasks[i] = AudioChannelBitfield(halChannelMasks[i]);
        }
        // Legacy get_parameter does not return a status_t, thus can not advertise of failure.
        // Note that this method must succeed (non empty list) if the format is supported.
        if (channelMasks.size() == 0) {
            result = Result::NOT_SUPPORTED;
        }
    }
#ifdef AUDIO_HAL_VERSION_2_0
    _hidl_cb(channelMasks);