[MPlayer-dev-eng] Re: [PATCH] libmpdemux: clean up stream/file detection

Eric Lammerts eric at lammerts.org
Thu May 23 23:28:02 CEST 2002


On Thu, May 23, 2002 at 10:48:30PM +0200, Arpi wrote:
> 
> hmm
> it seems this patch is not applied (by looking at open.c), but patch says:
> 
> root at arpi:/demo/mplayer/main# patch -p0 </demo/mplayer/main/\!P/pipe.diff
> patching file libmpdemux/open.c
> Reversed (or previously applied) patch detected!  Assume -R? [n]

Mmmmm, it appears pine removes trailing spaces. My bad.
Patch gets confused by it. The patch applies cleanly if you use -l.
Here's the correct patch (this time I'm sending it with mutt).

Eric


Index: libmpdemux/open.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/open.c,v
retrieving revision 1.43
diff -u -r1.43 open.c
--- libmpdemux/open.c	2 May 2002 10:32:55 -0000	1.43
+++ libmpdemux/open.c	20 May 2002 11:43:55 -0000
@@ -418,15 +418,6 @@
     return(stream);
   }
 
-//============ Open STDIN ============
-  if(!strcmp(filename,"-")){
-      // read from stdin
-      mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ReadSTDIN);
-      f=0; // 0=stdin
-      stream=new_stream(f,STREAMTYPE_STREAM);
-      return stream;
-  }
-  
 #ifdef STREAMING
   url = url_new(filename);
   if(url) {
@@ -442,22 +433,30 @@
   }
 #endif
 
-//============ Open plain FILE ============
-       f=open(filename,O_RDONLY);
-       if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);return NULL; }
-       len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET);
-       if (len == -1)
-	 perror("Error: lseek failed to obtain video file size");
-       else
+//============ Open STDIN or plain FILE ============
+  if(!strcmp(filename,"-")){
+      // read from stdin
+      mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ReadSTDIN);
+      f=0; // 0=stdin
+  } else {
+      f=open(filename,O_RDONLY);
+      if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_FileNotFound,filename);return NULL; }
+  }
+
+  len=lseek(f,0,SEEK_END);
+  if (len == -1) {
+    stream=new_stream(f,STREAMTYPE_STREAM);
+  } else {
+    lseek(f,0,SEEK_SET);
 #ifdef _LARGEFILE_SOURCE
-	 mp_msg(MSGT_OPEN,MSGL_V,"File size is %lld bytes\n", (long long)len);
+    mp_msg(MSGT_OPEN,MSGL_V,"File size is %lld bytes\n", (long long)len);
 #else
-	 mp_msg(MSGT_OPEN,MSGL_V,"File size is %u bytes\n", (unsigned int)len);
+    mp_msg(MSGT_OPEN,MSGL_V,"File size is %u bytes\n", (unsigned int)len);
 #endif
-       stream=new_stream(f,STREAMTYPE_FILE);
-       stream->end_pos=len;
-       return stream;
-
+    stream=new_stream(f,STREAMTYPE_FILE);
+    stream->end_pos=len;
+  }
+  return stream;
 }
 
 int dvd_parse_chapter_range(struct config *conf, const char *range){



More information about the MPlayer-dev-eng mailing list