vlc | branch: master | Alexandre Janniaux <aja...@videolabs.io> | Wed Jan 13 12:07:15 2021 +0100| [082a4d38cab7f177ee20a54191330dffe3b1094e] | committer: Alexandre Janniaux
android: utils: add releaseTexImage Add support for releaseTexImage in SurfaceTexture, which is needed in custom SurfaceTexture-based buffer producer to use the less number of buffer possible. This is especially important on old and low-memory devices which cannot create a ton of SurfaceTexture objects. Use the JNI variant for the NDK implementation since the function doesn't even exists in the NDK. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=082a4d38cab7f177ee20a54191330dffe3b1094e --- modules/video_output/android/utils.c | 31 +++++++++++++++++++++++++++++++ modules/video_output/android/utils.h | 6 ++++++ 2 files changed, 37 insertions(+) diff --git a/modules/video_output/android/utils.c b/modules/video_output/android/utils.c index 6e8a6f22b0..82210bf84e 100644 --- a/modules/video_output/android/utils.c +++ b/modules/video_output/android/utils.c @@ -130,6 +130,7 @@ static struct jmethodID init_iz; jmethodID init_z; jmethodID updateTexImage; + jmethodID releaseTexImage; jmethodID getTransformMatrix; jmethodID detachFromGLContext; jmethodID attachToGLContext; @@ -458,11 +459,15 @@ static void NDKSurfaceTexture_destroy( free(handle); } +static void +JNISurfaceTexture_releaseTexImage(struct vlc_asurfacetexture *surface); + static const struct vlc_asurfacetexture_operations NDKSurfaceAPI = { .attach_to_gl_context = NDKSurfaceTexture_attachToGLContext, .update_tex_image = NDKSurfaceTexture_updateTexImage, .detach_from_gl_context = NDKSurfaceTexture_detachFromGLContext, + .release_tex_image = JNISurfaceTexture_releaseTexImage, .destroy = NDKSurfaceTexture_destroy, }; @@ -540,6 +545,22 @@ JNISurfaceTexture_updateTexImage( return VLC_SUCCESS; } +static void +JNISurfaceTexture_releaseTexImage( + struct vlc_asurfacetexture *surface) +{ + struct vlc_asurfacetexture_priv *handle = + container_of(surface, struct vlc_asurfacetexture_priv, surface); + + AWindowHandler *p_awh = handle->awh; + JNIEnv *p_env = android_getEnvCommon(NULL, handle->awh->p_jvm, "SurfaceTexture"); + if (!p_env) + return; + + (*p_env)->CallVoidMethod(p_env, handle->jtexture, + jfields.SurfaceTexture.releaseTexImage); +} + static void JNISurfaceTexture_destroy( struct vlc_asurfacetexture *surface) { @@ -563,6 +584,7 @@ static const struct vlc_asurfacetexture_operations JNISurfaceAPI = .attach_to_gl_context = JNISurfaceTexture_attachToGLContext, .update_tex_image = JNISurfaceTexture_updateTexImage, .detach_from_gl_context = JNISurfaceTexture_detachFromGLContext, + .release_tex_image = JNISurfaceTexture_releaseTexImage, .destroy = JNISurfaceTexture_destroy, }; @@ -726,6 +748,9 @@ InitJNIFields(JNIEnv *env, vlc_object_t *p_obj, jobject *jobj) GET_METHOD(SurfaceTexture, getTransformMatrix, "getTransformMatrix", "([F)V", true); + GET_METHOD(SurfaceTexture, releaseTexImage, + "releaseTexImage", "()V", false); + GET_METHOD(SurfaceTexture, attachToGLContext, "attachToGLContext", "(I)V", true); @@ -1270,3 +1295,9 @@ SurfaceTexture_updateTexImage(struct vlc_asurfacetexture *st, const float **pp_t { return st->ops->update_tex_image(st, pp_transform_mtx); } + +void +SurfaceTexture_releaseTexImage(struct vlc_asurfacetexture *st) +{ + return st->ops->release_tex_image(st); +} diff --git a/modules/video_output/android/utils.h b/modules/video_output/android/utils.h index 69c5eaaceb..a7fc84d7a8 100644 --- a/modules/video_output/android/utils.h +++ b/modules/video_output/android/utils.h @@ -104,6 +104,9 @@ struct vlc_asurfacetexture_operations struct vlc_asurfacetexture *surface, const float **pp_transform_mtx); + void (*release_tex_image)( + struct vlc_asurfacetexture *st); + void (*destroy)( struct vlc_asurfacetexture *surface); }; @@ -219,3 +222,6 @@ vlc_asurfacetexture_Delete(struct vlc_asurfacetexture *st) */ int SurfaceTexture_updateTexImage(struct vlc_asurfacetexture *st, const float **pp_transform_mtx); + +void +SurfaceTexture_releaseTexImage(struct vlc_asurfacetexture *st); _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits