CoreAudio: fix QAudioOutput state after resume().

In push mode, the state must be IdleState after resume(), and only
change to ActiveState once it receives some data.

Task-number: QTBUG-50390
Change-Id: I4a38aa84a55e90d7a2db3e1d504674b2a688bbde
Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@theqtcompany.com>
This commit is contained in:
Yoann Lopes
2016-01-19 13:58:06 +01:00
parent f97c4aaa86
commit 94c846fb48
2 changed files with 5 additions and 1 deletions

View File

@@ -187,6 +187,7 @@ private:
QTimer *m_intervalTimer;
CoreAudioDeviceInfo *m_audioDeviceInfo;
qreal m_cachedVolume;
bool m_pullMode;
QAudio::Error m_errorCode;
QAudio::State m_stateCode;

View File

@@ -222,6 +222,7 @@ CoreAudioOutput::CoreAudioOutput(const QByteArray &device)
, m_startTime(0)
, m_audioBuffer(0)
, m_cachedVolume(1.0)
, m_pullMode(false)
, m_errorCode(QAudio::NoError)
, m_stateCode(QAudio::StoppedState)
{
@@ -271,6 +272,7 @@ void CoreAudioOutput::start(QIODevice *device)
m_stateCode = QAudio::ActiveState;
// Start
m_pullMode = true;
m_errorCode = QAudio::NoError;
m_totalFrames = 0;
m_startTime = CoreAudioUtils::currentTime();
@@ -296,6 +298,7 @@ QIODevice *CoreAudioOutput::start()
m_stateCode = QAudio::IdleState;
// Start
m_pullMode = false;
m_errorCode = QAudio::NoError;
m_totalFrames = 0;
m_startTime = CoreAudioUtils::currentTime();
@@ -347,7 +350,7 @@ void CoreAudioOutput::resume()
if (m_stateCode == QAudio::SuspendedState) {
audioThreadStart();
m_stateCode = QAudio::ActiveState;
m_stateCode = m_pullMode ? QAudio::ActiveState : QAudio::IdleState;
m_errorCode = QAudio::NoError;
emit stateChanged(m_stateCode);
}