[MPlayer-cvslog] r29615 - trunk/libvo/vo_corevideo.m

reimar subversion at mplayerhq.hu
Tue Sep 1 22:09:01 CEST 2009


Author: reimar
Date: Tue Sep  1 22:09:01 2009
New Revision: 29615

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

Modified:
   trunk/libvo/vo_corevideo.m

Modified: trunk/libvo/vo_corevideo.m
==============================================================================
--- trunk/libvo/vo_corevideo.m	Tue Sep  1 18:39:46 2009	(r29614)
+++ trunk/libvo/vo_corevideo.m	Tue Sep  1 22:09:01 2009	(r29615)
@@ -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;


More information about the MPlayer-cvslog mailing list