mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
avformat/cache: avoid lseek() on reading from the cache if possible
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
ce3551896a
commit
312151bb9a
@ -156,8 +156,12 @@ static int cache_read(URLContext *h, unsigned char *buf, int size)
|
||||
av_assert0(entry->logical_pos <= c->logical_pos);
|
||||
if (in_block_pos < entry->size) {
|
||||
int64_t physical_target = entry->physical_pos + in_block_pos;
|
||||
//FIXME avoid seek if unneeded
|
||||
r = lseek(c->fd, physical_target, SEEK_SET);
|
||||
|
||||
if (c->cache_pos != physical_target) {
|
||||
r = lseek(c->fd, physical_target, SEEK_SET);
|
||||
} else
|
||||
r = c->cache_pos;
|
||||
|
||||
if (r >= 0) {
|
||||
c->cache_pos = r;
|
||||
r = read(c->fd, buf, FFMIN(size, entry->size - in_block_pos));
|
||||
|
Loading…
Reference in New Issue
Block a user