summaryrefslogtreecommitdiffstats
path: root/video/vaapi.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-08-21 22:04:25 +0200
committerwm4 <wm4@nowhere>2014-08-21 22:45:58 +0200
commitf1e78306cb0efab153e2580b45759cdf3c1482f2 (patch)
treede2b0505743291e8c024a74efd1f9f6932f864ba /video/vaapi.h
parent03f97e4caecc55de9d7ac0cde1ee9556a8ef4b6c (diff)
downloadmpv-f1e78306cb0efab153e2580b45759cdf3c1482f2.tar.bz2
mpv-f1e78306cb0efab153e2580b45759cdf3c1482f2.tar.xz
vaapi: try dealing with Intel's braindamaged shit drivers
So talking to a certain Intel dev, it sounded like modern VA-API drivers are reasonable thread-safe. But apparently that is not the case. Not at all. So add approximate locking around all vaapi API calls. The problem appeared once we moved decoding and display to different threads. That means the "vaapi-copy" mode was unaffected, but decoding with vo_vaapi or vo_opengl lead to random crashes. Untested on real Intel hardware. With the vdpau emulation, it seems to work fine - but actually it worked fine even before this commit, because vdpau was written and designed not by morons, but competent people (vdpau is guaranteed to be fully thread-safe). There is some probability that this commit doesn't fix things entirely. One problem is that locking might not be complete. For one, libavcodec _also_ accesses vaapi, so we have to rely on our own guesses how and when lavc uses vaapi (since we disable multithreading when doing hw decoding, our guess should be relatively good, but it's still a lavc implementation detail). One other reason that this commit might not help is Intel's amazing potential to fuckup anything that is good and holy.
Diffstat (limited to 'video/vaapi.h')
-rw-r--r--video/vaapi.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/video/vaapi.h b/video/vaapi.h
index 8a96bb1347..86a9919e27 100644
--- a/video/vaapi.h
+++ b/video/vaapi.h
@@ -3,6 +3,7 @@
#include <stdbool.h>
#include <inttypes.h>
+#include <pthread.h>
#include <va/va.h>
#include <va/va_x11.h>
@@ -79,6 +80,7 @@ struct mp_vaapi_ctx {
struct mp_log *log;
VADisplay display;
struct va_image_formats *image_formats;
+ pthread_mutex_t lock;
};
struct va_image_formats;
@@ -87,6 +89,9 @@ bool check_va_status(struct mp_log *log, VAStatus status, const char *msg);
#define CHECK_VA_STATUS(ctx, msg) check_va_status((ctx)->log, status, msg)
+#define va_lock(ctx) pthread_mutex_lock(&(ctx)->lock)
+#define va_unlock(ctx) pthread_mutex_unlock(&(ctx)->lock)
+
int va_get_colorspace_flag(enum mp_csp csp);
struct mp_vaapi_ctx *va_initialize(VADisplay *display, struct mp_log *log);