Andraz,
As I have been suffering from the consequences of mpeg decoding leak, I am very 
excited to test this when I get home this afternoon.  Thanks!

One question: what is a crush?
scott
 -------------- Original message ----------------------
From: Andraž Tori <[EMAIL PROTECTED]>
> This is a fix for obvious leak when reopening mpeg from index files. 
> 
> Previous fd was not released in all cases. Now it is. 
> 
> This leak also caused crushes due to memory exaustion and creating extreme 
> number of waiting threads eventually... The way it crushed is not completely 
> obvious to me, but now the crush is gone.
> 
> Opening mpeg files that have index is still awfully inefficient, since every 
> file that already has TOC created is opened twice - first time just to read 
> the 
> number of video streams present. This could be done better...
> 
> bye
> andraz
> 


--- Begin Message ---
diff -ru --exclude-from exclude hvirtual-svn/cinelerra/filempeg.C hvirtual-2.1/cinelerra/filempeg.C
--- hvirtual-svn/cinelerra/filempeg.C	2006-10-12 23:17:43.000000000 +0200
+++ hvirtual-2.1/cinelerra/filempeg.C	2007-02-09 13:26:29.000000000 +0100
@@ -523,13 +523,16 @@
 
 	sprintf(ptr, ".toc");
 
-	int need_toc = 1;
+	mpeg3_t *fd_toc;
 
-// Test existing copy of TOC
-	if((fd = mpeg3_open(index_filename, &error)))
-		need_toc = 0;
 
-	if(need_toc)
+// Test existing copy of TOC
+	mpeg3_close(fd);     // Always free old fd
+	if((fd_toc = mpeg3_open(index_filename, &error)))
+	{
+// Just exchange old fd 
+		fd = fd_toc;
+	} else
 	{
 // Create progress window.
 // This gets around the fact that MWindowGUI is locked.
@@ -596,26 +599,10 @@
 			remove(index_filename);
 			return 1;
 		}
-		else
-// Fix date to date of source if success
-		{
-		}
-
-		if(fd) mpeg3_close(fd);
-		fd = 0;
-	}
-
-
 
 // Reopen file from index path instead of asset path.
-	if(!fd)
-	{
 		if(!(fd = mpeg3_open(index_filename, &error)))
-		{
 			return 1;
-		}
-		else
-			return 0;
 	}
 
 	return 0;

--- End Message ---

Reply via email to