X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_output%2Fios.m;h=baae0162a984cfe7efd01fa9f09f756080478d94;hb=ec04db28586c567287f5b5350153042d65a6fd19;hp=2b0948c2f7a15dbbac24a1d6fb70a43d740eaa45;hpb=91f7ead257fe27075aa33dc25a44592d06b0cab6;p=vlc diff --git a/modules/video_output/ios.m b/modules/video_output/ios.m index 2b0948c2f7..baae0162a9 100644 --- a/modules/video_output/ios.m +++ b/modules/video_output/ios.m @@ -27,8 +27,6 @@ *****************************************************************************/ #import -#import -#import #import #import @@ -68,7 +66,7 @@ vlc_module_begin () set_description( N_("iOS OpenGL ES video output (requires UIView)")) set_category(CAT_VIDEO) set_subcategory(SUBCAT_VIDEO_VOUT ) - set_capability("vout display", 300) + set_capability("vout display", 210) set_callbacks(Open, Close) add_shortcut("ios", "vout_ios") @@ -157,11 +155,11 @@ static int Open(vlc_object_t *this) sys->gl.lock = OpenglClean; // We don't do locking, but sometimes we need to cleanup the framebuffer sys->gl.unlock = NULL; sys->gl.swap = OpenglSwap; - sys->gl.getProcAddress = OurGetProcAddress; + sys->gl.getProcAddress = OurGetProcAddress; sys->gl.sys = sys; - sys->vgl = vout_display_opengl_New(&vd->fmt, NULL, &sys->gl); - if (!sys->vgl) + sys->vgl = vout_display_opengl_New(&vd->fmt, NULL, &sys->gl); + if (!sys->vgl) { sys->gl.sys = NULL; goto error; @@ -232,17 +230,20 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned requested_count) static void PictureRender(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture) { vout_display_sys_t *sys = vd->sys; - - vout_display_opengl_Prepare( sys->vgl, pic, subpicture ); + if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) { + vout_display_opengl_Prepare( sys->vgl, pic, subpicture ); + } } static void PictureDisplay(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture) { vout_display_sys_t *sys = vd->sys; - vout_display_opengl_Display(sys->vgl, &vd->fmt ); + if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) { + vout_display_opengl_Display(sys->vgl, &vd->fmt ); + } picture_Release (pic); sys->has_first_frame = true; - (void)subpicture; + (void)subpicture; } static int Control (vout_display_t *vd, int query, va_list ap) @@ -297,7 +298,10 @@ static void OpenglSwap(vlc_gl_t *gl) { vout_display_sys_t *sys = gl->sys; EAGLContext *context = [sys->glView context]; - [context presentRenderbuffer:GL_RENDERBUFFER_OES]; + + if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) { + [context presentRenderbuffer:GL_RENDERBUFFER]; + } } /***************************************************************************** @@ -333,7 +337,7 @@ static void OpenglSwap(vlc_gl_t *gl) kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; - _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; + _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; NSAssert(_context && [EAGLContext setCurrentContext:_context], @"Creating context"); // This shouldn't need to be done on the main thread. @@ -394,22 +398,22 @@ static void OpenglSwap(vlc_gl_t *gl) msg_Dbg(_vd, "Creating framebuffer for layer %p with bounds (%.1f,%.1f,%.1f,%.1f)", self.layer, self.layer.bounds.origin.x, self.layer.bounds.origin.y, self.layer.bounds.size.width, self.layer.bounds.size.height); [EAGLContext setCurrentContext:_context]; // Create default framebuffer object. The backing will be allocated for the current layer in -resizeFromLayer - glGenFramebuffersOES(1, &_defaultFramebuffer); // Generate one framebuffer, store it in _defaultFrameBuffer - glGenRenderbuffersOES(1, &_colorRenderbuffer); - glBindFramebufferOES(GL_FRAMEBUFFER_OES, _defaultFramebuffer); - glBindRenderbufferOES(GL_RENDERBUFFER_OES, _colorRenderbuffer); + glGenFramebuffers(1, &_defaultFramebuffer); // Generate one framebuffer, store it in _defaultFrameBuffer + glGenRenderbuffers(1, &_colorRenderbuffer); + glBindFramebuffer(GL_FRAMEBUFFER, _defaultFramebuffer); + glBindRenderbuffer(GL_RENDERBUFFER, _colorRenderbuffer); // This call associates the storage for the current render buffer with the EAGLDrawable (our CAEAGLLayer) // allowing us to draw into a buffer that will later be rendered to screen wherever the layer is (which corresponds with our view). - [_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id)self.layer]; - glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _colorRenderbuffer); + [_context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(id)self.layer]; + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _colorRenderbuffer); GLint backingWidth, backingHeight; - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); + glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &backingWidth); + glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &backingHeight); - if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { - msg_Err(_vd, "Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); + if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + msg_Err(_vd, "Failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER)); } [self _updateViewportWithBackingWitdh:backingWidth andBackingHeight:backingHeight]; } @@ -456,9 +460,9 @@ static void OpenglSwap(vlc_gl_t *gl) - (void)_destroyFramebuffer { [EAGLContext setCurrentContext:_context]; - glDeleteFramebuffersOES(1, &_defaultFramebuffer); + glDeleteFramebuffers(1, &_defaultFramebuffer); _defaultFramebuffer = 0; - glDeleteRenderbuffersOES(1, &_colorRenderbuffer); + glDeleteRenderbuffers(1, &_colorRenderbuffer); _colorRenderbuffer = 0; } @end