[MPlayer-dev-eng] [PATCH] error checking for lavc stats_file writing

Eric Lammerts eric at lammerts.org
Sat Aug 31 13:40:17 CEST 2002


Hi,
this patch adds error checking to lavc's stats_file writing.

Eric
-------------- next part --------------
Index: libmpcodecs/ve_lavc.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ve_lavc.c,v
retrieving revision 1.27
diff -u -r1.27 ve_lavc.c
--- libmpcodecs/ve_lavc.c	30 Aug 2002 00:38:42 -0000	1.27
+++ libmpcodecs/ve_lavc.c	31 Aug 2002 11:52:02 -0000
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
 
 #include "../config.h"
 
@@ -428,8 +429,14 @@
     
 #if LIBAVCODEC_BUILD >= 4620
     /* store stats if there are any */
-    if(lavc_venc_context.stats_out && stats_file) 
+    if(lavc_venc_context.stats_out && stats_file) {
         fprintf(stats_file, "%s", lavc_venc_context.stats_out);
+        if(ferror(stats_file)) {
+            mp_msg(MSGT_MENCODER,MSGL_ERR,"2pass failed: filename=%s error=%s\n",
+                passtmpfile, strerror(errno));
+            exit(1);
+        }
+    }
 #endif
 }
 
@@ -437,7 +444,13 @@
     avcodec_close(&lavc_venc_context);
 
 #if LIBAVCODEC_BUILD >= 4620
-    if(stats_file) fclose(stats_file);
+    if(stats_file) {
+        if(fclose(stats_file) != 0) {
+            mp_msg(MSGT_MENCODER,MSGL_ERR,"2pass failed: filename=%s error=%s\n",
+                passtmpfile, strerror(errno));
+            exit(1);
+        }
+    }
     
     /* free rc_override */
     if(lavc_venc_context.rc_override) free(lavc_venc_context.rc_override);


More information about the MPlayer-dev-eng mailing list