summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArtem Dyomin <artem.dyomin@qt.io>2023-04-14 14:25:14 +0200
committerArtem Dyomin <artem.dyomin@qt.io>2023-04-15 15:09:20 +0200
commit1b5249d1186064cd320b36ef6df7128e2e9937f2 (patch)
treeaf78da5dacc2c7f911b5876c88303e86c254423e /tests
parentff7de11d2af36c63f02599d65533b7aefd8eeb41 (diff)
downloadqtmultimedia-1b5249d1186064cd320b36ef6df7128e2e9937f2.tar.gz
Fix threading problems of QVideoSink
- change notification signals should be emitted out of the mutex since it causes a deadlock if the user connects directly and call QVideoSink getters. - currentVideoFrame should be under the mutex since frames assignment is not atomic. - minor clean up with moving to cpp file. Pick-to: 6.5 Change-Id: I07a7e54108c100cd18dc71c88acd93a5622bd2f5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
index a19ff44a8..a3e005929 100644
--- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
+++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
@@ -78,6 +78,7 @@ private slots:
void seekOnLoops();
void changeLoopsOnTheFly();
void lazyLoadVideo();
+ void videoSinkSignals();
private:
QUrl selectVideoFile(const QStringList& mediaCandidates);
@@ -1883,6 +1884,40 @@ void tst_QMediaPlayerBackend::lazyLoadVideo()
QVERIFY(frame.isValid());
}
+void tst_QMediaPlayerBackend::videoSinkSignals()
+{
+ // TODO: come up with custom frames source,
+ // create the test target tst_QVideoSinkBackend,
+ // and move the test there
+
+ if (localVideoFile2.isEmpty())
+ QSKIP("Video format is not supported");
+
+ QVideoSink sink;
+ QMediaPlayer player;
+ player.setVideoSink(&sink);
+
+ std::atomic<int> videoFrameCounter = 0;
+ std::atomic<int> videoSizeCounter = 0;
+
+ connect(&sink, &QVideoSink::videoFrameChanged, [&](const QVideoFrame &frame) {
+ QCOMPARE(sink.videoFrame(), frame);
+ QCOMPARE(sink.videoSize(), frame.size());
+ ++videoFrameCounter;
+ });
+
+ connect(&sink, &QVideoSink::videoSizeChanged, [&]() {
+ QCOMPARE(sink.videoSize(), sink.videoFrame().size());
+ ++videoSizeCounter;
+ });
+
+ player.setSource(localVideoFile2);
+ player.play();
+
+ QTRY_COMPARE_GE(videoFrameCounter, 2);
+ QCOMPARE(videoSizeCounter, 1);
+}
+
QTEST_MAIN(tst_QMediaPlayerBackend)
#include "tst_qmediaplayerbackend.moc"