summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-04-28 02:21:34 +0200
committerNiklas Haas <github-daiK1o@haasn.dev>2023-05-25 16:25:33 +0200
commit3b89a58af77189751944bb8297182ef4f5460db5 (patch)
tree39c3f0e80c7c305b975b93fd39bdb835f8798521 /video/out
parent695b3c51d1c79c42ae6754942c56caa2e08800d8 (diff)
downloadmpv-3b89a58af77189751944bb8297182ef4f5460db5.tar.bz2
mpv-3b89a58af77189751944bb8297182ef4f5460db5.tar.xz
vo_gpu_next: synchronize voctrl_performance_data access
info_callback is fired quite often and from different thread than any accesses to this structure.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/vo_gpu_next.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c
index e614db2fea..ae2a370050 100644
--- a/video/out/vo_gpu_next.c
+++ b/video/out/vo_gpu_next.c
@@ -146,6 +146,7 @@ struct priv {
// Performance data of last frame
struct voctrl_performance_data perf;
+ pthread_mutex_t perf_lock;
bool delayed_peak;
bool inter_preserve;
@@ -758,6 +759,9 @@ static void info_callback(void *priv, const struct pl_render_info *info)
struct mp_pass_perf *perf = &frame->perf[index];
const struct pl_dispatch_info *pass = info->pass;
static_assert(VO_PERF_SAMPLE_COUNT >= MP_ARRAY_SIZE(pass->samples), "");
+
+ pthread_mutex_lock(&p->perf_lock);
+
memcpy(perf->samples, pass->samples, pass->num_samples * sizeof(pass->samples[0]));
perf->count = pass->num_samples;
perf->last = pass->last;
@@ -767,6 +771,8 @@ static void info_callback(void *priv, const struct pl_render_info *info)
talloc_free(frame->desc[index]);
frame->desc[index] = talloc_strdup(p, pass->shader->description);
frame->count = index + 1;
+
+ pthread_mutex_unlock(&p->perf_lock);
}
static void update_options(struct vo *vo)
@@ -1307,7 +1313,9 @@ static int control(struct vo *vo, uint32_t request, void *data)
return VO_TRUE;
case VOCTRL_PERFORMANCE_DATA:
+ pthread_mutex_lock(&p->perf_lock);
*(struct voctrl_performance_data *) data = p->perf;
+ pthread_mutex_unlock(&p->perf_lock);
return true;
case VOCTRL_SCREENSHOT:
@@ -1410,6 +1418,8 @@ static void uninit(struct vo *vo)
pl_renderer_destroy(&p->rr);
+ pthread_mutex_destroy(&p->perf_lock);
+
p->ra_ctx = NULL;
p->pllog = NULL;
p->gpu = NULL;
@@ -1449,6 +1459,7 @@ static int preinit(struct vo *vo)
hwdec_devices_set_loader(vo->hwdec_devs, load_hwdec_api, vo);
ra_hwdec_ctx_init(&p->hwdec_ctx, vo->hwdec_devs, gl_opts->hwdec_interop, false);
pthread_mutex_init(&p->dr_lock, NULL);
+ pthread_mutex_init(&p->perf_lock, NULL);
p->rr = pl_renderer_create(p->pllog, p->gpu);
p->queue = pl_queue_create(p->gpu);