# HG changeset patch # User reimar # Date 1345319518 0 # Node ID 4d94558867d6da6b0bac810116e6af117b77da73 # Parent 144d16d56b458e5d2c9b8c896ca17afcb019d953 Update endpos each time libavformat asks for it. Fixes playback of still downloading files to not stop before we really reached the end. diff -r 144d16d56b45 -r 4d94558867d6 libmpdemux/demux_lavf.c --- a/libmpdemux/demux_lavf.c Sat Aug 18 19:38:47 2012 +0000 +++ b/libmpdemux/demux_lavf.c Sat Aug 18 19:51:58 2012 +0000 @@ -105,9 +105,13 @@ pos += stream->end_pos; else if(whence == SEEK_SET) pos += stream->start_pos; - else if(whence == AVSEEK_SIZE && stream->end_pos > 0) + else if(whence == AVSEEK_SIZE && stream->end_pos > 0) { + off_t size; + stream_control(stream, STREAM_CTRL_GET_SIZE, &size); + if (size > stream->end_pos) + stream->end_pos = size; return stream->end_pos - stream->start_pos; - else + } else return -1; if(pos<0) diff -r 144d16d56b45 -r 4d94558867d6 stream/cache2.c --- a/stream/cache2.c Sat Aug 18 19:38:47 2012 +0000 +++ b/stream/cache2.c Sat Aug 18 19:51:58 2012 +0000 @@ -91,7 +91,7 @@ // callback stream_t* stream; volatile int control; - volatile unsigned control_uint_arg; + volatile uint64_t control_uint_arg; volatile double control_double_arg; volatile struct stream_lang_req control_lang_arg; volatile int control_res; @@ -264,6 +264,7 @@ static int cache_execute_control(cache_vars_t *s) { double double_res; unsigned uint_res; + unsigned uint64_res; int needs_flush = 0; static unsigned last; int quit = s->control == -2; @@ -316,6 +317,10 @@ s->control_res = s->stream->control(s->stream, s->control, &uint_res); s->control_uint_arg = uint_res; break; + case STREAM_CTRL_GET_SIZE: + s->control_res = s->stream->control(s->stream, s->control, &uint64_res); + s->control_uint_arg = uint64_res; + break; case STREAM_CTRL_GET_LANG: s->control_res = s->stream->control(s->stream, s->control, (void *)&s->control_lang_arg); break; @@ -640,6 +645,7 @@ case STREAM_CTRL_GET_ASPECT_RATIO: case STREAM_CTRL_GET_NUM_ANGLES: case STREAM_CTRL_GET_ANGLE: + case STREAM_CTRL_GET_SIZE: case -2: s->control = cmd; break; @@ -680,6 +686,9 @@ case STREAM_CTRL_GET_ANGLE: *(unsigned *)arg = s->control_uint_arg; break; + case STREAM_CTRL_GET_SIZE: + *(off_t *)arg = s->control_uint_arg; + break; case STREAM_CTRL_GET_LANG: *(struct stream_lang_req *)arg = s->control_lang_arg; break;