mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 15:45:42 +08:00
[Notification] Make sure no sound is stopped in QTimer::singleShot which is no longer playing
This commit is contained in:
committed by
Mat Sutcliffe
parent
3a4f114308
commit
72334af1e8
@@ -32,6 +32,7 @@ namespace BlackSound
|
|||||||
{
|
{
|
||||||
if (!m_playingEffect && effect->isLoaded() && !effect->isPlaying())
|
if (!m_playingEffect && effect->isLoaded() && !effect->isPlaying())
|
||||||
{
|
{
|
||||||
|
const int currentEffect = ++m_playingEffectCounter;
|
||||||
const qreal v = volume / 100.0f;
|
const qreal v = volume / 100.0f;
|
||||||
m_playingEffect = effect;
|
m_playingEffect = effect;
|
||||||
effect->setVolume(v); // 0..1
|
effect->setVolume(v); // 0..1
|
||||||
@@ -48,6 +49,7 @@ namespace BlackSound
|
|||||||
QTimer::singleShot(3000, effect, [ = ]
|
QTimer::singleShot(3000, effect, [ = ]
|
||||||
{
|
{
|
||||||
if (!myself || !m_playingEffect) { return; }
|
if (!myself || !m_playingEffect) { return; }
|
||||||
|
if (currentEffect != m_playingEffectCounter) { return; }
|
||||||
m_playingEffect->stop();
|
m_playingEffect->stop();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ namespace BlackSound
|
|||||||
QHash<BlackMisc::Audio::CNotificationSounds::NotificationFlag, QSoundEffect *> m_effects;
|
QHash<BlackMisc::Audio::CNotificationSounds::NotificationFlag, QSoundEffect *> m_effects;
|
||||||
QString m_directory;
|
QString m_directory;
|
||||||
QPointer<QSoundEffect> m_playingEffect;
|
QPointer<QSoundEffect> m_playingEffect;
|
||||||
|
int m_playingEffectCounter = 0;
|
||||||
|
|
||||||
//! Playing of effect has been changed
|
//! Playing of effect has been changed
|
||||||
void onPlayingChanged();
|
void onPlayingChanged();
|
||||||
|
|||||||
Reference in New Issue
Block a user