1From 13ced625d99b119bde0bb207a6b2ace7098f3880 Mon Sep 17 00:00:00 2001
2From: Michael Forney <mforney@mforney.org>
3Date: Wed, 3 Jul 2019 02:21:16 -0700
4Subject: [PATCH] video/out/gpu: Prevent empty array when no compilers or
5 contexts are enabled
6
7---
8 video/out/gpu/context.c | 11 ++++++-----
9 1 file changed, 6 insertions(+), 5 deletions(-)
10
11diff --git a/video/out/gpu/context.c b/video/out/gpu/context.c
12index 88d4f4232d..5630c81f88 100644
13--- a/video/out/gpu/context.c
14+++ b/video/out/gpu/context.c
15@@ -115,6 +115,7 @@ static const struct ra_ctx_fns *contexts[] = {
16 #if HAVE_DMABUF_WAYLAND
17 &ra_ctx_wldmabuf,
18 #endif
19+ NULL
20 };
21
22 static int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt,
23@@ -122,7 +123,7 @@ static int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt,
24 {
25 mp_info(log, "GPU APIs (contexts):\n");
26 mp_info(log, " auto (autodetect)\n");
27- for (int n = 0; n < MP_ARRAY_SIZE(contexts); n++) {
28+ for (int n = 0; n < MP_ARRAY_SIZE(contexts) - 1; n++) {
29 if (!contexts[n]->hidden)
30 mp_info(log, " %s (%s)\n", contexts[n]->type, contexts[n]->name);
31 }
32@@ -134,7 +135,7 @@ static inline OPT_STRING_VALIDATE_FUNC(ra_ctx_validate_api)
33 struct bstr param = bstr0(*value);
34 if (bstr_equals0(param, "auto"))
35 return 1;
36- for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
37+ for (int i = 0; i < MP_ARRAY_SIZE(contexts) - 1; i++) {
38 if (bstr_equals0(param, contexts[i]->type) && !contexts[i]->hidden)
39 return 1;
40 }
41@@ -146,7 +147,7 @@ static int ra_ctx_context_help(struct mp_log *log, const struct m_option *opt,
42 {
43 mp_info(log, "GPU contexts (APIs):\n");
44 mp_info(log, " auto (autodetect)\n");
45- for (int n = 0; n < MP_ARRAY_SIZE(contexts); n++) {
46+ for (int n = 0; n < MP_ARRAY_SIZE(contexts) - 1; n++) {
47 if (!contexts[n]->hidden)
48 mp_info(log, " %s (%s)\n", contexts[n]->name, contexts[n]->type);
49 }
50@@ -158,7 +159,7 @@ static inline OPT_STRING_VALIDATE_FUNC(ra_ctx_validate_context)
51 struct bstr param = bstr0(*value);
52 if (bstr_equals0(param, "auto"))
53 return 1;
54- for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
55+ for (int i = 0; i < MP_ARRAY_SIZE(contexts) - 1; i++) {
56 if (bstr_equals0(param, contexts[i]->name) && !contexts[i]->hidden)
57 return 1;
58 }
59@@ -182,7 +183,7 @@ struct ra_ctx *ra_ctx_create(struct vo *vo, struct ra_ctx_opts opts)
60 bool old_probing = vo->probing;
61 vo->probing = opts.probing;
62
63- for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) {
64+ for (int i = 0; i < MP_ARRAY_SIZE(contexts) - 1; i++) {
65 if (contexts[i]->hidden)
66 continue;
67 if (!opts.probing && strcmp(contexts[i]->name, opts.context_name) != 0)
68--
692.44.0
70