Module: libav
Branch: master
Commit: 99cf943339a2e5171863c48cd1a73dd43dc243e1

Author:    Steve Lhomme <[email protected]>
Committer: Anton Khirnov <[email protected]>
Date:      Wed Jun 15 09:25:19 2016 +0200

d3d11va: don't keep the context lock while waiting for a frame

also fixes a deadlock found by Денис Кулаков <[email protected]>

Signed-off-by: Anton Khirnov <[email protected]>

---

 libavcodec/dxva2.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index 8b0e686..9157094 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -158,9 +158,15 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, 
AVFrame *frame,
                                                  ff_dxva2_get_surface(frame),
                                                  NULL);
 #endif
-        if (hr == E_PENDING)
-            av_usleep(2000);
-    } while (hr == E_PENDING && ++runs < 50);
+        if (hr != E_PENDING || ++runs > 50)
+            break;
+#if CONFIG_D3D11VA
+        if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
+            if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE)
+                ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
+#endif
+        av_usleep(2000);
+    } while(1);
 
     if (FAILED(hr)) {
         av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%lx\n", hr);

_______________________________________________
libav-commits mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-commits

Reply via email to