Skip to content

Commit 234da20

Browse files
Hack around VDPAU race conditions when compositing.
Once in a while we fail to redirect windows.
1 parent 6c6374f commit 234da20

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

video/out/vo_nouveau.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,26 @@ static void destroy_vdpau_objects(struct vo *vo)
977977

978978
free_video_specific(vo);
979979

980+
// Wait for all queued surfaces to become idle before destroying them.
981+
if (vc->flip_queue != VDP_INVALID_HANDLE) {
982+
VdpTime dummy;
983+
for (int i = 0; i < vc->num_output_surfaces; i++) {
984+
if (vc->output_surfaces[i] != VDP_INVALID_HANDLE) {
985+
vdp_st = vdp->presentation_queue_block_until_surface_idle(
986+
vc->flip_queue, vc->output_surfaces[i], &dummy);
987+
CHECK_VDP_WARNING(vo, "Error waiting for surface idle");
988+
}
989+
}
990+
if (vc->rotation_surface != VDP_INVALID_HANDLE) {
991+
vdp_st = vdp->presentation_queue_block_until_surface_idle(
992+
vc->flip_queue, vc->rotation_surface, &dummy);
993+
CHECK_VDP_WARNING(vo, "Error waiting for rotation surface idle");
994+
}
995+
996+
// Unfortunately VDPAU seems to be inherently racy.
997+
mp_sleep_ns(20000);
998+
}
999+
9801000
if (vc->flip_queue != VDP_INVALID_HANDLE) {
9811001
vdp_st = vdp->presentation_queue_destroy(vc->flip_queue);
9821002
CHECK_VDP_WARNING(vo, "Error when calling vdp_presentation_queue_destroy");

video/out/x11_common.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,8 +897,15 @@ void vo_x11_uninit(struct vo *vo)
897897

898898
set_screensaver(x11, true);
899899

900-
if (x11->window != None && x11->window != x11->rootwin)
900+
if (x11->window != None && x11->window != x11->rootwin) {
901+
// Reset compositor bypass hint before destroying the window to avoid
902+
// leaving compositors in a bad state.
903+
long hint = 0; // 0 = enable compositor
904+
XChangeProperty(x11->display, x11->window, XA(x11, _NET_WM_BYPASS_COMPOSITOR),
905+
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&hint, 1);
906+
XSync(x11->display, False);
901907
XDestroyWindow(x11->display, x11->window);
908+
}
902909
if (x11->xic)
903910
XDestroyIC(x11->xic);
904911
if (x11->colormap != None)

0 commit comments

Comments
 (0)