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 87b2e02a29..8388a1a1a6 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 }; -stream_t* open_stream_plugin(const stream_info_t* sinfo,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, char *filename, + int mode, struct MPOpts *options, + int *file_format, int *ret, + char **redirected_url) +{ void* arg = NULL; stream_t* s; m_struct_t* desc = (m_struct_t*)sinfo->opts; @@ -159,18 +163,9 @@ stream_t* open_stream_plugin(const stream_info_t* sinfo,char* filename,int mode, 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); @@ -207,7 +202,9 @@ stream_t* open_stream_plugin(const stream_info_t* sinfo,char* filename,int mode, } -stream_t* open_stream_full(char* filename,int mode, char** options, int* file_format) { +stream_t *open_stream_full(char *filename,int mode, struct MPOpts *options, + int* file_format) +{ int i,j,l,r; const stream_info_t* sinfo; stream_t* s; @@ -237,7 +234,7 @@ stream_t* open_stream_full(char* filename,int mode, char** options, int* file_fo 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; @@ -249,7 +246,8 @@ stream_t* open_stream_full(char* filename,int mode, char** options, int* file_fo return NULL; } -stream_t* open_output_stream(char* filename,char** options) { +stream_t *open_output_stream(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"); @@ -374,18 +372,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; } @@ -478,11 +480,14 @@ 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); } |