mirror of
https://github.com/mpv-player/mpv
synced 2024-12-21 22:30:22 +00:00
cache_file: fix operation if stream size is unknown
Happens when playing from a pipe. Note that seeking forward doesn't work. It would be possible to create a workaround for that by reading and skipping data until the target position is reached (and writing the skipped data into the cache file), but I'm not sure about that. Fixes #928. CC: @mpv-player/stable
This commit is contained in:
parent
1e8b98af73
commit
64e3b07a9d
@ -68,7 +68,7 @@ static int fill_buffer(stream_t *s, char *buffer, int max_len)
|
||||
if (s->pos >= p->size - BLOCK_SIZE) {
|
||||
int64_t new_size = -1;
|
||||
stream_control(s, STREAM_CTRL_GET_SIZE, &new_size);
|
||||
if (new_size != p->size)
|
||||
if (p->size >= 0 && new_size != p->size)
|
||||
set_bit(p, BLOCK_ALIGN(p->size), 0);
|
||||
p->size = MPMIN(p->max_size, new_size);
|
||||
}
|
||||
@ -96,7 +96,8 @@ static int fill_buffer(stream_t *s, char *buffer, int max_len)
|
||||
// align/limit to blocks
|
||||
max_len = MPMIN(max_len, BLOCK_SIZE - (s->pos % BLOCK_SIZE));
|
||||
// Limit to max. known file size
|
||||
max_len = MPMIN(max_len, p->size - s->pos);
|
||||
if (p->size >= 0)
|
||||
max_len = MPMIN(max_len, p->size - s->pos);
|
||||
return fread(buffer, 1, max_len, p->cache_file);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user