d3d11videosink: fix race conditions in win32 window
authorAleksandr Slobodeniuk <aslobodeniuk@fluendo.com>
Mon, 27 Mar 2023 07:20:27 +0000 (09:20 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 14 Apr 2023 02:09:07 +0000 (02:09 +0000)
commit936000f04e9be56d162de5708af8ad9557997b1d
tree1b2786bc94b10faf9b4634c277c0060574c42346
parentfec6b6e9f09058e9c7f7492df16ff1545a08a477
d3d11videosink: fix race conditions in win32 window

One race condition is the fact that the window object
can be destroyed while running some routine in the UI
thread (such as resizing). To avoid that situation we make
UI thread hold a reference on the window object while it's
running.
Other probpematic case is when the window handle is reused:
if we stop and start the pipeline very fast,
so the sink creates a new window object that is going to use
the same window handle as the previous one.
And finally the case when the pipeline is stopped immediatelly
right after starting, this one is also handled in this commit.

NOTE: a unit test that reproduces this cases have been added
in the previous commit.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4417>
subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videosink.cpp
subprojects/gst-plugins-bad/sys/d3d11/gstd3d11window_win32.cpp