Fix some of the major memleaks of vo_corevideo with -fixed-vo

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29615 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2009-09-01 20:09:01 +00:00
parent e8d5289623
commit cb9e32c88c
1 changed files with 27 additions and 24 deletions

View File

@ -134,8 +134,33 @@ static void update_screen_info(void)
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 int query_format(uint32_t format)
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 @@ static void uninit(void)
[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;