[MPlayer-cvslog] r29608 - trunk/libvo/vo_corevideo.m
reimar
subversion at mplayerhq.hu
Tue Sep 1 12:48:47 CEST 2009
Author: reimar
Date: Tue Sep 1 12:48:47 2009
New Revision: 29608
Log:
Reduce vo_corevideo memleaks by initializing static context etc. only once
in preinit and freeing the video-specific data before reallocating in config.
Modified:
trunk/libvo/vo_corevideo.m
Modified: trunk/libvo/vo_corevideo.m
==============================================================================
--- trunk/libvo/vo_corevideo.m Tue Sep 1 12:17:22 2009 (r29607)
+++ trunk/libvo/vo_corevideo.m Tue Sep 1 12:48:47 2009 (r29608)
@@ -431,6 +431,9 @@ static int control(uint32_t request, voi
@implementation MPlayerOpenGLView
- (void) preinit
{
+ GLint swapInterval = 1;
+ CVReturn error;
+
//init menu
[self initMenu];
@@ -448,6 +451,28 @@ static int control(uint32_t request, voi
isFullscreen = 0;
winSizeMult = 1;
+
+ //create OpenGL Context
+ glContext = [[NSOpenGLContext alloc] initWithFormat:[NSOpenGLView defaultPixelFormat] shareContext:nil];
+
+ [self setOpenGLContext:glContext];
+ [glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
+ [glContext setView:self];
+ [glContext makeCurrentContext];
+
+ error = CVOpenGLTextureCacheCreate(NULL, 0, [glContext CGLContextObj], [[self pixelFormat] CGLPixelFormatObj], 0, &textureCache);
+ if(error != kCVReturnSuccess)
+ mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture Cache(%d)\n", error);
+}
+
+- (void) releaseVideoSpecific
+{
+ CVPixelBufferRelease(frameBuffers[0]);
+ frameBuffers[0] = NULL;
+ CVPixelBufferRelease(frameBuffers[1]);
+ frameBuffers[1] = NULL;
+ CVOpenGLTextureRelease(texture);
+ texture = NULL;
}
- (void) config
@@ -455,8 +480,6 @@ static int control(uint32_t request, voi
uint32_t d_width;
uint32_t d_height;
- GLint swapInterval = 1;
-
NSRect frame;
CVReturn error = kCVReturnSuccess;
@@ -465,14 +488,7 @@ static int control(uint32_t request, voi
frame = NSMakeRect(0, 0, d_width, d_height);
[window setContentSize: frame.size];
- //create OpenGL Context
- glContext = [[NSOpenGLContext alloc] initWithFormat:[NSOpenGLView defaultPixelFormat] shareContext:nil];
-
- [self setOpenGLContext:glContext];
- [glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
- [glContext setView:self];
- [glContext makeCurrentContext];
-
+ [self releaseVideoSpecific];
error = CVPixelBufferCreateWithBytes(NULL, image_width, image_height, pixelFormat, image_datas[0], image_width*image_bytes, NULL, NULL, NULL, &frameBuffers[0]);
if(error != kCVReturnSuccess)
mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create Pixel Buffer(%d)\n", error);
@@ -482,10 +498,6 @@ static int control(uint32_t request, voi
mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create Pixel Double Buffer(%d)\n", error);
}
- error = CVOpenGLTextureCacheCreate(NULL, 0, [glContext CGLContextObj], [[self pixelFormat] CGLPixelFormatObj], 0, &textureCache);
- if(error != kCVReturnSuccess)
- mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture Cache(%d)\n", error);
-
error = CVOpenGLTextureCacheCreateTextureFromImage(NULL, textureCache, frameBuffers[image_page], 0, &texture);
if(error != kCVReturnSuccess)
mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL texture(%d)\n", error);
More information about the MPlayer-cvslog
mailing list