GLuint _frameBuffer;
BOOL _bufferNeedReset;
+ BOOL _appActive;
}
@property (readwrite) vout_display_t* voutDisplay;
@property (readonly) EAGLContext* eaglContext;
+@property (readonly) BOOL isAppActive;
- (void)createBuffers;
- (void)destroyBuffers;
vd->control = Control;
/* */
+ [[NSNotificationCenter defaultCenter] addObserver:sys->glESView selector:@selector(applicationStateChanged:) name:UIApplicationWillResignActiveNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:sys->glESView selector:@selector(applicationStateChanged:) name:UIApplicationDidBecomeActiveNotification object:nil];
[sys->glESView performSelectorOnMainThread:@selector(reshape) withObject:nil waitUntilDone:YES];
[autoreleasePool release];
{
vout_display_sys_t *sys = vd->sys;
sys->has_first_frame = true;
- vout_display_opengl_Display(sys->vgl, &vd->source);
+ if ([sys->glESView isAppActive])
+ vout_display_opengl_Display(sys->vgl, &vd->source);
picture_Release(pic);
vout_display_sys_t *sys = vd->sys;
- vout_display_opengl_Prepare(sys->vgl, pic, subpicture);
+ if ([sys->glESView isAppActive])
+ vout_display_opengl_Prepare(sys->vgl, pic, subpicture);
}
static picture_pool_t *PicturePool(vout_display_t *vd, unsigned requested_count)
static void OpenglESSwap(vlc_gl_t *gl)
{
vout_display_sys_t *sys = (vout_display_sys_t *)gl->sys;
- [[sys->glESView eaglContext] presentRenderbuffer:GL_RENDERBUFFER];
+ if ([sys->glESView isAppActive])
+ [[sys->glESView eaglContext] presentRenderbuffer:GL_RENDERBUFFER];
}
/*****************************************************************************
* Our UIView object
*****************************************************************************/
@implementation VLCOpenGLES2VideoView
-@synthesize voutDisplay = _voutDisplay, eaglContext = _eaglContext;
+@synthesize voutDisplay = _voutDisplay, eaglContext = _eaglContext, isAppActive = _appActive;
+ (Class)layerClass
{
[self performSelectorOnMainThread:@selector(reshape) withObject:nil waitUntilDone:NO];
[self setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
+ _appActive = ([UIApplication sharedApplication].applicationState == UIApplicationStateActive);
+
return self;
}
glViewport(place.x, place.y, place.width, place.height);
}
+- (void)applicationStateChanged:(NSNotification *)notification
+{
+ if ([[notification name] isEqualToString: UIApplicationWillResignActiveNotification])
+ _appActive = NO;
+ else
+ _appActive = YES;
+}
+
- (void)updateConstraints
{
[self reshape];