diff options
Diffstat (limited to 'stream/stream.c')
-rw-r--r-- | stream/stream.c | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/stream/stream.c b/stream/stream.c index 47d4b9e2a5..0b0cddc6f9 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -49,7 +49,9 @@ //#include "vcd_read_bincue.h" -static int (*stream_check_interrupt_cb)(int time) = NULL; +struct input_ctx; +static int (*stream_check_interrupt_cb)(struct input_ctx *ctx, int time); +static struct input_ctx *stream_check_interrupt_ctx; extern const stream_info_t stream_info_vcd; extern const stream_info_t stream_info_cdda; @@ -140,9 +142,11 @@ static const stream_info_t* const auto_open_streams[] = { NULL }; -static stream_t* open_stream_plugin(const stream_info_t* sinfo, const char* filename, - int mode, char** options, int* file_format, - int* ret, char** redirected_url) +static stream_t *open_stream_plugin(const stream_info_t *sinfo, + const char *filename, + int mode, struct MPOpts *options, + int *file_format, int *ret, + char **redirected_url) { void* arg = NULL; stream_t* s; @@ -160,18 +164,9 @@ static stream_t* open_stream_plugin(const stream_info_t* sinfo, const char* file return NULL; } } - if(options) { - int i; - for(i = 0 ; options[i] != NULL ; i += 2) { - mp_msg(MSGT_OPEN,MSGL_DBG2, "Set stream arg %s=%s\n", - options[i],options[i+1]); - if(!m_struct_set(desc,arg,options[i],options[i+1])) - mp_msg(MSGT_OPEN,MSGL_WARN, "Failed to set stream option %s=%s\n", - options[i],options[i+1]); - } - } } s = new_stream(-2,-2); + s->opts = options; s->url=strdup(filename); s->flags |= mode; *ret = sinfo->open(s,mode,arg,file_format); @@ -208,7 +203,9 @@ static stream_t* open_stream_plugin(const stream_info_t* sinfo, const char* file } -stream_t* open_stream_full(const char* filename,int mode, char** options, int* file_format) { +stream_t *open_stream_full(const char *filename, int mode, + struct MPOpts *options, int *file_format) +{ int i,j,l,r; const stream_info_t* sinfo; stream_t* s; @@ -238,7 +235,7 @@ stream_t* open_stream_full(const char* filename,int mode, char** options, int* f return s; } else if(r != STREAM_UNSUPPORTED) { - mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_FailedToOpen,filename); + mp_tmsg(MSGT_OPEN,MSGL_ERR, "Failed to open %s.\n",filename); return NULL; } break; @@ -250,7 +247,8 @@ stream_t* open_stream_full(const char* filename,int mode, char** options, int* f return NULL; } -stream_t* open_output_stream(const char* filename, char** options) { +stream_t *open_output_stream(const char *filename, struct MPOpts *options) +{ int file_format; //unused if(!filename) { mp_msg(MSGT_OPEN,MSGL_ERR,"open_output_stream(), NULL filename, report this bug\n"); @@ -375,18 +373,22 @@ if(newpos==0 || newpos!=s->pos){ // putchar('%');fflush(stdout); } -while(stream_fill_buffer(s) > 0 && pos >= 0) { +s->eof = 0; // EOF reset when seek succeeds. +while (stream_fill_buffer(s) > 0) { if(pos<=s->buf_len){ s->buf_pos=pos; // byte position in sector return 1; } pos -= s->buf_len; } - -// if(pos==s->buf_len) printf("XXX Seek to last byte of file -> EOF\n"); - - mp_msg(MSGT_STREAM,MSGL_V,"stream_seek: WARNING! Can't seek to 0x%"PRIX64" !\n",(int64_t)(pos+newpos)); - return 0; +// Fill failed, but seek still is a success. +s->pos += pos; +s->buf_pos = 0; +s->buf_len = 0; + +mp_msg(MSGT_STREAM,MSGL_V, + "stream_seek: Seek to/past EOF: no buffer preloaded.\n"); +return 1; } @@ -479,13 +481,16 @@ stream_t* new_ds_stream(demux_stream_t *ds) { return s; } -void stream_set_interrupt_callback(int (*cb)(int)) { +void stream_set_interrupt_callback(int (*cb)(struct input_ctx *, int), + struct input_ctx *ctx) +{ stream_check_interrupt_cb = cb; + stream_check_interrupt_ctx = ctx; } int stream_check_interrupt(int time) { if(!stream_check_interrupt_cb) return 0; - return stream_check_interrupt_cb(time); + return stream_check_interrupt_cb(stream_check_interrupt_ctx, time); } unsigned char* stream_read_line(stream_t *s,unsigned char* mem, int max) { |