From 91735c7565ac88117e0bd743d335bf76d6e16e0d Mon Sep 17 00:00:00 2001 From: Mike Melanson Date: Fri, 21 Feb 2003 02:22:15 +0000 Subject: support seeking from the start of the stream (if requested offset >= current offset) CVS patchset: 4227 CVS date: 2003/02/21 02:22:15 --- src/input/input_http.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/input/input_http.c b/src/input/input_http.c index 05919863d..64a2c7045 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -600,8 +600,6 @@ static off_t http_plugin_get_current_pos (input_plugin_t *this_gen){ static off_t http_plugin_seek(input_plugin_t *this_gen, off_t offset, int origin) { http_input_plugin_t *this = (http_input_plugin_t *) this_gen; - /* only realtive forward-seeking is implemented */ - if ((origin == SEEK_CUR) && (offset >= 0)) { for (;((int)offset) - BUFSIZE > 0; offset -= BUFSIZE) { @@ -611,6 +609,21 @@ static off_t http_plugin_seek(input_plugin_t *this_gen, off_t offset, int origin http_plugin_read (this_gen, this->seek_buf, offset); } + if (origin == SEEK_SET) { + + if (offset < this->curpos) + printf ("http: cannot seek back! (%lld > %lld)\n", this->curpos, offset); + else { + offset -= this->curpos; + + for (;((int)offset) - BUFSIZE > 0; offset -= BUFSIZE) { + http_plugin_read (this_gen, this->seek_buf, BUFSIZE); + } + + http_plugin_read (this_gen, this->seek_buf, offset); + } + } + return this->curpos; } -- cgit v1.2.3