From a843e62ad75e6160b8b406448b8d0a13e2c41dd5 Mon Sep 17 00:00:00 2001 From: lx-s Date: Wed, 3 Aug 2022 10:27:10 +0200 Subject: [PATCH] Added unmute delay when BT device reconnects --- WinMute/MuteControl.cpp | 6 ++++-- WinMute/MuteControl.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/WinMute/MuteControl.cpp b/WinMute/MuteControl.cpp index 540ad89..a00ccd3 100644 --- a/WinMute/MuteControl.cpp +++ b/WinMute/MuteControl.cpp @@ -33,6 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "common.h" +const int BLUETOOTH_RECONNECT_UNMUTE_DELAY = 5000; // Milliseconds + enum MuteType { // With restore MuteTypeWorkstationLock = 0, @@ -131,7 +133,7 @@ void MuteControl::RestoreVolume(bool withDelay) L"Volume restored", L"All endpoints have been restored to their previous configuration"); if (withDelay) { - Sleep(2000); + Sleep(BLUETOOTH_RECONNECT_UNMUTE_DELAY); } winAudio_->RestoreMuteStatus(); } @@ -285,7 +287,7 @@ void MuteControl::NotifyBluetoothConnected(bool connected) WMLog::GetInstance().Write( L"Mute Event: Bluetooth audio device %s", connected ? L"connected" : L"disconnected"); - NotifyRestoreCondition(MuteTypeBluetoothDisconnect, !connected); + NotifyRestoreCondition(MuteTypeBluetoothDisconnect, !connected, true); } void MuteControl::NotifyLogout() diff --git a/WinMute/MuteControl.h b/WinMute/MuteControl.h index 0db0640..9f0c370 100644 --- a/WinMute/MuteControl.h +++ b/WinMute/MuteControl.h @@ -98,7 +98,7 @@ private: const TrayIcon* trayIcon_; - void NotifyRestoreCondition(int type, bool active, bool withDelay); + void NotifyRestoreCondition(int type, bool active, bool withDelay = false); void SaveMuteStatus(); void RestoreVolume(bool withDelay = false); void ShowNotification(const std::wstring& title, const std::wstring& text); -- 2.43.0