Mercurial > mplayer.hg
changeset 29573:2b14be337eaf
Fix some of the major memleaks of vo_corevideo with -fixed-vo
author | reimar |
---|---|
date | Tue, 01 Sep 2009 20:09:01 +0000 |
parents | 4890363e713a |
children | 0aa36133f638 |
files | libvo/vo_corevideo.m |
diffstat | 1 files changed, 27 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- 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;