summaryrefslogtreecommitdiffstats
path: root/video/out/vo_vaapi.c
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/out/vo_vaapi.c
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/out/vo_vaapi.c')
-rw-r--r--video/out/vo_vaapi.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/video/out/vo_vaapi.c b/video/out/vo_vaapi.c
index 3c760ac07c..fa23c931c6 100644
--- a/video/out/vo_vaapi.c
+++ b/video/out/vo_vaapi.c
@@ -212,6 +212,8 @@ static bool render_to_screen(struct priv *p, struct mp_image *mpi)
if (surface == VA_INVALID_ID)
return false;
+ va_lock(p->mpvaapi);
+
for (int n = 0; n < MAX_OSD_PARTS; n++) {
struct vaapi_osd_part *part = &p->osd_parts[n];
if (part->active) {
@@ -261,6 +263,8 @@ static bool render_to_screen(struct priv *p, struct mp_image *mpi)
}
}
+ va_unlock(p->mpvaapi);
+
return true;
}
@@ -427,6 +431,8 @@ static void draw_osd(struct vo *vo)
if (!p->osd_format.fourcc)
return;
+ va_lock(p->mpvaapi);
+
struct mp_osd_res vid_res = osd_res_from_image_params(vo->params);
struct mp_osd_res *res;
@@ -439,6 +445,8 @@ static void draw_osd(struct vo *vo)
for (int n = 0; n < MAX_OSD_PARTS; n++)
p->osd_parts[n].active = false;
osd_draw(vo->osd, *res, pts, 0, osd_formats, draw_osd_cb, p);
+
+ va_unlock(p->mpvaapi);
}
static int get_displayattribtype(const char *name)
@@ -495,7 +503,9 @@ static int set_equalizer(struct priv *p, const char *name, int value)
return VO_NOTIMPL;
attr->value = ((value + 100) * r) / 200 + attr->min_value;
+ va_lock(p->mpvaapi);
status = vaSetDisplayAttributes(p->display, attr, 1);
+ va_unlock(p->mpvaapi);
if (!CHECK_VA_STATUS(p, "vaSetDisplayAttributes()"))
return VO_FALSE;
return VO_TRUE;