# HG changeset patch # User reimar # Date 1251835741 0 # Node ID 2b14be337eaf7f097be8e6d3975bbc2a2217b0ee # Parent 4890363e713a64287d5781981a68dc4dff341b2c Fix some of the major memleaks of vo_corevideo with -fixed-vo diff -r 4890363e713a -r 2b14be337eaf libvo/vo_corevideo.m --- a/libvo/vo_corevideo.m Tue Sep 01 16:39:46 2009 +0000 +++ b/libvo/vo_corevideo.m Tue Sep 01 20:09:01 2009 +0000 @@ -134,8 +134,33 @@ aspect_save_screenres(vo_screenwidth, vo_screenheight); } +static void free_file_specific(void) +{ + if(shared_buffer) + { + [mplayerosxProto stop]; + mplayerosxProto = nil; + [mplayerosxProxy release]; + mplayerosxProxy = nil; + + if (munmap(image_data, image_width*image_height*image_bytes) == -1) + mp_msg(MSGT_VO, MSGL_FATAL, "[vo_corevideo] uninit: munmap failed. Error: %s\n", strerror(errno)); + + if (shm_unlink(buffer_name) == -1) + mp_msg(MSGT_VO, MSGL_FATAL, "[vo_corevideo] uninit: shm_unlink failed. Error: %s\n", strerror(errno)); + } else { + free(image_datas[0]); + if (vo_doublebuffering) + free(image_datas[1]); + image_datas[0] = NULL; + image_datas[1] = NULL; + image_data = NULL; + } +} + static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { + free_file_specific(); config_movie_aspect((float)d_width/d_height); vo_dwidth = d_width *= mpGLView->winSizeMult; @@ -293,24 +318,11 @@ static void uninit(void) { - if(shared_buffer) - { - [mplayerosxProto stop]; - mplayerosxProto = nil; - [mplayerosxProxy release]; - mplayerosxProxy = nil; - - if (munmap(image_data, image_width*image_height*image_bytes) == -1) - mp_msg(MSGT_VO, MSGL_FATAL, "[vo_corevideo] uninit: munmap failed. Error: %s\n", strerror(errno)); - - if (shm_unlink(buffer_name) == -1) - mp_msg(MSGT_VO, MSGL_FATAL, "[vo_corevideo] uninit: shm_unlink failed. Error: %s\n", strerror(errno)); - - } - SetSystemUIMode( kUIModeNormal, 0); CGDisplayShowCursor(kCGDirectMainDisplay); + free_file_specific(); + if(mpGLView) { NSAutoreleasePool *finalPool; @@ -320,15 +332,6 @@ [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]; [finalPool release]; } - if (!shared_buffer) - { - free(image_datas[0]); - if (vo_doublebuffering) - free(image_datas[1]); - image_datas[0] = NULL; - image_datas[1] = NULL; - image_data = NULL; - } if (buffer_name) free(buffer_name); buffer_name = NULL;