[MPlayer-cvslog] r32497 - trunk/input/input.c

reimar subversion at mplayerhq.hu
Sun Oct 17 10:58:40 CEST 2010


Author: reimar
Date: Sun Oct 17 10:58:40 2010
New Revision: 32497

Log:
Do not fail opening a -input file= file just because stat failed, but try
to call "open" in any case.

Modified:
   trunk/input/input.c

Modified: trunk/input/input.c
==============================================================================
--- trunk/input/input.c	Sun Oct 17 10:49:02 2010	(r32496)
+++ trunk/input/input.c	Sun Oct 17 10:58:40 2010	(r32497)
@@ -1786,15 +1786,17 @@ mp_input_init(void) {
 
   if(in_file) {
     struct stat st;
-    if(stat(in_file,&st))
-      mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantStatFile,in_file,strerror(errno));
-    else {
-      in_file_fd = open(in_file,S_ISFIFO(st.st_mode) ? O_RDWR : O_RDONLY);
+    // use RDWR for FIFOs to ensure they stay open over multiple accesses
+    int mode = O_RDWR;
+    // e.g. on Windows stat may fail for named pipes, trying to open read-only
+    // is a safe choice.
+    if (stat(in_file,&st) || !S_ISFIFO(st.st_mode))
+      mode = O_RDONLY;
+    in_file_fd = open(in_file, mode);
       if(in_file_fd >= 0)
 	mp_input_add_cmd_fd(in_file_fd,1,NULL,(mp_close_func_t)close);
       else
 	mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrCantOpenFile,in_file,strerror(errno));
-    }
   }
 
 }


More information about the MPlayer-cvslog mailing list