diff options
author | wm4 <wm4@nowhere> | 2013-08-22 18:21:32 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-08-22 18:33:19 +0200 |
commit | a790f2133bb785e0c48a7c6cdc730c8b7e8287fb (patch) | |
tree | e9b4956bc63f8e8f4afd266cdf0b3a09d44c928a /stream/stream_file.c | |
parent | 28eac7dfb3a1cd67e3349f46c34a9a32465f6e55 (diff) | |
download | mpv-a790f2133bb785e0c48a7c6cdc730c8b7e8287fb.tar.bz2 mpv-a790f2133bb785e0c48a7c6cdc730c8b7e8287fb.tar.xz |
stream: move file forward skipping to common stream implementation
stream_file.c contains some code meant for forward seeking with pipes.
This simply reads data until the seek position is reached. Move this
code to stream.c. This stops stream_file from doing strange things
(messing with stream internals), and removes the code duplication too.
We also make stream_seek_long() use the new skip code. This is shorter
and much easier to follow than the old code, which basically did strange
things.
Diffstat (limited to 'stream/stream_file.c')
-rw-r--r-- | stream/stream_file.c | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/stream/stream_file.c b/stream/stream_file.c index cb8d4e2dbf..a8dcf8fbdb 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -69,26 +69,6 @@ static int seek(stream_t *s, int64_t newpos) return 1; } -static int seek_forward(stream_t *s, int64_t newpos) -{ - if (newpos < s->pos) { - mp_msg(MSGT_STREAM, MSGL_INFO, - "Cannot seek backward in linear streams!\n"); - return 0; - } - while (s->pos < newpos) { - int len = s->fill_buffer(s, s->buffer, STREAM_BUFFER_SIZE); - if (len <= 0) { // EOF - s->buf_pos = s->buf_len = 0; - break; - } - s->buf_pos = 0; - s->buf_len = len; - s->pos += len; - } - return 1; -} - static int control(stream_t *s, int cmd, void *arg) { struct priv *p = s->priv; @@ -192,10 +172,8 @@ static int open_f(stream_t *stream, int mode) len = -1; #endif stream->type = STREAMTYPE_FILE; - if (len == -1 && mode == STREAM_READ) { - stream->seek = seek_forward; - stream->flags = MP_STREAM_SEEK_FW; - } else if (len >= 0) { + stream->flags = MP_STREAM_FAST_SKIPPING; + if (len >= 0) { stream->seek = seek; stream->end_pos = len; } |