[vlc-commits] vout: ios: don't wait for the MainThread from Control callback

2018-03-07 Thread Thomas Guillem
vlc/vlc-3.0 | branch: master | Thomas Guillem  | Tue Mar  6 
10:32:48 2018 +0100| [fc0a3d02419a6a5f022aef5964de996a3df928a7] | committer: 
Thomas Guillem

vout: ios: don't wait for the MainThread from Control callback

(cherry picked from commit a0df71911458b6ca9ef2f659e19eabdb8f51e790)
Signed-off-by: Thomas Guillem 

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=fc0a3d02419a6a5f022aef5964de996a3df928a7
---

 modules/video_output/ios.m | 217 -
 1 file changed, 96 insertions(+), 121 deletions(-)

Diff:   
http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commitdiff;h=fc0a3d02419a6a5f022aef5964de996a3df928a7
___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] vout: ios: don't wait for the MainThread from Control callback

2018-03-07 Thread Thomas Guillem
vlc | branch: master | Thomas Guillem  | Tue Mar  6 10:32:48 
2018 +0100| [a0df71911458b6ca9ef2f659e19eabdb8f51e790] | committer: Thomas 
Guillem

vout: ios: don't wait for the MainThread from Control callback

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a0df71911458b6ca9ef2f659e19eabdb8f51e790
---

 modules/video_output/ios.m | 217 -
 1 file changed, 96 insertions(+), 121 deletions(-)

diff --git a/modules/video_output/ios.m b/modules/video_output/ios.m
index 31fad7fbfa..3e3bb15c7f 100644
--- a/modules/video_output/ios.m
+++ b/modules/video_output/ios.m
@@ -95,9 +95,15 @@ vlc_module_end ()
 
 BOOL _bufferNeedReset;
 BOOL _appActive;
+BOOL _placeInvalidated;
 
 /* Written from MT, read locked from vout */
 vout_display_place_t _place;
+CGSize _viewSize;
+CGFloat _scaleFactor;
+
+/* Written from vout, read locked from MT */
+vout_display_cfg_t _cfg;
 }
 @property (readonly) GLuint renderBuffer;
 @property (readonly) GLuint frameBuffer;
@@ -107,14 +113,14 @@ vlc_module_end ()
 - (id)initWithFrameAndVd:(CGRect)frame withVd:(vout_display_t*)vd;
 - (void)createBuffers;
 - (void)destroyBuffers;
-- (void)resetBuffers;
 - (BOOL)makeCurrent:(EAGLContext **)previousEaglContext;
+- (BOOL)makeCurrentWithGL:(EAGLContext **)previousEaglContext withGL:(vlc_gl_t 
*)gl;
 - (void)releaseCurrent:(EAGLContext *)previousEaglContext;
 
-- (void)setPlace:(const vout_display_place_t *)place;
+- (void)updateVoutCfg:(const vout_display_cfg_t *)cfg 
withVGL:(vout_display_opengl_t *)vgl;
+- (void)getPlaceLocked:(vout_display_place_t *)place;
 - (void)reshape;
 - (void)propagateDimensionsToVoutCore;
-- (CGSize)viewSize;
 @end
 
 struct vout_display_sys_t
@@ -296,50 +302,18 @@ static int Control(vout_display_t *vd, int query, va_list 
ap)
 case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
 case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
 {
-if (!vd->sys)
-return VLC_EGENERIC;
-
-@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;
-} else {
-cfg = (const vout_display_cfg_t*)va_arg(ap, const 
vout_display_cfg_t *);
-}
-
-/* we don't adapt anything here regardless of what the vout 
core
- * wants since we are not in a traditional desktop window */
-if (!cfg)
-return VLC_EGENERIC;
+const vout_display_cfg_t *cfg;
 
-vout_display_cfg_t cfg_tmp = *cfg;
-CGSize viewSize;
-viewSize = [sys->glESView viewSize];
+if (query == VOUT_DISPLAY_CHANGE_SOURCE_ASPECT ||
+query == VOUT_DISPLAY_CHANGE_SOURCE_CROP)
+cfg = vd->cfg;
+else
+cfg = (const vout_display_cfg_t*)va_arg(ap, const 
vout_display_cfg_t *);
 
-/* on HiDPI displays, the point bounds don't equal the actual 
pixels */
-CGFloat scaleFactor = sys->glESView.contentScaleFactor;
-cfg_tmp.display.width = viewSize.width * scaleFactor;
-cfg_tmp.display.height = viewSize.height * scaleFactor;
+assert(cfg);
 
-vout_display_place_t place;
-vout_display_PlacePicture(, >source, _tmp, 
false);
+[sys->glESView updateVoutCfg:cfg withVGL:glsys->vgl];
 
-[sys->glESView setPlace:];
-
-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)
-vout_display_opengl_Viewport(sys->vgl, place.x,
- cfg_tmp.display.height - 
(place.y + place.height),
- place.width, place.height);
-vlc_gl_ReleaseCurrent(sys->gl);
-}
 return VLC_SUCCESS;
 }
 
@@ -404,10 +378,8 @@ static int GLESMakeCurrent(vlc_gl_t *gl)
 {
 struct gl_sys *sys = gl->sys;
 
-if (![sys->glESView makeCurrent:>previousEaglContext])
+if (![sys->glESView makeCurrentWithGL:>previousEaglContext withGL:gl])
 return VLC_EGENERIC;
-
-[sys->glESView resetBuffers];
 return VLC_SUCCESS;
 }
 
@@ -456,6 +428,7 @@ static void GLESSwap(vlc_gl_t *gl)
 return nil;
 
 _voutDisplay = vd;
+_cfg = *_voutDisplay->cfg;
 
 vlc_mutex_init(&_mutex);
 
@@ -553,7 +526,10 @@ static void GLESSwap(vlc_gl_t *gl)
 - (void)didMoveToWindow
 {
 self.contentScaleFactor =