diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-02-20 18:53:07 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-02-20 18:53:07 +0000 |
commit | 9554a844e9daef9a702004957f0d74aabacd8403 (patch) | |
tree | e51c613d728cffe700d8213e75aefe5d81c6b4ae /stream | |
parent | 908f8c91e7bf59ca72d25657403ed35dee7b145e (diff) |
Do not discard stream buffer on eof, instead reuse it to slightly improve
format autodetection with -nocache and non-seekable streams.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30668 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'stream')
-rw-r--r-- | stream/stream.c | 8 | ||||
-rw-r--r-- | stream/stream.h | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/stream/stream.c b/stream/stream.c index 203e2ed291..bcd1f907c3 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -264,7 +264,7 @@ stream_t* open_output_stream(char* filename,char** options) { int stream_fill_buffer(stream_t *s){ int len; - if (/*s->fd == NULL ||*/ s->eof) { s->buf_pos = s->buf_len = 0; return 0; } + if (/*s->fd == NULL ||*/ s->eof) { return 0; } switch(s->type){ case STREAMTYPE_STREAM: #ifdef CONFIG_NETWORK @@ -285,7 +285,7 @@ int stream_fill_buffer(stream_t *s){ default: len= s->fill_buffer ? s->fill_buffer(s,s->buffer,STREAM_BUFFER_SIZE) : 0; } - if(len<=0){ s->eof=1; s->buf_pos=s->buf_len=0; return 0; } + if(len<=0){ s->eof=1; return 0; } s->buf_pos=0; s->buf_len=len; s->pos+=len; @@ -392,8 +392,8 @@ while(stream_fill_buffer(s) > 0 && pos >= 0) { void stream_reset(stream_t *s){ if(s->eof){ - s->pos=0; //ftell(f); -// s->buf_pos=s->buf_len=0; + s->pos=0; + s->buf_pos=s->buf_len=0; s->eof=0; } if(s->control) s->control(s,STREAM_CTRL_RESET,NULL); diff --git a/stream/stream.h b/stream/stream.h index a995b8119f..e281a266f3 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -282,6 +282,8 @@ inline static int stream_seek(stream_t *s,off_t pos){ mp_dbg(MSGT_DEMUX, MSGL_DBG3, "seek to 0x%qX\n",(long long)pos); + if(s->eof) + return 0; if(pos<s->pos){ off_t x=pos-(s->pos-s->buf_len); if(x>=0){ |