[vlc-commits] vout: ios: refactor OpenGL context locking
Thomas Guillem
git at videolan.org
Fri Sep 8 13:46:15 CEST 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Sep 7 16:09:06 2017 +0200| [697d8b5f4a479f28e94744dc4c751bc3c0932a43] | committer: Thomas Guillem
vout: ios: refactor OpenGL context locking
Check if app is active from vlc_gl_MakeCurrent.
Simplify the code since sys->gl can't be NULL.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=697d8b5f4a479f28e94744dc4c751bc3c0932a43
---
modules/video_output/ios.m | 38 ++++++++++++++++----------------------
1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/modules/video_output/ios.m b/modules/video_output/ios.m
index 03f9c880d1..beeb56f689 100644
--- a/modules/video_output/ios.m
+++ b/modules/video_output/ios.m
@@ -257,7 +257,7 @@ static void Close (vlc_object_t *this)
@synchronized (sys->glESView) {
msg_Dbg(this, "deleting display");
- if (likely([sys->glESView isAppActive]) && sys->vgl)
+ if (likely(sys->vgl))
{
vlc_gl_MakeCurrent(sys->gl);
vout_display_opengl_Delete(sys->vgl);
@@ -294,6 +294,9 @@ static int Control(vout_display_t *vd, int query, va_list ap)
@autoreleasepool {
const vout_display_cfg_t *cfg;
+ if (vlc_gl_MakeCurrent(sys->gl) != VLC_SUCCESS)
+ return VLC_EGENERIC;
+
if (query == VOUT_DISPLAY_CHANGE_SOURCE_ASPECT ||
query == VOUT_DISPLAY_CHANGE_SOURCE_CROP) {
cfg = vd->cfg;
@@ -321,30 +324,19 @@ static int Control(vout_display_t *vd, int query, va_list ap)
sys->place = place;
}
- if (sys->gl != NULL) {
- vlc_gl_MakeCurrent(sys->gl);
- vout_display_opengl_SetWindowAspectRatio(sys->vgl, (float)place.width / place.height);
- }
+ vout_display_opengl_SetWindowAspectRatio(sys->vgl, (float)place.width / place.height);
// x / y are top left corner, but we need the lower left one
- if (query != VOUT_DISPLAY_CHANGE_DISPLAY_SIZE) {
+ if (query != VOUT_DISPLAY_CHANGE_DISPLAY_SIZE)
glViewport(place.x, cfg_tmp.display.height - (place.y + place.height), place.width, place.height);
- vlc_gl_ReleaseCurrent(sys->gl);
- }
+ vlc_gl_ReleaseCurrent(sys->gl);
}
return VLC_SUCCESS;
}
case VOUT_DISPLAY_CHANGE_VIEWPOINT:
- if (sys->gl != NULL) {
- vlc_gl_MakeCurrent(sys->gl);
- int viewport = vout_display_opengl_SetViewpoint(sys->vgl,
- &va_arg (ap, const vout_display_cfg_t* )->viewpoint);
- vlc_gl_ReleaseCurrent(sys->gl);
- return viewport;
- }
- else
- return VLC_EGENERIC;
+ return vout_display_opengl_SetViewpoint(sys->vgl,
+ &va_arg (ap, const vout_display_cfg_t* )->viewpoint);
case VOUT_DISPLAY_RESET_PICTURES:
vlc_assert_unreachable ();
@@ -358,7 +350,7 @@ static void PictureDisplay(vout_display_t *vd, picture_t *pic, subpicture_t *sub
{
vout_display_sys_t *sys = vd->sys;
@synchronized (sys->glESView) {
- if (likely([sys->glESView isAppActive]) && vlc_gl_MakeCurrent(sys->gl) == VLC_SUCCESS)
+ if (vlc_gl_MakeCurrent(sys->gl) == VLC_SUCCESS)
{
vout_display_opengl_Display(sys->vgl, &vd->source);
vlc_gl_ReleaseCurrent(sys->gl);
@@ -374,7 +366,7 @@ static void PictureDisplay(vout_display_t *vd, picture_t *pic, subpicture_t *sub
static void PictureRender(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture)
{
vout_display_sys_t *sys = vd->sys;
- if (likely([sys->glESView isAppActive]) && vlc_gl_MakeCurrent(sys->gl) == VLC_SUCCESS)
+ if (vlc_gl_MakeCurrent(sys->gl) == VLC_SUCCESS)
{
vout_display_opengl_Prepare(sys->vgl, pic, subpicture);
vlc_gl_ReleaseCurrent(sys->gl);
@@ -400,11 +392,13 @@ static int OpenglESLock(vlc_gl_t *gl)
{
struct gl_sys *sys = gl->sys;
+ if (unlikely(![sys->glESView isAppActive]))
+ return VLC_EGENERIC;
+
[sys->glESView lock];
- if (likely([sys->glESView isAppActive]))
- [sys->glESView resetBuffers];
+ [sys->glESView resetBuffers];
sys->locked_ctx = (__bridge CVEAGLContext) ((__bridge void *) [sys->glESView eaglContext]);
- return 0;
+ return VLC_SUCCESS;
}
static void OpenglESUnlock(vlc_gl_t *gl)
More information about the vlc-commits
mailing list