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

Commit 8711cfda authored by Eric Laurent's avatar Eric Laurent
Browse files

audio HAL wrapper: createAudioPatch handle reuse

Add workaround for missing patch handle in HIDL
interface createAudioPatch() method signature.
The legacy HAL implementation has the convention of releasing
previous audio patch when a valid patch handle is passed.
The framework relies on this optimization and does not release previous
patch explicitly when just updating the sinks of an existing patch.

Bug: 117744819
Test: repro steps in bug
Change-Id: I93e19e4b16b0beac31438cffd0553f5db3117a1e
parent 8b7a6326
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -322,6 +322,14 @@ status_t DeviceHalHidl::createAudioPatch(
        const struct audio_port_config *sinks,
        audio_patch_handle_t *patch) {
    if (mDevice == 0) return NO_INIT;
    if (patch == nullptr) return BAD_VALUE;

    if (*patch != AUDIO_PATCH_HANDLE_NONE) {
        status_t status = releaseAudioPatch(*patch);
        ALOGW_IF(status != NO_ERROR, "%s error %d releasing patch handle %d",
            __func__, status, *patch);
    }

    hidl_vec<AudioPortConfig> hidlSources, hidlSinks;
    HidlUtils::audioPortConfigsFromHal(num_sources, sources, &hidlSources);
    HidlUtils::audioPortConfigsFromHal(num_sinks, sinks, &hidlSinks);