summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-02-04 14:46:03 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-02-06 10:47:28 +0100
commit0220951e712322e4e80253431a322317063e104a (patch)
tree453deee52af357153739e4b66348861a4e3f179e /src/multimedia/audio
parent75d9b447e4887448265313a3a1f94ce87e9cc026 (diff)
Fix behavior of QAudioSink::resume in push mode
Up to now, a QAudioSink in push mode (ie. started without a QIODevice, but returning a QIODevice buffer that the client has to push data into) transitioned to IdleState when resuming after a suspend, even if there was still data in the buffer or device to play. This resulted in the sink playing audio even though it was in IdleState, and the client not getting notified when the audio data was actually drained (as the stateChanged signal did not get emitted again). Fix this by storing the state in which the sink gets suspended, and restore to that state when resuming. If the sink then runs into an underrun because not enough data is available in the push-buffer, then it will transition to IdleState with UnderrunError later. Implement this consistently in all platform implementations, adjust the test, which previously verified that a push-sink transitions to IdleState when resuming, and change the documentation accordingly. [ChangeLog][QtMutimedia][QAudioSink] Calling QAudioSink::resume() now returns the sink to the state it had when QAudioSink::suspend() was called, no matter whether the sink operates in pull or push mode. Pick-to: 6.5 Change-Id: If0c7fe8629627de814276d629d825e469c998d2d Reviewed-by: Lars Knoll <lars@knoll.priv.no> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
Diffstat (limited to 'src/multimedia/audio')
-rw-r--r--src/multimedia/audio/qaudiosink.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/multimedia/audio/qaudiosink.cpp b/src/multimedia/audio/qaudiosink.cpp
index 5f38bbc98..47d522d2c 100644
--- a/src/multimedia/audio/qaudiosink.cpp
+++ b/src/multimedia/audio/qaudiosink.cpp
@@ -203,10 +203,9 @@ void QAudioSink::suspend()
/*!
Resumes processing audio data after a suspend().
- Sets error() to QAudio::NoError.
- Sets state() to QAudio::ActiveState if you previously called start(QIODevice*).
- Sets state() to QAudio::IdleState if you previously called start().
- emits stateChanged() signal.
+ Sets state() to the state the sink had when suspend() was called, and sets
+ error() to QAudioError::NoError. This function does nothing if the audio sink's
+ state is not QAudio::SuspendedState.
*/
void QAudioSink::resume()
{