vlc | branch: master | Alexandre Janniaux <[email protected]> | Wed Jan 13 12:07:27 2021 +0100| [f3dbaa3ddf6617e637d5b02aef40a256f6c2bbbd] | committer: Alexandre Janniaux
android: utils: allow single-buffered vlc_asurfacetexture Non single-buffered vlc_asurfacetexture are very expensive when you only want to store a single buffer. When using multiple of them, it's possible that the phone goes OOM, and especially on old phones that don't support single-buffered SurfaceTexture so in that case just fail the creation of the SurfaceTexture. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f3dbaa3ddf6617e637d5b02aef40a256f6c2bbbd --- modules/codec/omxil/mediacodec.c | 2 +- modules/video_output/android/utils.c | 13 ++++++++----- modules/video_output/android/utils.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c index b021f87afe..4469e73e33 100644 --- a/modules/codec/omxil/mediacodec.c +++ b/modules/codec/omxil/mediacodec.c @@ -665,7 +665,7 @@ CreateVideoContext(decoder_t *p_dec) if (use_surfacetexture) { - p_sys->video.surfacetexture = vlc_asurfacetexture_New(awh); + p_sys->video.surfacetexture = vlc_asurfacetexture_New(awh, false); assert(p_sys->video.surfacetexture); if (p_sys->video.surfacetexture == NULL) goto error; diff --git a/modules/video_output/android/utils.c b/modules/video_output/android/utils.c index 1172b6c16b..e46b8e004d 100644 --- a/modules/video_output/android/utils.c +++ b/modules/video_output/android/utils.c @@ -959,7 +959,7 @@ AWindowHandler_getANativeWindowAPI(AWindowHandler *p_awh) } static struct vlc_asurfacetexture_priv* CreateSurfaceTexture( - AWindowHandler *p_awh, JNIEnv *p_env) + AWindowHandler *p_awh, JNIEnv *p_env, bool single_buffer) { /* Needed in case of old API, see comments below. */ EGLDisplay display = EGL_NO_DISPLAY; @@ -990,7 +990,7 @@ static struct vlc_asurfacetexture_priv* CreateSurfaceTexture( /* We can create a SurfaceTexture in detached mode directly */ surfacetexture = (*p_env)->NewObject(p_env, - p_awh->jfields.SurfaceTexture.clazz, p_awh->jfields.SurfaceTexture.init_z, false); + p_awh->jfields.SurfaceTexture.clazz, p_awh->jfields.SurfaceTexture.init_z, single_buffer); if (surfacetexture == NULL) goto error; @@ -1060,7 +1060,7 @@ init_iz: msg_Dbg(p_awh->wnd, "Using SurfaceTexture constructor init_iz"); surfacetexture = (*p_env)->NewObject(p_env, - p_awh->jfields.SurfaceTexture.clazz, p_awh->jfields.SurfaceTexture.init_iz, texture, false); + p_awh->jfields.SurfaceTexture.clazz, p_awh->jfields.SurfaceTexture.init_iz, texture, single_buffer); if (surfacetexture == NULL) goto error; @@ -1072,6 +1072,9 @@ init_i: assert(p_awh->jfields.SurfaceTexture.init_i != NULL); msg_Dbg(p_awh->wnd, "Using SurfaceTexture constructor init_i"); + if (single_buffer) + goto error; + surfacetexture = (*p_env)->NewObject(p_env, p_awh->jfields.SurfaceTexture.clazz, p_awh->jfields.SurfaceTexture.init_i, texture); @@ -1168,11 +1171,11 @@ error: } struct vlc_asurfacetexture * -vlc_asurfacetexture_New(AWindowHandler *p_awh) +vlc_asurfacetexture_New(AWindowHandler *p_awh, bool single_buffer) { JNIEnv *p_env = android_getEnvCommon(NULL, p_awh->p_jvm, "SurfaceTexture"); struct vlc_asurfacetexture_priv *surfacetexture = - CreateSurfaceTexture(p_awh, p_env); + CreateSurfaceTexture(p_awh, p_env, single_buffer); if (surfacetexture == NULL) return NULL; return &surfacetexture->surface; diff --git a/modules/video_output/android/utils.h b/modules/video_output/android/utils.h index a9610545f3..ca5838b2f5 100644 --- a/modules/video_output/android/utils.h +++ b/modules/video_output/android/utils.h @@ -203,7 +203,7 @@ SurfaceTexture_detachFromGLContext(struct vlc_asurfacetexture *st); * See Android SurfaceTexture */ struct vlc_asurfacetexture * -vlc_asurfacetexture_New(AWindowHandler *p_awh); +vlc_asurfacetexture_New(AWindowHandler *p_awh, bool single_buffer); /** * Delete a SurfaceTexture object created with SurfaceTexture_New. _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
