mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +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())
|
||||
{
|
||||
const int currentEffect = ++m_playingEffectCounter;
|
||||
const qreal v = volume / 100.0f;
|
||||
m_playingEffect = effect;
|
||||
effect->setVolume(v); // 0..1
|
||||
@@ -48,6 +49,7 @@ namespace BlackSound
|
||||
QTimer::singleShot(3000, effect, [ = ]
|
||||
{
|
||||
if (!myself || !m_playingEffect) { return; }
|
||||
if (currentEffect != m_playingEffectCounter) { return; }
|
||||
m_playingEffect->stop();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace BlackSound
|
||||
QHash<BlackMisc::Audio::CNotificationSounds::NotificationFlag, QSoundEffect *> m_effects;
|
||||
QString m_directory;
|
||||
QPointer<QSoundEffect> m_playingEffect;
|
||||
int m_playingEffectCounter = 0;
|
||||
|
||||
//! Playing of effect has been changed
|
||||
void onPlayingChanged();
|
||||
|
||||
Reference in New Issue
Block a user