[MPlayer-dev-eng] Re: pre5?

Eric Lammerts eric at lammerts.org
Fri Jun 7 00:33:48 CEST 2002


On Thu, Jun 06, 2002 at 09:08:28PM +0200, Arpi wrote:
> Hi,
> 
> i've collected the importamt changes from cvs log, since pre4:

Hi,
the following patch was also not committed. The first time I sent it, it
didn't apply because pine ate some trailing spaces. This one should work.

original message:

Eric Lammerts <eric at lammerts.org> wrote:
: Hello,
: This patch removes the assumption that "-" is always a stream and a
: filename is always a regular file. Instead, lseek() is used to
: determine if it's a file or a stream.

: This makes it possible to
: a) play from a named pipe (fifo)
: b) seek in a movie played with "mplayer - < /some/regular.file"

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	6 Jun 2002 22:41:31 -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