From cb7ba0e7506507f3552e49283e71930a909b2437 Mon Sep 17 00:00:00 2001 From: lx-s Date: Wed, 3 Aug 2022 10:21:50 +0200 Subject: [PATCH] Added delay to mutecontrol --- WinMute/MuteControl.cpp | 9 ++++++--- WinMute/MuteControl.h | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/WinMute/MuteControl.cpp b/WinMute/MuteControl.cpp index ba55e32..eb014cf 100644 --- a/WinMute/MuteControl.cpp +++ b/WinMute/MuteControl.cpp @@ -109,7 +109,7 @@ void MuteControl::SetNotifications(bool enable) notificationsEnabled_ = enable; } -void MuteControl::RestoreVolume() +void MuteControl::RestoreVolume(bool withDelay) { WMLog& log = WMLog::GetInstance(); if (!restoreVolume_) { @@ -129,6 +129,9 @@ void MuteControl::RestoreVolume() ShowNotification( _T("Volume restored"), _T("All endpoints have been restored to their previous configuration")); + if (withDelay) { + Sleep(2000); + } winAudio_->RestoreMuteStatus(); } } @@ -213,7 +216,7 @@ bool MuteControl::GetMuteOnShutdown() return muteConfig_[MuteTypeShutdown].shouldMute; } -void MuteControl::NotifyRestoreCondition(int type, bool active) +void MuteControl::NotifyRestoreCondition(int type, bool active, bool withDelay) { if (active) { SaveMuteStatus(); @@ -229,7 +232,7 @@ void MuteControl::NotifyRestoreCondition(int type, bool active) if (muteConfig_[type].active) { muteConfig_[type].active = false; if (muteConfig_[type].shouldMute) { - RestoreVolume(); + RestoreVolume(withDelay); } } } diff --git a/WinMute/MuteControl.h b/WinMute/MuteControl.h index fd56488..01f4b47 100644 --- a/WinMute/MuteControl.h +++ b/WinMute/MuteControl.h @@ -95,8 +95,8 @@ private: const TrayIcon* trayIcon_; - void NotifyRestoreCondition(int type, bool active); + void NotifyRestoreCondition(int type, bool active, bool withDelay); void SaveMuteStatus(); - void RestoreVolume(); + void RestoreVolume(bool withDelay = false); void ShowNotification(const tstring& title, const tstring& text); }; -- 2.43.0