]> repos.lx-s.de Git - winmute.git/commitdiff
Reworked connect/disconnect detection logic, when windows scans for new devices
authorlx-s <lx-s@users.noreply.github.com>
Tue, 23 Aug 2022 08:47:59 +0000 (10:47 +0200)
committerlx-s <lx-s@users.noreply.github.com>
Tue, 23 Aug 2022 08:47:59 +0000 (10:47 +0200)
WinMute/BluetoothDetector.cpp

index 317f3a276696ca9b04f3e808e735922f555190d3..232bfeba59494f3c504fad9be20e9f8068a447cc 100644 (file)
@@ -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;
 }