From c773c45899dbdc93b606c9ea82e6f9a29a775258 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 26 May 2021 13:05:31 +0200 Subject: 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 Reviewed-by: Lars Knoll --- src/imports/multimedia/qmldir | 1 + src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/imports/multimedia/qmldir b/src/imports/multimedia/qmldir index 028587088..387cb3c14 100644 --- a/src/imports/multimedia/qmldir +++ b/src/imports/multimedia/qmldir @@ -4,3 +4,4 @@ classname QMultimediaDeclarativeModule typeinfo plugins.qmltypes prefer :/qt-project.org/imports/QtMultimedia/ Video 5.0 Video.qml + 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) -- cgit v1.2.3