summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-05-16 12:46:29 +0200
committerwm4 <wm4@nowhere>2016-05-16 12:51:26 +0200
commit155857dbe63f9f9e5d417e2b14a8b81e469d6c5c (patch)
treed236e244cb9e32c5e3b294dcee954f48deca19f5 /video
parent0c40eee47940595308d704f9755f653627b20cbd (diff)
downloadmpv-155857dbe63f9f9e5d417e2b14a8b81e469d6c5c.tar.bz2
mpv-155857dbe63f9f9e5d417e2b14a8b81e469d6c5c.tar.xz
vo_opengl: never clear file cache
Make it dynamic and never remove entries from it. For now, this is better than possibly creating dangling pointers all over the place in the gl_user_shader struct. Untested.
Diffstat (limited to 'video')
-rw-r--r--video/out/opengl/video.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 7224e1af22..f7dae25a28 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -259,7 +259,7 @@ struct gl_video {
int last_dither_matrix_size;
float *last_dither_matrix;
- struct cached_file files[10];
+ struct cached_file *files;
int num_files;
struct gl_hwdec *hwdec;
@@ -508,22 +508,14 @@ static struct bstr load_cached_file(struct gl_video *p, const char *path)
return p->files[n].body;
}
// not found -> load it
- if (p->num_files == MP_ARRAY_SIZE(p->files)) {
- // empty cache when it overflows
- for (int n = 0; n < p->num_files; n++) {
- talloc_free(p->files[n].path);
- talloc_free(p->files[n].body.start);
- }
- p->num_files = 0;
- }
struct bstr s = stream_read_file(path, p, p->global, 100000); // 100 kB
if (s.len) {
- struct cached_file *new = &p->files[p->num_files++];
- *new = (struct cached_file) {
+ struct cached_file new = {
.path = talloc_strdup(p, path),
.body = s,
};
- return new->body;
+ MP_TARRAY_APPEND(p, p->files, p->num_files, new);
+ return new.body;
}
return (struct bstr){0};
}