summaryrefslogtreecommitdiffstats
path: root/src/plugins
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/plugins
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/plugins')
-rw-r--r--src/plugins/multimedia/gstreamer/audio/qgstreameraudiosink.cpp3
-rw-r--r--src/plugins/multimedia/gstreamer/audio/qgstreameraudiosink_p.h1
2 files changed, 3 insertions, 1 deletions
diff --git a/src/plugins/multimedia/gstreamer/audio/qgstreameraudiosink.cpp b/src/plugins/multimedia/gstreamer/audio/qgstreameraudiosink.cpp
index 86a10da66..b66fc6623 100644
--- a/src/plugins/multimedia/gstreamer/audio/qgstreameraudiosink.cpp
+++ b/src/plugins/multimedia/gstreamer/audio/qgstreameraudiosink.cpp
@@ -294,7 +294,7 @@ void QGStreamerAudioSink::resume()
m_appSrc->resume();
gstPipeline.setState(GST_STATE_PLAYING);
- setState(QAudio::ActiveState);
+ setState(m_suspendedInState);
setError(QAudio::NoError);
}
}
@@ -312,6 +312,7 @@ QAudioFormat QGStreamerAudioSink::format() const
void QGStreamerAudioSink::suspend()
{
if (m_deviceState == QAudio::ActiveState || m_deviceState == QAudio::IdleState) {
+ m_suspendedInState = m_deviceState;
setError(QAudio::NoError);
setState(QAudio::SuspendedState);
diff --git a/src/plugins/multimedia/gstreamer/audio/qgstreameraudiosink_p.h b/src/plugins/multimedia/gstreamer/audio/qgstreameraudiosink_p.h
index 07286a3b5..9574960ae 100644
--- a/src/plugins/multimedia/gstreamer/audio/qgstreameraudiosink_p.h
+++ b/src/plugins/multimedia/gstreamer/audio/qgstreameraudiosink_p.h
@@ -86,6 +86,7 @@ private:
QAudioFormat m_format;
QAudio::Error m_errorState = QAudio::NoError;
QAudio::State m_deviceState = QAudio::StoppedState;
+ QAudio::State m_suspendedInState = QAudio::SuspendedState;
bool m_pullMode = true;
bool m_opened = false;
QIODevice *m_audioSource = nullptr;