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

Commit 977176c2 authored by Wonsik Kim's avatar Wonsik Kim Committed by Sungtak Lee
Browse files

c2 hal: handle C2_BAD_INDEX

In Codec 2.0 API query/config may return C2_BAD_INDEX but has valid
out params. In AIDL when the result is not OK the out params are
invalidated. To reconcile the differences, HAL adaptation returns OK
for C2_BAD_INDEX and the client side recovers the error code from the
out params.

Bug: 315555457
Test: atest android.media.decoder.cts.DecoderTest
Change-Id: If7c285929b0e7782ea305d5f1e268ff28900f2b5
parent 325445a5
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <android-base/logging.h>

#include <android/binder_auto_utils.h>
#include <android-base/hex.h>
#include <codec2/aidl/Configurable.h>
#include <codec2/aidl/ParamTypes.h>

@@ -135,8 +136,6 @@ ScopedAStatus CachedConfigurable::querySupportedParams(
                LOG(WARNING) << "querySupportedParams -- invalid output params.";
                break;
            }
        } else {
            res = Status::BAD_INDEX;
        }
    }
    paramDesc->resize(dstIx);
+12 −3
Original line number Diff line number Diff line
@@ -649,8 +649,8 @@ c2_status_t Codec2ConfigurableClient::AidlImpl::query(
        return C2_CORRUPTED;
    }
    size_t i = 0;
    for (auto it = paramPointers.begin();
            it != paramPointers.end(); ) {
    size_t numUpdatedStackParams = 0;
    for (auto it = paramPointers.begin(); it != paramPointers.end(); ) {
        C2Param* paramPointer = *it;
        if (numStackIndices > 0) {
            --numStackIndices;
@@ -677,7 +677,9 @@ c2_status_t Codec2ConfigurableClient::AidlImpl::query(
                status = C2_BAD_INDEX;
                continue;
            }
            if (!stackParams[i++]->updateFrom(*paramPointer)) {
            if (stackParams[i++]->updateFrom(*paramPointer)) {
                ++numUpdatedStackParams;
            } else {
                LOG(WARNING) << "query -- param update failed: "
                                "index = "
                             << paramPointer->index() << ".";
@@ -697,6 +699,13 @@ c2_status_t Codec2ConfigurableClient::AidlImpl::query(
        }
        ++it;
    }
    size_t numQueried = numUpdatedStackParams;
    if (heapParams) {
        numQueried += heapParams->size();
    }
    if (status == C2_OK && indices.size() != numQueried) {
        status = C2_BAD_INDEX;
    }
    return status;
}