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

Commit 2f7a6072 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Disable buffer dropping from BufferQueueProducer" into qt-dev

parents 67607d6d e3c87346
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -1110,6 +1110,9 @@ status_t MediaCodec::configure(
            reset();
        }
        if (!isResourceError(err)) {
            if (err == OK) {
                disableLegacyBufferDropPostQ(surface);
            }
            break;
        }
    }
@@ -1175,7 +1178,11 @@ status_t MediaCodec::setSurface(const sp<Surface> &surface) {
    msg->setObject("surface", surface);

    sp<AMessage> response;
    return PostAndAwaitResponse(msg, &response);
    status_t result = PostAndAwaitResponse(msg, &response);
    if (result == OK) {
        disableLegacyBufferDropPostQ(surface);
    }
    return result;
}

status_t MediaCodec::createInputSurface(
+26 −0
Original line number Diff line number Diff line
@@ -18,10 +18,13 @@
#define LOG_TAG "SurfaceUtils"
#include <utils/Log.h>

#include <android/api-level.h>
#include <media/hardware/VideoAPI.h>
#include <media/stagefright/SurfaceUtils.h>
#include <gui/Surface.h>

extern "C" int android_get_application_target_sdk_version();

namespace android {

status_t setNativeWindowSizeFormatAndUsage(
@@ -291,5 +294,28 @@ status_t nativeWindowDisconnect(ANativeWindow *surface, const char *reason) {

    return err;
}

status_t disableLegacyBufferDropPostQ(const sp<Surface> &surface) {
    sp<IGraphicBufferProducer> igbp =
            surface ? surface->getIGraphicBufferProducer() : nullptr;
    if (igbp) {
        int targetSdk = android_get_application_target_sdk_version();
        // When the caller is not an app (e.g. MediaPlayer in mediaserver)
        // targetSdk is __ANDROID_API_FUTURE__.
        bool drop =
                targetSdk < __ANDROID_API_Q__ ||
                targetSdk == __ANDROID_API_FUTURE__;
        if (!drop) {
            status_t err = igbp->setLegacyBufferDrop(false);
            if (err == NO_ERROR) {
                ALOGD("legacy buffer drop disabled: target sdk (%d)",
                      targetSdk);
            } else {
                ALOGD("disabling legacy buffer drop failed: %d", err);
            }
        }
    }
    return NO_ERROR;
}
}  // namespace android
+11 −0
Original line number Diff line number Diff line
@@ -19,8 +19,10 @@
#define SURFACE_UTILS_H_

#include <utils/Errors.h>
#include <utils/StrongPointer.h>

struct ANativeWindow;
class Surface;

namespace android {

@@ -40,6 +42,15 @@ status_t pushBlankBuffersToNativeWindow(ANativeWindow *nativeWindow /* nonnull *
status_t nativeWindowConnect(ANativeWindow *surface, const char *reason);
status_t nativeWindowDisconnect(ANativeWindow *surface, const char *reason);

/**
 * Disable buffer dropping behavior of BufferQueue if target sdk of application
 * is Q or later. If the caller is not an app (e.g. MediaPlayer in mediaserver)
 * retain buffer dropping behavior.
 *
 * @return NO_ERROR
 */
status_t disableLegacyBufferDropPostQ(const sp<Surface> &surface);

} // namespace android

#endif  // SURFACE_UTILS_H_