Removed
Link Here
|
1 |
From 2ecf240b1cd20875991a5b18efafbe799864ff7f Mon Sep 17 00:00:00 2001 |
2 |
From: Mark Thompson <sw@jkqxz.net> |
3 |
Date: Mon, 9 Oct 2017 20:10:26 +0100 |
4 |
Subject: [PATCH] vaapi: Use libva2 message callbacks |
5 |
|
6 |
They are no longer global, so they work vaguely sensibly. |
7 |
--- video/vaapi.c.orig 2017-09-13 01:40:14 UTC |
8 |
+++ video/vaapi.c |
9 |
@@ -112,9 +112,27 @@ static void va_get_formats(struct mp_vaa |
10 |
ctx->image_formats = formats; |
11 |
} |
12 |
|
13 |
-// VA message callbacks are global and do not have a context parameter, so it's |
14 |
-// impossible to know from which VADisplay they originate. Try to route them |
15 |
-// to existing mpv/libmpv instances within this process. |
16 |
+#if VA_CHECK_VERSION(1, 0, 0) |
17 |
+static void va_message_callback(void *context, const char *msg, int mp_level) |
18 |
+{ |
19 |
+ struct mp_vaapi_ctx *res = context; |
20 |
+ mp_msg(res->log, mp_level, "libva: %s", msg); |
21 |
+} |
22 |
+ |
23 |
+static void va_error_callback(void *context, const char *msg) |
24 |
+{ |
25 |
+ va_message_callback(context, msg, MSGL_ERR); |
26 |
+} |
27 |
+ |
28 |
+static void va_info_callback(void *context, const char *msg) |
29 |
+{ |
30 |
+ va_message_callback(context, msg, MSGL_V); |
31 |
+} |
32 |
+#else |
33 |
+// Pre-libva2 VA message callbacks are global and do not have a context |
34 |
+// parameter, so it's impossible to know from which VADisplay they |
35 |
+// originate. Try to route them to existing mpv/libmpv instances within |
36 |
+// this process. |
37 |
static pthread_mutex_t va_log_mutex = PTHREAD_MUTEX_INITIALIZER; |
38 |
static struct mp_vaapi_ctx **va_mpv_clients; |
39 |
static int num_va_mpv_clients; |
40 |
@@ -149,6 +167,7 @@ static void va_info_callback(const char |
41 |
{ |
42 |
va_message_callback(msg, MSGL_V); |
43 |
} |
44 |
+#endif |
45 |
|
46 |
static void open_lavu_vaapi_device(struct mp_vaapi_ctx *ctx) |
47 |
{ |
48 |
@@ -181,6 +200,10 @@ struct mp_vaapi_ctx *va_initialize(VADis |
49 |
}, |
50 |
}; |
51 |
|
52 |
+#if VA_CHECK_VERSION(1, 0, 0) |
53 |
+ vaSetErrorCallback(display, va_error_callback, res); |
54 |
+ vaSetInfoCallback(display, va_info_callback, res); |
55 |
+#else |
56 |
pthread_mutex_lock(&va_log_mutex); |
57 |
MP_TARRAY_APPEND(NULL, va_mpv_clients, num_va_mpv_clients, res); |
58 |
pthread_mutex_unlock(&va_log_mutex); |
59 |
@@ -191,6 +214,7 @@ struct mp_vaapi_ctx *va_initialize(VADis |
60 |
vaSetErrorCallback(va_error_callback); |
61 |
vaSetInfoCallback(va_info_callback); |
62 |
#endif |
63 |
+#endif |
64 |
|
65 |
int major_version, minor_version; |
66 |
int status = vaInitialize(display, &major_version, &minor_version); |
67 |
@@ -231,6 +255,7 @@ void va_destroy(struct mp_vaapi_ctx *ctx |
68 |
if (ctx->destroy_native_ctx) |
69 |
ctx->destroy_native_ctx(ctx->native_ctx); |
70 |
|
71 |
+#if !VA_CHECK_VERSION(1, 0, 0) |
72 |
pthread_mutex_lock(&va_log_mutex); |
73 |
for (int n = 0; n < num_va_mpv_clients; n++) { |
74 |
if (va_mpv_clients[n] == ctx) { |
75 |
@@ -241,6 +266,7 @@ void va_destroy(struct mp_vaapi_ctx *ctx |
76 |
if (num_va_mpv_clients == 0) |
77 |
TA_FREEP(&va_mpv_clients); // avoid triggering leak detectors |
78 |
pthread_mutex_unlock(&va_log_mutex); |
79 |
+#endif |
80 |
|
81 |
talloc_free(ctx); |
82 |
} |