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

Commit 7a31095b authored by Pawin Vongmasa's avatar Pawin Vongmasa Committed by android-build-merger
Browse files

Merge "Prevent NOT_ENOUGH_DATA from entering HIDL" into pi-dev am: 79890542

am: a458ff06

Change-Id: Ie5e2d674ab091fd2d19c95dfb201b6609f0fd646
parents 784bead1 a458ff06
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -3,10 +3,12 @@ cc_library_headers {
    vendor_available: true,
    export_include_dirs: ["include"],
    header_libs:[
        "libgui_headers",
        "libstagefright_headers",
        "media_plugin_headers",
    ],
    export_header_lib_headers: [
        "libgui_headers",
        "libstagefright_headers",
        "media_plugin_headers",
    ],
@@ -192,6 +194,14 @@ cc_library {
        export_aidl_headers: true,
    },

    header_libs: [
        "libstagefright_headers",
    ],

    export_header_lib_headers: [
        "libstagefright_headers",
    ],

    shared_libs: [
        "liblog",
        "libcutils",
+66 −22
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <vector>
#include <list>

#include <cinttypes>
#include <unistd.h>

#include <hidl/MQDescriptor.h>
@@ -34,6 +35,8 @@
#include <media/OMXFenceParcelable.h>
#include <media/OMXBuffer.h>
#include <media/hardware/VideoAPI.h>
#include <media/stagefright/MediaErrors.h>
#include <gui/IGraphicBufferProducer.h>

#include <android/hardware/media/omx/1.0/types.h>
#include <android/hardware/media/omx/1.0/IOmx.h>
@@ -196,26 +199,6 @@ inline ::android::binder::Status toBinderStatus(
            t.isOk() ? static_cast<status_t>(static_cast<Status>(t)) : UNKNOWN_ERROR);
}

/**
 * \brief Convert `Return<Status>` to `status_t`. This is for legacy binder
 * calls.
 *
 * \param[in] t The source `Return<Status>`.
 * \return The corresponding `status_t`.
 *
 * This function first check if \p t has a transport error. If it does, then the
 * return value is the transport error code. Otherwise, the return value is
 * converted from `Status` contained inside \p t.
 *
 * Note:
 * - This `Status` is omx-specific. It is defined in `types.hal`.
 * - The name of this function is not `convert`.
 */
// convert: Status -> status_t
inline status_t toStatusT(Return<Status> const& t) {
    return t.isOk() ? static_cast<status_t>(static_cast<Status>(t)) : UNKNOWN_ERROR;
}

/**
 * \brief Convert `Return<void>` to `status_t`. This is for legacy binder calls.
 *
@@ -235,7 +218,47 @@ inline status_t toStatusT(Return<void> const& t) {
 */
// convert: Status -> status_t
inline status_t toStatusT(Status const& t) {
    switch (t) {
    case Status::NO_ERROR:
    case Status::NAME_NOT_FOUND:
    case Status::WOULD_BLOCK:
    case Status::NO_MEMORY:
    case Status::ALREADY_EXISTS:
    case Status::NO_INIT:
    case Status::BAD_VALUE:
    case Status::DEAD_OBJECT:
    case Status::INVALID_OPERATION:
    case Status::TIMED_OUT:
    case Status::ERROR_UNSUPPORTED:
    case Status::UNKNOWN_ERROR:
    case Status::RELEASE_ALL_BUFFERS:
        return static_cast<status_t>(t);
    case Status::BUFFER_NEEDS_REALLOCATION:
        return NOT_ENOUGH_DATA;
    default:
        ALOGW("Unrecognized status value: %" PRId32, static_cast<int32_t>(t));
        return static_cast<status_t>(t);
    }
}

/**
 * \brief Convert `Return<Status>` to `status_t`. This is for legacy binder
 * calls.
 *
 * \param[in] t The source `Return<Status>`.
 * \return The corresponding `status_t`.
 *
 * This function first check if \p t has a transport error. If it does, then the
 * return value is the transport error code. Otherwise, the return value is
 * converted from `Status` contained inside \p t.
 *
 * Note:
 * - This `Status` is omx-specific. It is defined in `types.hal`.
 * - The name of this function is not `convert`.
 */
// convert: Status -> status_t
inline status_t toStatusT(Return<Status> const& t) {
    return t.isOk() ? toStatusT(static_cast<Status>(t)) : UNKNOWN_ERROR;
}

/**
@@ -246,7 +269,28 @@ inline status_t toStatusT(Status const& t) {
 */
// convert: status_t -> Status
inline Status toStatus(status_t l) {
    switch (l) {
    case NO_ERROR:
    case NAME_NOT_FOUND:
    case WOULD_BLOCK:
    case NO_MEMORY:
    case ALREADY_EXISTS:
    case NO_INIT:
    case BAD_VALUE:
    case DEAD_OBJECT:
    case INVALID_OPERATION:
    case TIMED_OUT:
    case ERROR_UNSUPPORTED:
    case UNKNOWN_ERROR:
    case IGraphicBufferProducer::RELEASE_ALL_BUFFERS:
    case IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION:
        return static_cast<Status>(l);
    case NOT_ENOUGH_DATA:
        return Status::BUFFER_NEEDS_REALLOCATION;
    default:
        ALOGW("Unrecognized status value: %" PRId32, static_cast<int32_t>(l));
        return static_cast<Status>(l);
    }
}

/**
+56 −13
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <vector>
#include <list>

#include <cinttypes>
#include <unistd.h>

#include <hidl/MQDescriptor.h>
@@ -35,6 +36,7 @@
#include <media/OMXFenceParcelable.h>
#include <media/OMXBuffer.h>
#include <media/hardware/VideoAPI.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/bqhelper/Conversion.h>

#include <android/hidl/memory/1.0/IMemory.h>
@@ -140,6 +142,37 @@ using ::android::conversion::toStatusT;
 * `convertTo()` do.
 */

/**
 * \brief Convert `Status` to `status_t`. This is for legacy binder calls.
 *
 * \param[in] t The source `Status`.
 * \return the corresponding `status_t`.
 */
// convert: Status -> status_t
inline status_t toStatusT(Status const& t) {
    switch (t) {
    case Status::NO_ERROR:
    case Status::NAME_NOT_FOUND:
    case Status::WOULD_BLOCK:
    case Status::NO_MEMORY:
    case Status::ALREADY_EXISTS:
    case Status::NO_INIT:
    case Status::BAD_VALUE:
    case Status::DEAD_OBJECT:
    case Status::INVALID_OPERATION:
    case Status::TIMED_OUT:
    case Status::ERROR_UNSUPPORTED:
    case Status::UNKNOWN_ERROR:
    case Status::RELEASE_ALL_BUFFERS:
        return static_cast<status_t>(t);
    case Status::BUFFER_NEEDS_REALLOCATION:
        return NOT_ENOUGH_DATA;
    default:
        ALOGW("Unrecognized status value: %" PRId32, static_cast<int32_t>(t));
        return static_cast<status_t>(t);
    }
}

/**
 * \brief Convert `Return<Status>` to `status_t`. This is for legacy binder
 * calls.
@@ -157,18 +190,7 @@ using ::android::conversion::toStatusT;
 */
// convert: Status -> status_t
inline status_t toStatusT(Return<Status> const& t) {
    return t.isOk() ? static_cast<status_t>(static_cast<Status>(t)) : UNKNOWN_ERROR;
}

/**
 * \brief Convert `Status` to `status_t`. This is for legacy binder calls.
 *
 * \param[in] t The source `Status`.
 * \return the corresponding `status_t`.
 */
// convert: Status -> status_t
inline status_t toStatusT(Status const& t) {
    return static_cast<status_t>(t);
    return t.isOk() ? toStatusT(static_cast<Status>(t)) : UNKNOWN_ERROR;
}

/**
@@ -179,7 +201,28 @@ inline status_t toStatusT(Status const& t) {
 */
// convert: status_t -> Status
inline Status toStatus(status_t l) {
    switch (l) {
    case NO_ERROR:
    case NAME_NOT_FOUND:
    case WOULD_BLOCK:
    case NO_MEMORY:
    case ALREADY_EXISTS:
    case NO_INIT:
    case BAD_VALUE:
    case DEAD_OBJECT:
    case INVALID_OPERATION:
    case TIMED_OUT:
    case ERROR_UNSUPPORTED:
    case UNKNOWN_ERROR:
    case IGraphicBufferProducer::RELEASE_ALL_BUFFERS:
    case IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION:
        return static_cast<Status>(l);
    case NOT_ENOUGH_DATA:
        return Status::BUFFER_NEEDS_REALLOCATION;
    default:
        ALOGW("Unrecognized status value: %" PRId32, static_cast<int32_t>(l));
        return static_cast<Status>(l);
    }
}

/**