mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
d3dvideosink: improve concurrency on internal window create/destroy
Remove timeout and rely on condition variable instead to indicate thread start.
This commit is contained in:
parent
adfbce336a
commit
027eb5ef20
1 changed files with 12 additions and 18 deletions
|
@ -2315,20 +2315,21 @@ d3d_internal_window_thread (D3DInternalWindowDat * dat)
|
||||||
g_thread_self ());
|
g_thread_self ());
|
||||||
|
|
||||||
/* Create internal window */
|
/* Create internal window */
|
||||||
g_mutex_lock (&dat->lock);
|
|
||||||
hWnd = _d3d_create_internal_window (sink);
|
hWnd = _d3d_create_internal_window (sink);
|
||||||
|
|
||||||
|
g_mutex_lock (&dat->lock);
|
||||||
if (!hWnd) {
|
if (!hWnd) {
|
||||||
GST_ERROR_OBJECT (sink, "Failed to create internal window");
|
GST_ERROR_OBJECT (sink, "Failed to create internal window");
|
||||||
dat->error = TRUE;
|
dat->error = TRUE;
|
||||||
g_cond_signal (&dat->cond);
|
} else {
|
||||||
g_mutex_unlock (&dat->lock);
|
dat->hWnd = hWnd;
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dat->hWnd = hWnd;
|
|
||||||
g_cond_signal (&dat->cond);
|
g_cond_signal (&dat->cond);
|
||||||
g_mutex_unlock (&dat->lock);
|
g_mutex_unlock (&dat->lock);
|
||||||
|
|
||||||
|
if (dat->error)
|
||||||
|
goto end;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal window message loop
|
* Internal window message loop
|
||||||
*/
|
*/
|
||||||
|
@ -2351,8 +2352,6 @@ d3d_create_internal_window (GstD3DVideoSink * sink)
|
||||||
{
|
{
|
||||||
GThread *thread;
|
GThread *thread;
|
||||||
D3DInternalWindowDat dat;
|
D3DInternalWindowDat dat;
|
||||||
gint64 end_time;
|
|
||||||
gboolean timeout = FALSE;
|
|
||||||
|
|
||||||
dat.sink = sink;
|
dat.sink = sink;
|
||||||
dat.error = FALSE;
|
dat.error = FALSE;
|
||||||
|
@ -2360,30 +2359,25 @@ d3d_create_internal_window (GstD3DVideoSink * sink)
|
||||||
g_mutex_init (&dat.lock);
|
g_mutex_init (&dat.lock);
|
||||||
g_cond_init (&dat.cond);
|
g_cond_init (&dat.cond);
|
||||||
|
|
||||||
g_mutex_lock (&dat.lock);
|
|
||||||
thread =
|
thread =
|
||||||
g_thread_new ("d3dvideosink-window-thread",
|
g_thread_new ("d3dvideosink-window-thread",
|
||||||
(GThreadFunc) d3d_internal_window_thread, &dat);
|
(GThreadFunc) d3d_internal_window_thread, &dat);
|
||||||
if (!thread) {
|
if (!thread) {
|
||||||
g_mutex_unlock (&dat.lock);
|
|
||||||
GST_ERROR ("Failed to created internal window thread");
|
GST_ERROR ("Failed to created internal window thread");
|
||||||
goto clear;
|
goto clear;
|
||||||
}
|
}
|
||||||
|
|
||||||
sink->internal_window_thread = thread;
|
sink->internal_window_thread = thread;
|
||||||
|
|
||||||
end_time = g_get_monotonic_time () + 10 * G_TIME_SPAN_SECOND;
|
/* Wait for window proc loop to start up */
|
||||||
/* Wait 10 seconds for window proc loop to start up */
|
g_mutex_lock (&dat.lock);
|
||||||
while (!dat.error && !dat.hWnd) {
|
while (!dat.error && !dat.hWnd) {
|
||||||
if (!g_cond_wait_until (&dat.cond, &dat.lock, end_time)) {
|
g_cond_wait (&dat.cond, &dat.lock);
|
||||||
timeout = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
g_mutex_unlock (&dat.lock);
|
g_mutex_unlock (&dat.lock);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (sink, "Created window: %p (error: %d, timeout: %d)",
|
GST_DEBUG_OBJECT (sink, "Created window: %p (error: %d)",
|
||||||
dat.hWnd, dat.error, timeout);
|
dat.hWnd, dat.error);
|
||||||
|
|
||||||
clear:
|
clear:
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue