summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-05-11 15:49:03 +0200
committerLars Knoll <lars.knoll@qt.io>2021-05-17 10:34:08 +0000
commit718d25264419afd72c1d6ae7d4c335da286b216d (patch)
tree4de50ba2667641e4468365ee0f192520a63e6ab7 /tests
parent65d06e5445519e7b8094460e6d1d7983fa8cbaee (diff)
Cleanup the audio decoder architecture
QPlatformAudioDecoder should not be a QObject, instead just have a pointer back to the front-end class. The backend is now also properly owned by the frontend. Get rid of QAudioDecoderPrivate, we don't need it anymore. Fix the audiodecoderbackend autotest and the audiodecoder example. Change-Id: Id9a3368788b5398f37b77be819e8f12947ba045f Reviewed-by: André de la Rocha <andre.rocha@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp17
-rw-r--r--tests/auto/unit/mockbackend/qmockaudiodecoder.h2
-rw-r--r--tests/auto/unit/mockbackend/qmockintegration.cpp4
-rw-r--r--tests/auto/unit/mockbackend/qmockintegration_p.h2
4 files changed, 14 insertions, 11 deletions
diff --git a/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp b/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp
index a59bd1701..b3ccb0a10 100644
--- a/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp
+++ b/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp
@@ -107,10 +107,11 @@ void tst_QAudioDecoderBackend::fileTest()
// Test local file
QFileInfo fileInfo(QFINDTESTDATA(TEST_FILE_NAME));
- d.setSource(fileInfo.absoluteFilePath());
+ QUrl url = QUrl::fromLocalFile(fileInfo.absoluteFilePath());
+ d.setSource(url);
QVERIFY(d.state() == QAudioDecoder::StoppedState);
QVERIFY(!d.bufferAvailable());
- QCOMPARE(d.source(), fileInfo.absoluteFilePath());
+ QCOMPARE(d.source(), url);
QSignalSpy readySpy(&d, SIGNAL(bufferReady()));
QSignalSpy bufferChangedSpy(&d, SIGNAL(bufferAvailableChanged(bool)));
@@ -284,10 +285,11 @@ void tst_QAudioDecoderBackend::unsupportedFileTest()
// Test local file
QFileInfo fileInfo(QFINDTESTDATA(TEST_UNSUPPORTED_FILE_NAME));
- d.setSource(fileInfo.absoluteFilePath());
+ QUrl url = QUrl::fromLocalFile(fileInfo.absoluteFilePath());
+ d.setSource(url);
QVERIFY(d.state() == QAudioDecoder::StoppedState);
QVERIFY(!d.bufferAvailable());
- QCOMPARE(d.source(), fileInfo.absoluteFilePath());
+ QCOMPARE(d.source(), url);
QSignalSpy readySpy(&d, SIGNAL(bufferReady()));
QSignalSpy bufferChangedSpy(&d, SIGNAL(bufferAvailableChanged(bool)));
@@ -357,15 +359,16 @@ void tst_QAudioDecoderBackend::corruptedFileTest()
QVERIFY(d.state() == QAudioDecoder::StoppedState);
QVERIFY(d.bufferAvailable() == false);
- QCOMPARE(d.source(), QString(""));
+ QCOMPARE(d.source(), QUrl());
QVERIFY(d.audioFormat() == QAudioFormat());
// Test local file
QFileInfo fileInfo(QFINDTESTDATA(TEST_CORRUPTED_FILE_NAME));
- d.setSource(fileInfo.absoluteFilePath());
+ QUrl url = QUrl::fromLocalFile(fileInfo.absoluteFilePath());
+ d.setSource(url);
QVERIFY(d.state() == QAudioDecoder::StoppedState);
QVERIFY(!d.bufferAvailable());
- QCOMPARE(d.source(), fileInfo.absoluteFilePath());
+ QCOMPARE(d.source(), url);
QSignalSpy readySpy(&d, SIGNAL(bufferReady()));
QSignalSpy bufferChangedSpy(&d, SIGNAL(bufferAvailableChanged(bool)));
diff --git a/tests/auto/unit/mockbackend/qmockaudiodecoder.h b/tests/auto/unit/mockbackend/qmockaudiodecoder.h
index 1e1dca514..24cd98756 100644
--- a/tests/auto/unit/mockbackend/qmockaudiodecoder.h
+++ b/tests/auto/unit/mockbackend/qmockaudiodecoder.h
@@ -47,7 +47,7 @@ class QMockAudioDecoder : public QPlatformAudioDecoder
Q_OBJECT
public:
- QMockAudioDecoder(QObject *parent = 0)
+ QMockAudioDecoder(QAudioDecoder *parent = 0)
: QPlatformAudioDecoder(parent)
, mState(QAudioDecoder::StoppedState)
, mDevice(0)
diff --git a/tests/auto/unit/mockbackend/qmockintegration.cpp b/tests/auto/unit/mockbackend/qmockintegration.cpp
index 698ecfed9..a9135f175 100644
--- a/tests/auto/unit/mockbackend/qmockintegration.cpp
+++ b/tests/auto/unit/mockbackend/qmockintegration.cpp
@@ -66,12 +66,12 @@ QPlatformMediaDevices *QMockIntegration::devices()
return m_devices;
}
-QPlatformAudioDecoder *QMockIntegration::createAudioDecoder()
+QPlatformAudioDecoder *QMockIntegration::createAudioDecoder(QAudioDecoder *decoder)
{
if (m_flags & NoAudioDecoderInterface)
m_lastAudioDecoderControl = nullptr;
else
- m_lastAudioDecoderControl = new QMockAudioDecoder;
+ m_lastAudioDecoderControl = new QMockAudioDecoder(decoder);
return m_lastAudioDecoderControl;
}
diff --git a/tests/auto/unit/mockbackend/qmockintegration_p.h b/tests/auto/unit/mockbackend/qmockintegration_p.h
index 11ca8eccc..d0c14523d 100644
--- a/tests/auto/unit/mockbackend/qmockintegration_p.h
+++ b/tests/auto/unit/mockbackend/qmockintegration_p.h
@@ -71,7 +71,7 @@ public:
QPlatformMediaDevices *devices() override;
QPlatformMediaFormatInfo *formatInfo() override { return nullptr; }
- QPlatformAudioDecoder *createAudioDecoder() override;
+ QPlatformAudioDecoder *createAudioDecoder(QAudioDecoder *decoder) override;
QPlatformMediaPlayer *createPlayer(QMediaPlayer *) override;
QPlatformCamera *createCamera(QCamera *) override;
QPlatformMediaEncoder *createEncoder(QMediaEncoder *) override;