summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-09-14 15:46:18 +0200
committerSven Gothel <[email protected]>2022-09-14 15:46:18 +0200
commit011fa250d7de5b3758ed3ab6baecacd5344cb19d (patch)
treeb4bab823af4710715dabf7f77b53143665a08efe
parent511b6fc169544f72ab61b27bbe607979fee7ca97 (diff)
BTAdapter::removeDevicePausingDiscovery(): Drop 'off_thread' argument, always perform off thread BTAdapter::startDiscoveryBackground()
-rw-r--r--api/direct_bt/BTAdapter.hpp5
-rw-r--r--src/direct_bt/BTAdapter.cpp20
2 files changed, 9 insertions, 16 deletions
diff --git a/api/direct_bt/BTAdapter.hpp b/api/direct_bt/BTAdapter.hpp
index 9d6f0da4..a0a52b52 100644
--- a/api/direct_bt/BTAdapter.hpp
+++ b/api/direct_bt/BTAdapter.hpp
@@ -480,7 +480,6 @@ namespace direct_bt {
bool unlockConnectAny() noexcept;
bool addDevicePausingDiscovery(const BTDeviceRef & device) noexcept;
- bool removeDevicePausingDiscovery(const BTDevice & device, const bool off_thread_enable) noexcept;
BTDeviceRef findDevicePausingDiscovery (const EUI48 & address, const BDAddressType & addressType) noexcept;
void clearDevicesPausingDiscovery() noexcept;
bool hasDevicesPausingDiscovery() noexcept;
@@ -1097,9 +1096,7 @@ namespace direct_bt {
* @return true if this was the last BTDevice, re-enabling discovery. Otherwise false.
* @since 2.5.1
*/
- bool removeDevicePausingDiscovery(const BTDevice & device) noexcept {
- return removeDevicePausingDiscovery(device, false /* off_thread_enable */);
- }
+ bool removeDevicePausingDiscovery(const BTDevice & device) noexcept;
/**
* Returns the current meta discovering ScanType. It can be modified through startDiscovery(..) and stopDiscovery().
diff --git a/src/direct_bt/BTAdapter.cpp b/src/direct_bt/BTAdapter.cpp
index 44e0cd11..28d32610 100644
--- a/src/direct_bt/BTAdapter.cpp
+++ b/src/direct_bt/BTAdapter.cpp
@@ -153,7 +153,7 @@ bool BTAdapter::addDevicePausingDiscovery(const BTDeviceRef & device) noexcept {
}
}
-bool BTAdapter::removeDevicePausingDiscovery(const BTDevice & device, const bool off_thread_enable) noexcept {
+bool BTAdapter::removeDevicePausingDiscovery(const BTDevice & device) noexcept {
bool removed_last = false;
{
const std::lock_guard<std::mutex> lock(mtx_pausingDiscoveryDevices); // RAII-style acquire and relinquish via destructor
@@ -173,12 +173,8 @@ bool BTAdapter::removeDevicePausingDiscovery(const BTDevice & device, const bool
}
}
if( removed_last ) {
- if( off_thread_enable ) {
- std::thread bg(&BTAdapter::startDiscoveryBackground, this); // @suppress("Invalid arguments")
- bg.detach();
- } else {
- startDiscoveryBackground();
- }
+ std::thread bg(&BTAdapter::startDiscoveryBackground, this); // @suppress("Invalid arguments")
+ bg.detach();
return true;
} else {
return false;
@@ -1373,7 +1369,7 @@ void BTAdapter::removeDevice(BTDevice & device) noexcept {
unlockConnect(device);
removeConnectedDevice(device); // usually done in BTAdapter::mgmtEvDeviceDisconnectedHCI
removeDiscoveredDevice(device.addressAndType); // usually done in BTAdapter::mgmtEvDeviceDisconnectedHCI
- removeDevicePausingDiscovery(device, true /* off_thread_enable */);
+ removeDevicePausingDiscovery(device);
removeSharedDevice(device);
if( _print_device_lists || jau::environment::get().verbose ) {
@@ -2187,13 +2183,13 @@ bool BTAdapter::mgmtEvDeviceDisconnectedHCI(const MgmtEvent& e) noexcept {
}
}
}
- removeDevicePausingDiscovery(*device, true /* off_thread_enable */);
+ removeDevicePausingDiscovery(*device);
} else {
DBG_PRINT("BTAdapter::hci:DeviceDisconnected(dev_id %d): Device not connected: %s",
dev_id, event.toString().c_str());
device = findDevicePausingDiscovery(event.getAddress(), event.getAddressType());
if( nullptr != device ) {
- removeDevicePausingDiscovery(*device, true /* off_thread_enable */);
+ removeDevicePausingDiscovery(*device);
}
}
return true;
@@ -2633,14 +2629,14 @@ void BTAdapter::sendDevicePairingState(BTDeviceRef device, const SMPPairingState
void BTAdapter::notifyPairingStageDone(BTDeviceRef device, uint64_t timestamp) noexcept {
if( DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_PAIRED == discovery_policy ) {
- removeDevicePausingDiscovery(*device, true /* off_thread_enable */);
+ removeDevicePausingDiscovery(*device);
}
(void)timestamp;
}
void BTAdapter::sendDeviceReady(BTDeviceRef device, uint64_t timestamp) noexcept {
if( DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_READY == discovery_policy ) {
- removeDevicePausingDiscovery(*device, false /* off_thread_enable */);
+ removeDevicePausingDiscovery(*device);
}
int i=0;
jau::for_each_fidelity(statusListenerList, [&](StatusListenerPair &p) {