Loading system/profile/avrcp/connection_handler.cc +9 −6 Original line number Diff line number Diff line Loading @@ -45,7 +45,10 @@ namespace avrcp { ConnectionHandler* ConnectionHandler::instance_ = nullptr; std::mutex device_map_lock; // ConnectionHandler::CleanUp take the lock and calls // ConnectionHandler::AcceptorControlCB with AVRC_CLOSE_IND_EVT // which also takes the lock, so use a recursive_mutex. std::recursive_mutex device_map_lock; ConnectionHandler* ConnectionHandler::Get() { CHECK(instance_); Loading Loading @@ -95,7 +98,7 @@ bool ConnectionHandler::CleanUp() { CHECK(instance_ != nullptr); // TODO (apanicke): Cleanup the SDP Entries here std::lock_guard<std::mutex> lock(device_map_lock); std::lock_guard<std::recursive_mutex> lock(device_map_lock); for (auto entry = instance_->device_map_.begin(); entry != instance_->device_map_.end();) { auto curr = entry; Loading Loading @@ -175,7 +178,7 @@ void ConnectionHandler::SetBipClientStatus(const RawAddress& bdaddr, std::vector<std::shared_ptr<Device>> ConnectionHandler::GetListOfDevices() const { std::vector<std::shared_ptr<Device>> list; std::lock_guard<std::mutex> lock(device_map_lock); std::lock_guard<std::recursive_mutex> lock(device_map_lock); for (const auto& device : device_map_) { list.push_back(device.second); } Loading Loading @@ -298,7 +301,7 @@ void ConnectionHandler::InitiatorControlCb(uint8_t handle, uint8_t event, << "Connection Close received from device that doesn't exist"; return; } std::lock_guard<std::mutex> lock(device_map_lock); std::lock_guard<std::recursive_mutex> lock(device_map_lock); avrc_->Close(handle); feature_map_.erase(device_map_[handle]->GetAddress()); device_map_[handle]->DeviceDisconnected(); Loading Loading @@ -344,7 +347,7 @@ void ConnectionHandler::AcceptorControlCb(uint8_t handle, uint8_t event, btif_av_peer_is_connected_source(*peer_addr)) { LOG(WARNING) << "peer is src, close new avrcp cback"; if (device_map_.find(handle) != device_map_.end()) { std::lock_guard<std::mutex> lock(device_map_lock); std::lock_guard<std::recursive_mutex> lock(device_map_lock); feature_map_.erase(device_map_[handle]->GetAddress()); device_map_[handle]->DeviceDisconnected(); device_map_.erase(handle); Loading Loading @@ -407,7 +410,7 @@ void ConnectionHandler::AcceptorControlCb(uint8_t handle, uint8_t event, return; } { std::lock_guard<std::mutex> lock(device_map_lock); std::lock_guard<std::recursive_mutex> lock(device_map_lock); feature_map_.erase(device_map_[handle]->GetAddress()); device_map_[handle]->DeviceDisconnected(); device_map_.erase(handle); Loading Loading
system/profile/avrcp/connection_handler.cc +9 −6 Original line number Diff line number Diff line Loading @@ -45,7 +45,10 @@ namespace avrcp { ConnectionHandler* ConnectionHandler::instance_ = nullptr; std::mutex device_map_lock; // ConnectionHandler::CleanUp take the lock and calls // ConnectionHandler::AcceptorControlCB with AVRC_CLOSE_IND_EVT // which also takes the lock, so use a recursive_mutex. std::recursive_mutex device_map_lock; ConnectionHandler* ConnectionHandler::Get() { CHECK(instance_); Loading Loading @@ -95,7 +98,7 @@ bool ConnectionHandler::CleanUp() { CHECK(instance_ != nullptr); // TODO (apanicke): Cleanup the SDP Entries here std::lock_guard<std::mutex> lock(device_map_lock); std::lock_guard<std::recursive_mutex> lock(device_map_lock); for (auto entry = instance_->device_map_.begin(); entry != instance_->device_map_.end();) { auto curr = entry; Loading Loading @@ -175,7 +178,7 @@ void ConnectionHandler::SetBipClientStatus(const RawAddress& bdaddr, std::vector<std::shared_ptr<Device>> ConnectionHandler::GetListOfDevices() const { std::vector<std::shared_ptr<Device>> list; std::lock_guard<std::mutex> lock(device_map_lock); std::lock_guard<std::recursive_mutex> lock(device_map_lock); for (const auto& device : device_map_) { list.push_back(device.second); } Loading Loading @@ -298,7 +301,7 @@ void ConnectionHandler::InitiatorControlCb(uint8_t handle, uint8_t event, << "Connection Close received from device that doesn't exist"; return; } std::lock_guard<std::mutex> lock(device_map_lock); std::lock_guard<std::recursive_mutex> lock(device_map_lock); avrc_->Close(handle); feature_map_.erase(device_map_[handle]->GetAddress()); device_map_[handle]->DeviceDisconnected(); Loading Loading @@ -344,7 +347,7 @@ void ConnectionHandler::AcceptorControlCb(uint8_t handle, uint8_t event, btif_av_peer_is_connected_source(*peer_addr)) { LOG(WARNING) << "peer is src, close new avrcp cback"; if (device_map_.find(handle) != device_map_.end()) { std::lock_guard<std::mutex> lock(device_map_lock); std::lock_guard<std::recursive_mutex> lock(device_map_lock); feature_map_.erase(device_map_[handle]->GetAddress()); device_map_[handle]->DeviceDisconnected(); device_map_.erase(handle); Loading Loading @@ -407,7 +410,7 @@ void ConnectionHandler::AcceptorControlCb(uint8_t handle, uint8_t event, return; } { std::lock_guard<std::mutex> lock(device_map_lock); std::lock_guard<std::recursive_mutex> lock(device_map_lock); feature_map_.erase(device_map_[handle]->GetAddress()); device_map_[handle]->DeviceDisconnected(); device_map_.erase(handle); Loading