summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia/audio')
-rw-r--r--src/multimedia/audio/qsoundeffect.cpp22
-rw-r--r--src/multimedia/audio/qsoundeffect_pulse_p.cpp4
-rw-r--r--src/multimedia/audio/qsoundeffect_qaudio_p.cpp7
3 files changed, 23 insertions, 10 deletions
diff --git a/src/multimedia/audio/qsoundeffect.cpp b/src/multimedia/audio/qsoundeffect.cpp
index 83b28c453..cdf5ab300 100644
--- a/src/multimedia/audio/qsoundeffect.cpp
+++ b/src/multimedia/audio/qsoundeffect.cpp
@@ -184,16 +184,20 @@ void QSoundEffect::setSource(const QUrl &url)
/*!
\qmlproperty int QtMultimedia::SoundEffect::loops
- This property provides a way to control the number of times to repeat the sound on each play().
+ This property holds the number of times the sound is played. A value of 0 or 1 means
+ the sound will be played only once; set to SoundEffect.Infinite to enable infinite looping.
- Set to SoundEffect.Infinite to enable infinite looping.
+ The value can be changed while the sound effect is playing, in which case it will update
+ the remaining loops to the new value.
*/
/*!
\property QSoundEffect::loops
- This property provides a way to control the number of times to repeat the sound on each play().
+ This property holds the number of times the sound is played. A value of 0 or 1 means
+ the sound will be played only once; set to SoundEffect.Infinite to enable infinite looping.
- Set to QSoundEffect::Infinite to enable infinite looping.
+ The value can be changed while the sound effect is playing, in which case it will update
+ the remaining loops to the new value.
*/
/*!
@@ -213,8 +217,14 @@ int QSoundEffect::loopCount() const
*/
/*!
- Set the total number of times to repeat playing this sound effect on each play() call to \a loopCount.
- Pass \c QSoundEffect::Infinite to repeat until stop() is called.
+ Set the total number of times to play this sound effect to \a loopCount.
+
+ Setting the loop count to 0 or 1 means the sound effect will be played only once;
+ pass \c QSoundEffect::Infinite to repeat indefinitely. The loop count can be changed while
+ the sound effect is playing, in which case it will update the remaining loops to
+ the new \a loopCount.
+
+ \sa loopsRemaining()
*/
void QSoundEffect::setLoopCount(int loopCount)
{
diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.cpp b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
index ef09cd90a..570870fc9 100644
--- a/src/multimedia/audio/qsoundeffect_pulse_p.cpp
+++ b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
@@ -516,6 +516,8 @@ void QSoundEffectPrivate::setLoopCount(int loopCount)
if (loopCount == 0)
loopCount = 1;
m_loopCount = loopCount;
+ if (m_playing)
+ setLoopsRemaining(loopCount);
}
qreal QSoundEffectPrivate::volume() const
@@ -647,7 +649,7 @@ void QSoundEffectPrivate::play()
emptyStream();
return;
}
- m_runningCount = m_loopCount;
+ setLoopsRemaining(m_loopCount);
playSample();
}
diff --git a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp
index aed8a7aea..2b4359ccf 100644
--- a/src/multimedia/audio/qsoundeffect_qaudio_p.cpp
+++ b/src/multimedia/audio/qsoundeffect_qaudio_p.cpp
@@ -172,7 +172,8 @@ void QSoundEffectPrivate::setLoopCount(int loopCount)
if (loopCount == 0)
loopCount = 1;
d->m_loopCount = loopCount;
- d->m_runningCount = loopCount;
+ if (d->m_playing)
+ setLoopsRemaining(loopCount);
}
qreal QSoundEffectPrivate::volume() const
@@ -228,7 +229,7 @@ QSoundEffect::Status QSoundEffectPrivate::status() const
void QSoundEffectPrivate::play()
{
d->m_offset = 0;
- d->m_runningCount = d->m_loopCount;
+ setLoopsRemaining(d->m_loopCount);
#ifdef QT_QAUDIO_DEBUG
qDebug() << this << "play";
#endif
@@ -283,7 +284,7 @@ void QSoundEffectPrivate::setPlaying(bool playing)
void QSoundEffectPrivate::setLoopsRemaining(int loopsRemaining)
{
- if (!d->m_runningCount && loopsRemaining)
+ if (d->m_runningCount == loopsRemaining)
return;
#ifdef QT_QAUDIO_DEBUG
qDebug() << this << "setLoopsRemaining " << loopsRemaining;