[MPlayer-dev-eng] Re: Re: pre5?
Eric Lammerts
eric at lammerts.org
Fri Jun 7 13:01:12 CEST 2002
On Fri, Jun 07, 2002 at 02:50:46AM +0200, Arpi wrote:
>> It adds error checking to mencoder's .avi writing.
> because i don't like this patch, but don't even refuse as i agree it is
> required :) so i placed into /dev/delay but someone seems to redirected it
> to /dev/null :(
> my problems with this:
> - it checks for every file writes - normally it's ok, error can happen
> everywhere... but, it's far enough to check only at packet writting.
> if it cannot write data chunks, then disk is full. it will give the wanted
> result, with a 10-line patch
Checking the return value of some of the fwrite() calls is not enough,
because the disk can become un-full again any time, and then subsequent
fwrites return success.
The following patch uses ferror() instead (once in the main loop, and once
just before fclose()). The only drawback is that errno is probably gone by
the time we call ferror(), so we can't tell the use what the exact cause of
the write failure was. But this is not really important.
Eric
Index: mencoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/mencoder.c,v
retrieving revision 1.131
diff -u -r1.131 mencoder.c
--- mencoder.c 2 Jun 2002 15:25:52 -0000 1.131
+++ mencoder.c 7 Jun 2002 11:04:50 -0000
@@ -1100,6 +1100,10 @@
}
#endif
+ if(ferror(muxer_f)) {
+ mp_msg(MSGT_MENCODER,MSGL_FATAL,"%s: error writing file.\n", out_filename);
+ mencoder_exit(1, NULL);
+ }
} // while(!eof)
@@ -1124,7 +1128,10 @@
printf("Fixup AVI header...\n");
fseek(muxer_f,0,SEEK_SET);
aviwrite_write_header(muxer,muxer_f); // update header
-fclose(muxer_f);
+if(ferror(muxer_f) || fclose(muxer_f) != 0) {
+ mp_msg(MSGT_MENCODER,MSGL_FATAL,"%s: error writing file.\n", out_filename);
+ mencoder_exit(1, NULL);
+}
if(out_video_codec==VCODEC_FRAMENO && mux_v->timer>100){
printf("Recommended video bitrate for 650MB CD: %d\n",(int)((650*1024*1024-muxer_f_size)/mux_v->timer/125));
More information about the MPlayer-dev-eng
mailing list