Loading system/btif/src/btif_av.cc +9 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <base/strings/stringprintf.h> #include <base/strings/stringprintf.h> #include <string.h> #include <string.h> #include <map> #include <map> #include <mutex> #include <hardware/bluetooth.h> #include <hardware/bluetooth.h> #include <hardware/bt_av.h> #include <hardware/bt_av.h> Loading Loading @@ -466,6 +467,7 @@ class BtifAvSource { std::map<RawAddress, BtifAvPeer*> peers_; std::map<RawAddress, BtifAvPeer*> peers_; RawAddress active_peer_; RawAddress active_peer_; std::map<uint8_t, tBTA_AV_HNDL> peer_id2bta_handle_; std::map<uint8_t, tBTA_AV_HNDL> peer_id2bta_handle_; std::mutex mutex_; }; }; class BtifAvSink { class BtifAvSink { Loading Loading @@ -576,6 +578,7 @@ class BtifAvSink { std::map<RawAddress, BtifAvPeer*> peers_; std::map<RawAddress, BtifAvPeer*> peers_; RawAddress active_peer_; RawAddress active_peer_; std::map<uint8_t, tBTA_AV_HNDL> peer_id2bta_handle_; std::map<uint8_t, tBTA_AV_HNDL> peer_id2bta_handle_; std::mutex mutex_; }; }; /***************************************************************************** /***************************************************************************** Loading Loading @@ -949,6 +952,7 @@ BtifAvPeer* BtifAvSource::FindPeerByPeerId(uint8_t peer_id) { BtifAvPeer* BtifAvSource::FindOrCreatePeer(const RawAddress& peer_address, BtifAvPeer* BtifAvSource::FindOrCreatePeer(const RawAddress& peer_address, tBTA_AV_HNDL bta_handle) { tBTA_AV_HNDL bta_handle) { std::unique_lock<std::mutex> lock(mutex_); BTIF_TRACE_DEBUG("%s: peer_address=%s bta_handle=0x%x", __PRETTY_FUNCTION__, BTIF_TRACE_DEBUG("%s: peer_address=%s bta_handle=0x%x", __PRETTY_FUNCTION__, peer_address.ToString().c_str(), bta_handle); peer_address.ToString().c_str(), bta_handle); Loading Loading @@ -1048,6 +1052,7 @@ void BtifAvSource::RegisterAllBtaHandles() { } } void BtifAvSource::DeregisterAllBtaHandles() { void BtifAvSource::DeregisterAllBtaHandles() { std::unique_lock<std::mutex> lock(mutex_); for (auto it : peer_id2bta_handle_) { for (auto it : peer_id2bta_handle_) { tBTA_AV_HNDL bta_handle = it.second; tBTA_AV_HNDL bta_handle = it.second; BTA_AvDeregister(bta_handle); BTA_AvDeregister(bta_handle); Loading @@ -1057,6 +1062,7 @@ void BtifAvSource::DeregisterAllBtaHandles() { void BtifAvSource::BtaHandleRegistered(uint8_t peer_id, void BtifAvSource::BtaHandleRegistered(uint8_t peer_id, tBTA_AV_HNDL bta_handle) { tBTA_AV_HNDL bta_handle) { std::unique_lock<std::mutex> lock(mutex_); peer_id2bta_handle_.insert(std::make_pair(peer_id, bta_handle)); peer_id2bta_handle_.insert(std::make_pair(peer_id, bta_handle)); // Set the BTA Handle for the Peer (if exists) // Set the BTA Handle for the Peer (if exists) Loading Loading @@ -1134,6 +1140,7 @@ BtifAvPeer* BtifAvSink::FindPeerByPeerId(uint8_t peer_id) { BtifAvPeer* BtifAvSink::FindOrCreatePeer(const RawAddress& peer_address, BtifAvPeer* BtifAvSink::FindOrCreatePeer(const RawAddress& peer_address, tBTA_AV_HNDL bta_handle) { tBTA_AV_HNDL bta_handle) { std::unique_lock<std::mutex> lock(mutex_); BTIF_TRACE_DEBUG("%s: peer_address=%s bta_handle=0x%x", __PRETTY_FUNCTION__, BTIF_TRACE_DEBUG("%s: peer_address=%s bta_handle=0x%x", __PRETTY_FUNCTION__, peer_address.ToString().c_str(), bta_handle); peer_address.ToString().c_str(), bta_handle); Loading Loading @@ -1234,6 +1241,7 @@ void BtifAvSink::RegisterAllBtaHandles() { } } void BtifAvSink::DeregisterAllBtaHandles() { void BtifAvSink::DeregisterAllBtaHandles() { std::unique_lock<std::mutex> lock(mutex_); for (auto it : peer_id2bta_handle_) { for (auto it : peer_id2bta_handle_) { tBTA_AV_HNDL bta_handle = it.second; tBTA_AV_HNDL bta_handle = it.second; BTA_AvDeregister(bta_handle); BTA_AvDeregister(bta_handle); Loading @@ -1242,6 +1250,7 @@ void BtifAvSink::DeregisterAllBtaHandles() { } } void BtifAvSink::BtaHandleRegistered(uint8_t peer_id, tBTA_AV_HNDL bta_handle) { void BtifAvSink::BtaHandleRegistered(uint8_t peer_id, tBTA_AV_HNDL bta_handle) { std::unique_lock<std::mutex> lock(mutex_); peer_id2bta_handle_.insert(std::make_pair(peer_id, bta_handle)); peer_id2bta_handle_.insert(std::make_pair(peer_id, bta_handle)); // Set the BTA Handle for the Peer (if exists) // Set the BTA Handle for the Peer (if exists) Loading Loading
system/btif/src/btif_av.cc +9 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <base/strings/stringprintf.h> #include <base/strings/stringprintf.h> #include <string.h> #include <string.h> #include <map> #include <map> #include <mutex> #include <hardware/bluetooth.h> #include <hardware/bluetooth.h> #include <hardware/bt_av.h> #include <hardware/bt_av.h> Loading Loading @@ -466,6 +467,7 @@ class BtifAvSource { std::map<RawAddress, BtifAvPeer*> peers_; std::map<RawAddress, BtifAvPeer*> peers_; RawAddress active_peer_; RawAddress active_peer_; std::map<uint8_t, tBTA_AV_HNDL> peer_id2bta_handle_; std::map<uint8_t, tBTA_AV_HNDL> peer_id2bta_handle_; std::mutex mutex_; }; }; class BtifAvSink { class BtifAvSink { Loading Loading @@ -576,6 +578,7 @@ class BtifAvSink { std::map<RawAddress, BtifAvPeer*> peers_; std::map<RawAddress, BtifAvPeer*> peers_; RawAddress active_peer_; RawAddress active_peer_; std::map<uint8_t, tBTA_AV_HNDL> peer_id2bta_handle_; std::map<uint8_t, tBTA_AV_HNDL> peer_id2bta_handle_; std::mutex mutex_; }; }; /***************************************************************************** /***************************************************************************** Loading Loading @@ -949,6 +952,7 @@ BtifAvPeer* BtifAvSource::FindPeerByPeerId(uint8_t peer_id) { BtifAvPeer* BtifAvSource::FindOrCreatePeer(const RawAddress& peer_address, BtifAvPeer* BtifAvSource::FindOrCreatePeer(const RawAddress& peer_address, tBTA_AV_HNDL bta_handle) { tBTA_AV_HNDL bta_handle) { std::unique_lock<std::mutex> lock(mutex_); BTIF_TRACE_DEBUG("%s: peer_address=%s bta_handle=0x%x", __PRETTY_FUNCTION__, BTIF_TRACE_DEBUG("%s: peer_address=%s bta_handle=0x%x", __PRETTY_FUNCTION__, peer_address.ToString().c_str(), bta_handle); peer_address.ToString().c_str(), bta_handle); Loading Loading @@ -1048,6 +1052,7 @@ void BtifAvSource::RegisterAllBtaHandles() { } } void BtifAvSource::DeregisterAllBtaHandles() { void BtifAvSource::DeregisterAllBtaHandles() { std::unique_lock<std::mutex> lock(mutex_); for (auto it : peer_id2bta_handle_) { for (auto it : peer_id2bta_handle_) { tBTA_AV_HNDL bta_handle = it.second; tBTA_AV_HNDL bta_handle = it.second; BTA_AvDeregister(bta_handle); BTA_AvDeregister(bta_handle); Loading @@ -1057,6 +1062,7 @@ void BtifAvSource::DeregisterAllBtaHandles() { void BtifAvSource::BtaHandleRegistered(uint8_t peer_id, void BtifAvSource::BtaHandleRegistered(uint8_t peer_id, tBTA_AV_HNDL bta_handle) { tBTA_AV_HNDL bta_handle) { std::unique_lock<std::mutex> lock(mutex_); peer_id2bta_handle_.insert(std::make_pair(peer_id, bta_handle)); peer_id2bta_handle_.insert(std::make_pair(peer_id, bta_handle)); // Set the BTA Handle for the Peer (if exists) // Set the BTA Handle for the Peer (if exists) Loading Loading @@ -1134,6 +1140,7 @@ BtifAvPeer* BtifAvSink::FindPeerByPeerId(uint8_t peer_id) { BtifAvPeer* BtifAvSink::FindOrCreatePeer(const RawAddress& peer_address, BtifAvPeer* BtifAvSink::FindOrCreatePeer(const RawAddress& peer_address, tBTA_AV_HNDL bta_handle) { tBTA_AV_HNDL bta_handle) { std::unique_lock<std::mutex> lock(mutex_); BTIF_TRACE_DEBUG("%s: peer_address=%s bta_handle=0x%x", __PRETTY_FUNCTION__, BTIF_TRACE_DEBUG("%s: peer_address=%s bta_handle=0x%x", __PRETTY_FUNCTION__, peer_address.ToString().c_str(), bta_handle); peer_address.ToString().c_str(), bta_handle); Loading Loading @@ -1234,6 +1241,7 @@ void BtifAvSink::RegisterAllBtaHandles() { } } void BtifAvSink::DeregisterAllBtaHandles() { void BtifAvSink::DeregisterAllBtaHandles() { std::unique_lock<std::mutex> lock(mutex_); for (auto it : peer_id2bta_handle_) { for (auto it : peer_id2bta_handle_) { tBTA_AV_HNDL bta_handle = it.second; tBTA_AV_HNDL bta_handle = it.second; BTA_AvDeregister(bta_handle); BTA_AvDeregister(bta_handle); Loading @@ -1242,6 +1250,7 @@ void BtifAvSink::DeregisterAllBtaHandles() { } } void BtifAvSink::BtaHandleRegistered(uint8_t peer_id, tBTA_AV_HNDL bta_handle) { void BtifAvSink::BtaHandleRegistered(uint8_t peer_id, tBTA_AV_HNDL bta_handle) { std::unique_lock<std::mutex> lock(mutex_); peer_id2bta_handle_.insert(std::make_pair(peer_id, bta_handle)); peer_id2bta_handle_.insert(std::make_pair(peer_id, bta_handle)); // Set the BTA Handle for the Peer (if exists) // Set the BTA Handle for the Peer (if exists) Loading