summaryrefslogtreecommitdiffstats
path: root/src/plugins/opensles
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-08-28 16:25:20 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-09-01 12:52:51 +0200
commit659f238bbbe040cce1bdf900f8f5500845ca8727 (patch)
tree7990072bf39b2c19df68bcd7615242d08eb8dd2f /src/plugins/opensles
parent80ba1d635dc37963b4c90d776c46774b0349c4f8 (diff)
parent1dba07b602ef8b3fd9333a8afb1db4cbaf9d824e (diff)
Merge remote-tracking branch 'origin/5.3' into 5.4
Conflicts: src/gsttools/qgstreamervideoinputdevicecontrol.cpp src/plugins/gstreamer/camerabin/camerabinserviceplugin.cpp src/plugins/gstreamer/mediacapture/qgstreamercaptureserviceplugin.cpp Change-Id: Ic854589562d2deeaa0ebf75840cb8a2ee32e99de
Diffstat (limited to 'src/plugins/opensles')
-rw-r--r--src/plugins/opensles/qopenslesaudiooutput.cpp36
-rw-r--r--src/plugins/opensles/qopenslesaudiooutput.h1
2 files changed, 32 insertions, 5 deletions
diff --git a/src/plugins/opensles/qopenslesaudiooutput.cpp b/src/plugins/opensles/qopenslesaudiooutput.cpp
index f055796b5..f6583e542 100644
--- a/src/plugins/opensles/qopenslesaudiooutput.cpp
+++ b/src/plugins/opensles/qopenslesaudiooutput.cpp
@@ -70,7 +70,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;
@@ -190,7 +191,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
@@ -480,13 +507,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 60c8cfa86..d466ea64b 100644
--- a/src/plugins/opensles/qopenslesaudiooutput.h
+++ b/src/plugins/opensles/qopenslesaudiooutput.h
@@ -112,6 +112,7 @@ private:
qint64 m_elapsedTime;
qint64 m_processedBytes;
QAtomicInt m_availableBuffers;
+ SLuint32 m_eventMask;
qint32 m_streamType;
QTime m_clockStamp;