d3d11memory: Protect map and unmap with device lock
authorSeungha Yang <seungha@centricular.com>
Thu, 20 May 2021 09:49:01 +0000 (18:49 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 20 May 2021 11:19:44 +0000 (11:19 +0000)
commit360a1951585a6f41e8ca02ed5dfaf085fd6a104e
tree8ad63e11c7e03ff5605697ca2cd03851950df0ed
parent7a0bc2a91d4e8eb641dd7b468a59ab2c0eaf44cd
d3d11memory: Protect map and unmap with device lock

We should lock memory object with gst_d3d11_device_lock() first
then GST_D3D11_MEMORY_LOCK() need to be used.

One observed deadlock case is that:
- Thread A takes d3d11 device lock
- At the same time, Thread B tries CPU map to d3d11memory which requires
  d3d11 device lock as well, but it's already taken by Thread A.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2267>
gst-libs/gst/d3d11/gstd3d11memory.c