[vlc-devel] [PATCHv2 02/14] android: utils: reorder SurfaceTexture implementation
Alexandre Janniaux
ajanni at videolabs.io
Wed Jun 24 15:14:26 CEST 2020
Avoid forward-declaring SurfaceTexture implementation. In future
refactor we will change their prototype and put them into vtable.
---
modules/video_output/android/utils.c | 161 ++++++++++++---------------
1 file changed, 73 insertions(+), 88 deletions(-)
diff --git a/modules/video_output/android/utils.c b/modules/video_output/android/utils.c
index 3f57489cf6d..45a30af455e 100644
--- a/modules/video_output/android/utils.c
+++ b/modules/video_output/android/utils.c
@@ -389,20 +389,84 @@ LoadNativeSurfaceAPI(AWindowHandler *p_awh)
*/
static int
-NDKSurfaceTexture_attachToGLContext(AWindowHandler *p_awh, uint32_t texName);
+NDKSurfaceTexture_attachToGLContext(AWindowHandler *p_awh, uint32_t texName)
+{
+ return p_awh->ndk_ast_api.pf_attachToGL(p_awh->ndk_ast_api.p_ast, texName);
+}
+
+static void
+NDKSurfaceTexture_detachFromGLContext(AWindowHandler *p_awh, JNIEnv *p_env)
+{
+ (void)p_env;
+ p_awh->ndk_ast_api.pf_detachFromGL(p_awh->ndk_ast_api.p_ast);
+}
+
+static int
+NDKSurfaceTexture_updateTexImage(AWindowHandler *p_awh, const float **pp_transform_mtx)
+{
+ if (p_awh->ndk_ast_api.pf_updateTexImage(p_awh->ndk_ast_api.p_ast))
+ return VLC_EGENERIC;
+
+ p_awh->ndk_ast_api.pf_getTransMatrix(p_awh->ndk_ast_api.p_ast,
+ p_awh->ndk_ast_api.transMat);
+ *pp_transform_mtx = p_awh->ndk_ast_api.transMat;
+ return VLC_SUCCESS;
+}
+
static int
-NDKSurfaceTexture_updateTexImage(AWindowHandler *p_awh,
- const float **pp_transform_mtx);
+JNISurfaceTexture_attachToGLContext(AWindowHandler *p_awh, uint32_t tex_name)
+{
+ JNIEnv *p_env = android_getEnvCommon(NULL, p_awh->p_jvm, "SurfaceTexture");
+ if (!p_env)
+ return VLC_EGENERIC;
+
+ return JNI_STEXCALL(CallBooleanMethod, attachToGLContext, tex_name) ?
+ VLC_SUCCESS : VLC_EGENERIC;
+}
+
static void
-NDKSurfaceTexture_detachFromGLContext(AWindowHandler *p_awh, JNIEnv *p_env);
+JNISurfaceTexture_detachFromGLContext(AWindowHandler *p_awh, JNIEnv *p_env)
+{
+ JNI_STEXCALL(CallVoidMethod, detachFromGLContext);
+
+ if (p_awh->stex.jtransform_mtx != NULL)
+ {
+ (*p_env)->ReleaseFloatArrayElements(p_env, p_awh->stex.jtransform_mtx_array,
+ p_awh->stex.jtransform_mtx,
+ JNI_ABORT);
+ p_awh->stex.jtransform_mtx = NULL;
+ }
+}
static int
JNISurfaceTexture_waitAndUpdateTexImage(AWindowHandler *p_awh,
- const float **pp_transform_mtx);
-static void
-JNISurfaceTexture_detachFromGLContext(AWindowHandler *p_awh, JNIEnv *p_env);
-static int
-JNISurfaceTexture_attachToGLContext(AWindowHandler *p_awh, uint32_t tex_name);
+ const float **pp_transform_mtx)
+{
+ JNIEnv *p_env = android_getEnvCommon(NULL, p_awh->p_jvm, "SurfaceTexture");
+ if (!p_env)
+ return VLC_EGENERIC;
+
+ if (p_awh->stex.jtransform_mtx != NULL)
+ (*p_env)->ReleaseFloatArrayElements(p_env, p_awh->stex.jtransform_mtx_array,
+ p_awh->stex.jtransform_mtx,
+ JNI_ABORT);
+
+ bool ret = JNI_STEXCALL(CallBooleanMethod, waitAndUpdateTexImage,
+ p_awh->stex.jtransform_mtx_array);
+ if (ret)
+ {
+ p_awh->stex.jtransform_mtx = (*p_env)->GetFloatArrayElements(p_env,
+ p_awh->stex.jtransform_mtx_array, NULL);
+ *pp_transform_mtx = p_awh->stex.jtransform_mtx;
+ return VLC_SUCCESS;
+ }
+ else
+ {
+ p_awh->stex.jtransform_mtx = NULL;
+ return VLC_EGENERIC;
+ }
+}
+
static int
LoadNDKSurfaceTextureAPI(AWindowHandler *p_awh, void *p_library, JNIEnv *p_env)
@@ -907,50 +971,12 @@ AWindowHandler_setVideoLayout(AWindowHandler *p_awh,
return VLC_SUCCESS;
}
-static int
-NDKSurfaceTexture_attachToGLContext(AWindowHandler *p_awh, uint32_t texName)
-{
- return p_awh->ndk_ast_api.pf_attachToGL(p_awh->ndk_ast_api.p_ast, texName);
-}
-
-static int
-JNISurfaceTexture_attachToGLContext(AWindowHandler *p_awh, uint32_t tex_name)
-{
- JNIEnv *p_env = android_getEnvCommon(NULL, p_awh->p_jvm, "SurfaceTexture");
- if (!p_env)
- return VLC_EGENERIC;
-
- return JNI_STEXCALL(CallBooleanMethod, attachToGLContext, tex_name) ?
- VLC_SUCCESS : VLC_EGENERIC;
-}
-
int
SurfaceTexture_attachToGLContext(AWindowHandler *p_awh, uint32_t tex_name)
{
return p_awh->st.pf_attachToGL(p_awh, tex_name);
}
-static void
-NDKSurfaceTexture_detachFromGLContext(AWindowHandler *p_awh, JNIEnv *p_env)
-{
- (void)p_env;
- p_awh->ndk_ast_api.pf_detachFromGL(p_awh->ndk_ast_api.p_ast);
-}
-
-static void
-JNISurfaceTexture_detachFromGLContext(AWindowHandler *p_awh, JNIEnv *p_env)
-{
- JNI_STEXCALL(CallVoidMethod, detachFromGLContext);
-
- if (p_awh->stex.jtransform_mtx != NULL)
- {
- (*p_env)->ReleaseFloatArrayElements(p_env, p_awh->stex.jtransform_mtx_array,
- p_awh->stex.jtransform_mtx,
- JNI_ABORT);
- p_awh->stex.jtransform_mtx = NULL;
- }
-}
-
void
SurfaceTexture_detachFromGLContext(AWindowHandler *p_awh)
{
@@ -963,47 +989,6 @@ SurfaceTexture_detachFromGLContext(AWindowHandler *p_awh)
AWindowHandler_releaseANativeWindowEnv(p_awh, p_env, AWindow_SurfaceTexture);
}
-static int
-NDKSurfaceTexture_updateTexImage(AWindowHandler *p_awh, const float **pp_transform_mtx)
-{
- if (p_awh->ndk_ast_api.pf_updateTexImage(p_awh->ndk_ast_api.p_ast))
- return VLC_EGENERIC;
-
- p_awh->ndk_ast_api.pf_getTransMatrix(p_awh->ndk_ast_api.p_ast,
- p_awh->ndk_ast_api.transMat);
- *pp_transform_mtx = p_awh->ndk_ast_api.transMat;
- return VLC_SUCCESS;
-}
-
-static int
-JNISurfaceTexture_waitAndUpdateTexImage(AWindowHandler *p_awh,
- const float **pp_transform_mtx)
-{
- JNIEnv *p_env = android_getEnvCommon(NULL, p_awh->p_jvm, "SurfaceTexture");
- if (!p_env)
- return VLC_EGENERIC;
-
- if (p_awh->stex.jtransform_mtx != NULL)
- (*p_env)->ReleaseFloatArrayElements(p_env, p_awh->stex.jtransform_mtx_array,
- p_awh->stex.jtransform_mtx,
- JNI_ABORT);
-
- bool ret = JNI_STEXCALL(CallBooleanMethod, waitAndUpdateTexImage,
- p_awh->stex.jtransform_mtx_array);
- if (ret)
- {
- p_awh->stex.jtransform_mtx = (*p_env)->GetFloatArrayElements(p_env,
- p_awh->stex.jtransform_mtx_array, NULL);
- *pp_transform_mtx = p_awh->stex.jtransform_mtx;
- return VLC_SUCCESS;
- }
- else
- {
- p_awh->stex.jtransform_mtx = NULL;
- return VLC_EGENERIC;
- }
-}
-
int
SurfaceTexture_updateTexImage(AWindowHandler *p_awh, const float **pp_transform_mtx)
{
--
2.27.0
More information about the vlc-devel
mailing list