diff options
author | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-04-25 12:24:15 +0200 |
---|---|---|
committer | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-05-14 07:55:09 +0000 |
commit | 72101558b3afc40ef41132e66ce789b92929e911 (patch) | |
tree | 49cb0aed2d8e380cf014e8af4b1ccaddb4cb0bbb | |
parent | c4de056a6aa44567cdbf2ce91a464e597ad4af8f (diff) |
Gstreamer: Fix deadlock when state is requested in ASYNC mode
When new media is set to the player, updating of "show-preroll-frame" property from the video sink
is also requested:
g_object_set(G_OBJECT(m_videoSink), "show-preroll-frame", value, NULL);
This produces emitting of a signal:
g_signal_connect(G_OBJECT(sink), "notify::show-preroll-frame", G_CALLBACK(handleShowPrerollChange), sink);
Inside handleShowPrerollChange() the state of the video sink is requested with infinite timeout:
gst_element_get_state(GST_ELEMENT(sink), &state, NULL, GST_CLOCK_TIME_NONE);
In case if the video sink performed an ASYNC state change,
means changing of the state is pending and need to wait,
this function will block up for infinite timeout.
But probably changing of the state is requested (and should be performed) on the same thread
where it is waiting for this change, it produces a deadlock.
Changing timeout to 10ms to avoid this block.
Fixes: QTBUG-72468
Change-Id: I06235ccfb8f76423f65ed192d5e8de6e60723e72
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
-rw-r--r-- | src/gsttools/qgstvideorenderersink.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/gsttools/qgstvideorenderersink.cpp b/src/gsttools/qgstvideorenderersink.cpp index 09fdd42a6..c3a7a5988 100644 --- a/src/gsttools/qgstvideorenderersink.cpp +++ b/src/gsttools/qgstvideorenderersink.cpp @@ -516,7 +516,8 @@ void QGstVideoRendererSink::handleShowPrerollChange(GObject *o, GParamSpec *p, g if (!showPrerollFrame) { GstState state = GST_STATE_VOID_PENDING; - gst_element_get_state(GST_ELEMENT(sink), &state, NULL, GST_CLOCK_TIME_NONE); + GstClockTime timeout = 10000000; // 10 ms + gst_element_get_state(GST_ELEMENT(sink), &state, NULL, timeout); // show-preroll-frame being set to 'false' while in GST_STATE_PAUSED means // the QMediaPlayer was stopped from the paused state. // We need to flush the current frame. |