|
|
|
@ -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
|
|
|
|
|
|
|
|
|
|