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

Arpi arpi at thot.banki.hu
Thu May 23 22:48:30 CEST 2002


Hi,

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]

if i answer y here:

Reversed (or previously applied) patch detected!  Assume -R? [n] y
Hunk #1 succeeded at 19 with fuzz 2 (offset -399 lines).
Hunk #2 FAILED at 43.
1 out of 2 hunks FAILED -- saving rejects to file libmpdemux/open.c.rej

any ideas?

> 
> 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	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);retu
> rn 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);retur
> n 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){
> 
> 
> _______________________________________________
> MPlayer-dev-eng mailing list
> MPlayer-dev-eng at mplayerhq.hu
> http://mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
> 
> 


A'rpi / Astral & ESP-team

--
Developer of MPlayer, the Movie Player for Linux - http://www.MPlayerHQ.hu



More information about the MPlayer-dev-eng mailing list