diff options
author | Christian Strømme <christian.stromme@digia.com> | 2014-08-12 16:46:50 +0200 |
---|---|---|
committer | Christian Stromme <christian.stromme@digia.com> | 2014-08-25 16:33:16 +0200 |
commit | fb35f025e320ef1639adf9a5d7bee73faa44e442 (patch) | |
tree | b5dfbb8c756d449daee332e64d8c741379481306 /src/plugins/opensles | |
parent | 18e665b5a611823de13159bbaacd2134e6727180 (diff) | |
download | qtmultimedia-fb35f025e320ef1639adf9a5d7bee73faa44e442.tar.gz |
OpenSL: Fix QAudioOutput::setNotifyInterval().
It was not possible to change the notify interval after calling
start().
Task-number: QTBUG-40208
Change-Id: I82a626003e3bdfe7b7fc88b2f97da492c788877e
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
Diffstat (limited to 'src/plugins/opensles')
-rw-r--r-- | src/plugins/opensles/qopenslesaudiooutput.cpp | 36 | ||||
-rw-r--r-- | src/plugins/opensles/qopenslesaudiooutput.h | 1 |
2 files changed, 32 insertions, 5 deletions
diff --git a/src/plugins/opensles/qopenslesaudiooutput.cpp b/src/plugins/opensles/qopenslesaudiooutput.cpp index 49bea0b36..9c62852de 100644 --- a/src/plugins/opensles/qopenslesaudiooutput.cpp +++ b/src/plugins/opensles/qopenslesaudiooutput.cpp @@ -78,7 +78,8 @@ QOpenSLESAudioOutput::QOpenSLESAudioOutput(const QByteArray &device) m_periodSize(0), m_elapsedTime(0), m_processedBytes(0), - m_availableBuffers(BUFFER_COUNT) + m_availableBuffers(BUFFER_COUNT), + m_eventMask(SL_PLAYEVENT_HEADATEND) { #ifndef ANDROID m_streamType = -1; @@ -198,7 +199,33 @@ int QOpenSLESAudioOutput::bufferSize() const void QOpenSLESAudioOutput::setNotifyInterval(int ms) { - m_notifyInterval = ms > 0 ? ms : 0; + const int newInterval = ms > 0 ? ms : 0; + + if (newInterval == m_notifyInterval) + return; + + const SLuint32 newEvenMask = newInterval == 0 ? m_eventMask & ~SL_PLAYEVENT_HEADATNEWPOS + : m_eventMask & SL_PLAYEVENT_HEADATNEWPOS; + + if (m_state == QAudio::StoppedState) { + m_eventMask = newEvenMask; + m_notifyInterval = newInterval; + return; + } + + if (newEvenMask != m_eventMask + && SL_RESULT_SUCCESS != (*m_playItf)->SetCallbackEventsMask(m_playItf, newEvenMask)) { + return; + } + + m_eventMask = newEvenMask; + + if (newInterval && SL_RESULT_SUCCESS != (*m_playItf)->SetPositionUpdatePeriod(m_playItf, + newInterval)) { + return; + } + + m_notifyInterval = newInterval; } int QOpenSLESAudioOutput::notifyInterval() const @@ -488,13 +515,12 @@ bool QOpenSLESAudioOutput::preparePlayer() return false; } - SLuint32 mask = SL_PLAYEVENT_HEADATEND; if (m_notifyInterval && SL_RESULT_SUCCESS == (*m_playItf)->SetPositionUpdatePeriod(m_playItf, m_notifyInterval)) { - mask |= SL_PLAYEVENT_HEADATNEWPOS; + m_eventMask |= SL_PLAYEVENT_HEADATNEWPOS; } - if (SL_RESULT_SUCCESS != (*m_playItf)->SetCallbackEventsMask(m_playItf, mask)) { + if (SL_RESULT_SUCCESS != (*m_playItf)->SetCallbackEventsMask(m_playItf, m_eventMask)) { setError(QAudio::FatalError); return false; } diff --git a/src/plugins/opensles/qopenslesaudiooutput.h b/src/plugins/opensles/qopenslesaudiooutput.h index b0f01fa22..16cbc50d0 100644 --- a/src/plugins/opensles/qopenslesaudiooutput.h +++ b/src/plugins/opensles/qopenslesaudiooutput.h @@ -120,6 +120,7 @@ private: qint64 m_elapsedTime; qint64 m_processedBytes; QAtomicInt m_availableBuffers; + SLuint32 m_eventMask; qint32 m_streamType; QTime m_clockStamp; |