From d9dd49d9170ac3660bfd6b08af4bb29b181fedba Mon Sep 17 00:00:00 2001 From: lx-s Date: Tue, 23 Aug 2022 10:47:59 +0200 Subject: [PATCH] Reworked connect/disconnect detection logic, when windows scans for new devices --- WinMute/BluetoothDetector.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/WinMute/BluetoothDetector.cpp b/WinMute/BluetoothDetector.cpp index 317f3a2..232bfeb 100644 --- a/WinMute/BluetoothDetector.cpp +++ b/WinMute/BluetoothDetector.cpp @@ -162,10 +162,12 @@ BluetoothDetector::BluetoothStatus BluetoothDetector::GetBluetoothStatus( return BluetoothStatus::Unknown; } } - if (inRangeInfo->deviceInfo.flags & BDIF_CONNECTED) { + if ((inRangeInfo->deviceInfo.flags & BDIF_CONNECTED) && !(inRangeInfo->previousDeviceFlags & BDIF_CONNECTED)) { log.Write(L"Bluetooth Audio device \"%S\" connected.", inRangeInfo->deviceInfo.name); return BluetoothStatus::Connected; + } else if (!(inRangeInfo->deviceInfo.flags & BDIF_CONNECTED) && (inRangeInfo->previousDeviceFlags & BDIF_CONNECTED)) { + log.Write(L"Bluetooth Audio device \"%S\" disconnected.", inRangeInfo->deviceInfo.name); + return BluetoothStatus::Disconnected; } - log.Write(L"Bluetooth Audio device \"%S\" disconnected.", inRangeInfo->deviceInfo.name); - return BluetoothStatus::Disconnected; + return BluetoothStatus::Unknown; } -- 2.43.0