mirror of https://github.com/mpv-player/mpv
stream, demux_lavf: minor cleanup for stream size code
This commit is contained in:
parent
ddffcce678
commit
efaa73cc73
|
@ -112,9 +112,7 @@ static int64_t mp_seek(void *opaque, int64_t pos, int whence)
|
||||||
else if (whence == SEEK_SET)
|
else if (whence == SEEK_SET)
|
||||||
pos += stream->start_pos;
|
pos += stream->start_pos;
|
||||||
else if (whence == AVSEEK_SIZE && stream->end_pos > 0) {
|
else if (whence == AVSEEK_SIZE && stream->end_pos > 0) {
|
||||||
uint64_t size;
|
stream_update_size(stream);
|
||||||
if (stream_control(stream, STREAM_CTRL_GET_SIZE, &size) == STREAM_OK)
|
|
||||||
return size;
|
|
||||||
return stream->end_pos - stream->start_pos;
|
return stream->end_pos - stream->start_pos;
|
||||||
} else
|
} else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -476,6 +476,15 @@ int stream_control(stream_t *s, int cmd, void *arg){
|
||||||
return s->control(s, cmd, arg);
|
return s->control(s, cmd, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stream_update_size(stream_t *s)
|
||||||
|
{
|
||||||
|
uint64_t size;
|
||||||
|
if (stream_control(s, STREAM_CTRL_GET_SIZE, &size) == STREAM_OK) {
|
||||||
|
if (size > s->end_pos)
|
||||||
|
s->end_pos = size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stream_t* new_memory_stream(unsigned char* data,int len){
|
stream_t* new_memory_stream(unsigned char* data,int len){
|
||||||
stream_t *s;
|
stream_t *s;
|
||||||
|
|
||||||
|
|
|
@ -349,6 +349,7 @@ struct bstr stream_read_complete(struct stream *s, void *talloc_ctx,
|
||||||
int max_size, int padding_bytes);
|
int max_size, int padding_bytes);
|
||||||
void stream_reset(stream_t *s);
|
void stream_reset(stream_t *s);
|
||||||
int stream_control(stream_t *s, int cmd, void *arg);
|
int stream_control(stream_t *s, int cmd, void *arg);
|
||||||
|
void stream_update_size(stream_t *s);
|
||||||
stream_t* new_stream(int fd,int type);
|
stream_t* new_stream(int fd,int type);
|
||||||
void free_stream(stream_t *s);
|
void free_stream(stream_t *s);
|
||||||
stream_t* new_memory_stream(unsigned char* data,int len);
|
stream_t* new_memory_stream(unsigned char* data,int len);
|
||||||
|
|
Loading…
Reference in New Issue