summaryrefslogtreecommitdiffstats
path: root/src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-05-26 13:05:31 +0200
committerLars Knoll <lars.knoll@qt.io>2021-05-26 11:16:05 +0000
commitc773c45899dbdc93b606c9ea82e6f9a29a775258 (patch)
tree82e94f0ffa7a1476bce76cc7b0bfe8e3eec4c7ad /src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp
parentddf481c1bb251f8c4d2fe5e9ad6394c985f94f34 (diff)
Fix a deadlock when changing the video output
Changing the videooutput and deleting the mediaplayer directly afterwards could lead to a deadlock, as the videosink was blocking on a pad and then calling a slot on the main thread using a blocking queued connection. If the main thread was changing the state of the gst pipeline at the same time, this could lead to a deadlock. Avoid it by pausing the pipeline before changing the video output. Change-Id: I0d0cbad0ab97a4eb83dd3c66c664c01de3b0ea90 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp')
-rw-r--r--src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp b/src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp
index f9bf9f6c2..982cdfc9c 100644
--- a/src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp
+++ b/src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp
@@ -80,7 +80,12 @@ void QGstreamerVideoOutput::setVideoSink(QVideoSink *sink)
if (m_videoWindow) {
connect(m_videoWindow, SIGNAL(sinkChanged()), this, SLOT(sinkChanged()));
}
+ auto state = gstPipeline.state();
+ if (state == GST_STATE_PLAYING)
+ gstPipeline.setStateSync(GST_STATE_PAUSED);
sinkChanged();
+ if (state == GST_STATE_PLAYING)
+ gstPipeline.setState(GST_STATE_PLAYING);
}
void QGstreamerVideoOutput::setPipeline(const QGstPipeline &pipeline)