summaryrefslogtreecommitdiffstats
path: root/tests/auto/unit/mockbackend/qmockaudiodecoder.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-06-14 15:42:59 +0200
committerLars Knoll <lars.knoll@qt.io>2021-06-17 23:13:28 +0200
commitaf1182b5e29afa0cd69f929d54da224019707214 (patch)
tree45c04b63af92bc43d7125494284a2347c9ae7dab /tests/auto/unit/mockbackend/qmockaudiodecoder.h
parent0bd8c0a36e8ccff03af7f6990298238455443ec4 (diff)
Fix the QAudioDecoder API
Adjust API after code review. Remove the audioFormat property. QAudioDecoder will now always decode to the native format used in the encoded file. QAudioBuffer will have the correct format set, and it's up to the app to handle this correctly. Remove state() and replace by isDecoding(). Change-Id: I6f2ac375d98b2d7c36aebaa729599f78699b1c7b Reviewed-by: André de la Rocha <andre.rocha@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Doris Verria <doris.verria@qt.io>
Diffstat (limited to 'tests/auto/unit/mockbackend/qmockaudiodecoder.h')
-rw-r--r--tests/auto/unit/mockbackend/qmockaudiodecoder.h32
1 files changed, 4 insertions, 28 deletions
diff --git a/tests/auto/unit/mockbackend/qmockaudiodecoder.h b/tests/auto/unit/mockbackend/qmockaudiodecoder.h
index 24cd98756..a106a83d2 100644
--- a/tests/auto/unit/mockbackend/qmockaudiodecoder.h
+++ b/tests/auto/unit/mockbackend/qmockaudiodecoder.h
@@ -49,7 +49,6 @@ class QMockAudioDecoder : public QPlatformAudioDecoder
public:
QMockAudioDecoder(QAudioDecoder *parent = 0)
: QPlatformAudioDecoder(parent)
- , mState(QAudioDecoder::StoppedState)
, mDevice(0)
, mPosition(-1)
, mSerial(0)
@@ -59,29 +58,11 @@ public:
mFormat.setSampleRate(1000);
}
- QAudioDecoder::State state() const
- {
- return mState;
- }
-
QUrl source() const
{
return mSource;
}
- QAudioFormat audioFormat() const
- {
- return mFormat;
- }
-
- void setAudioFormat(const QAudioFormat &format)
- {
- if (mFormat != format) {
- mFormat = format;
- emit formatChanged(mFormat);
- }
- }
-
void setSource(const QUrl &fileName)
{
mSource = fileName;
@@ -106,10 +87,9 @@ public:
// 5 buffers
void start()
{
- if (mState == QAudioDecoder::StoppedState) {
+ if (!isDecoding()) {
if (!mSource.isEmpty()) {
- mState = QAudioDecoder::DecodingState;
- emit stateChanged(mState);
+ setIsDecoding(true);
emit durationChanged(duration());
QTimer::singleShot(50, this, SLOT(pretendDecode()));
@@ -121,12 +101,11 @@ public:
void stop()
{
- if (mState != QAudioDecoder::StoppedState) {
- mState = QAudioDecoder::StoppedState;
+ if (isDecoding()) {
mSerial = 0;
mPosition = 0;
mBuffers.clear();
- emit stateChanged(mState);
+ setIsDecoding(false);
emit bufferAvailableChanged(false);
}
}
@@ -143,9 +122,7 @@ public:
emit bufferAvailableChanged(false);
if (mBuffers.isEmpty() && mSerial >= MOCK_DECODER_MAX_BUFFERS) {
- mState = QAudioDecoder::StoppedState;
emit finished();
- emit stateChanged(mState);
} else
QTimer::singleShot(50, this, SLOT(pretendDecode()));
}
@@ -189,7 +166,6 @@ private slots:
}
public:
- QAudioDecoder::State mState;
QUrl mSource;
QIODevice *mDevice;
QAudioFormat mFormat;