From: Hansong Zhang Date: Fri, 15 Jan 2021 02:56:02 +0000 (-0800) Subject: Wire up SetChannelTxPriority X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=16d2287cf89a3f7887583dff42531ef51e9e3131;p=android-x86%2Fsystem-bt.git Wire up SetChannelTxPriority Test: cert/run Tag: #gd-refactor Bug: 141555841 Change-Id: Iceb6559d7468a886d3720038f172dce6297016d3 --- diff --git a/gd/l2cap/classic/internal/link.cc b/gd/l2cap/classic/internal/link.cc index 0d6bea031..c3f0f78e3 100644 --- a/gd/l2cap/classic/internal/link.cc +++ b/gd/l2cap/classic/internal/link.cc @@ -171,6 +171,10 @@ void Link::SendConnectionRequest(Psm psm, Cid local_cid, } } +void Link::SetChannelTxPriority(Cid local_cid, bool high_priority) { + data_pipeline_manager_.SetChannelTxPriority(local_cid, high_priority); +} + void Link::SetPendingDynamicChannels(std::list psm_list, std::list callback_list) { ASSERT(psm_list.size() == callback_list.size()); diff --git a/gd/l2cap/classic/internal/link.h b/gd/l2cap/classic/internal/link.h index 958ad71dc..c8c95140a 100644 --- a/gd/l2cap/classic/internal/link.h +++ b/gd/l2cap/classic/internal/link.h @@ -106,6 +106,7 @@ class Link : public l2cap::internal::ILink, public hci::acl_manager::ConnectionM virtual void SendConnectionRequest(Psm psm, Cid local_cid); virtual void SendConnectionRequest(Psm psm, Cid local_cid, PendingDynamicChannelConnection pending_dynamic_channel_connection); + void SetChannelTxPriority(Cid local_cid, bool high_priority) override; // When a Link is established, LinkManager notifies pending dynamic channels to connect virtual void SetPendingDynamicChannels(std::list psm_list, diff --git a/gd/l2cap/dynamic_channel.cc b/gd/l2cap/dynamic_channel.cc index 19d527fbd..a49aed763 100644 --- a/gd/l2cap/dynamic_channel.cc +++ b/gd/l2cap/dynamic_channel.cc @@ -42,5 +42,10 @@ DynamicChannel::GetQueueUpEnd() const { Cid DynamicChannel::HACK_GetRemoteCid() { return impl_->GetRemoteCid(); } + +void DynamicChannel::HACK_SetChannelTxPriority(bool high_priority) { + return impl_->SetChannelTxPriority(high_priority); +} + } // namespace l2cap } // namespace bluetooth diff --git a/gd/l2cap/dynamic_channel.h b/gd/l2cap/dynamic_channel.h index 7bb34fed4..ba4e750eb 100644 --- a/gd/l2cap/dynamic_channel.h +++ b/gd/l2cap/dynamic_channel.h @@ -72,6 +72,12 @@ class DynamicChannel { Cid HACK_GetRemoteCid(); + /** + * Used by A2dp software encoding to prioritize Tx of this channel + * @param high_priority + */ + void HACK_SetChannelTxPriority(bool high_priority); + private: std::shared_ptr impl_; os::Handler* l2cap_handler_; diff --git a/gd/l2cap/internal/data_pipeline_manager.cc b/gd/l2cap/internal/data_pipeline_manager.cc index b19412a11..7247e28cf 100644 --- a/gd/l2cap/internal/data_pipeline_manager.cc +++ b/gd/l2cap/internal/data_pipeline_manager.cc @@ -36,6 +36,7 @@ void DataPipelineManager::AttachChannel(Cid cid, std::shared_ptr ch void DataPipelineManager::DetachChannel(Cid cid) { ASSERT(sender_map_.find(cid) != sender_map_.end()); sender_map_.erase(cid); + scheduler_->SetChannelTxPriority(cid, false); } DataController* DataPipelineManager::GetDataController(Cid cid) { @@ -55,6 +56,11 @@ void DataPipelineManager::UpdateClassicConfiguration(Cid cid, classic::internal: sender_map_.find(cid)->second.UpdateClassicConfiguration(config); } +void DataPipelineManager::SetChannelTxPriority(Cid cid, bool high_priority) { + ASSERT(sender_map_.find(cid) != sender_map_.end()); + scheduler_->SetChannelTxPriority(cid, high_priority); +} + } // namespace internal } // namespace l2cap } // namespace bluetooth diff --git a/gd/l2cap/internal/data_pipeline_manager.h b/gd/l2cap/internal/data_pipeline_manager.h index aea8d7c35..104f49ec7 100644 --- a/gd/l2cap/internal/data_pipeline_manager.h +++ b/gd/l2cap/internal/data_pipeline_manager.h @@ -66,6 +66,7 @@ class DataPipelineManager { virtual DataController* GetDataController(Cid cid); virtual void OnPacketSent(Cid cid); virtual void UpdateClassicConfiguration(Cid cid, classic::internal::ChannelConfigurationState config); + virtual void SetChannelTxPriority(Cid cid, bool high_priority); virtual ~DataPipelineManager() = default; private: diff --git a/gd/l2cap/internal/dynamic_channel_impl.h b/gd/l2cap/internal/dynamic_channel_impl.h index c54332e2e..a012fff2d 100644 --- a/gd/l2cap/internal/dynamic_channel_impl.h +++ b/gd/l2cap/internal/dynamic_channel_impl.h @@ -66,6 +66,10 @@ class DynamicChannelImpl : public l2cap::internal::ChannelImpl { return psm_; } + virtual void SetChannelTxPriority(bool high_priority) { + link_->SetChannelTxPriority(cid_, high_priority); + } + // TODO(cmanton) Do something a little bit better than this bool local_initiated_{false}; diff --git a/gd/l2cap/internal/ilink.h b/gd/l2cap/internal/ilink.h index 2f354cb58..4f6d664f2 100644 --- a/gd/l2cap/internal/ilink.h +++ b/gd/l2cap/internal/ilink.h @@ -33,7 +33,10 @@ class ILink { virtual hci::AddressWithType GetDevice() const = 0; // To be used by LE credit based channel data controller over LE link - virtual void SendLeCredit(Cid local_cid, uint16_t credit) = 0; + virtual void SendLeCredit(Cid local_cid, uint16_t credit) {} + + // Used by A2dp software encoding + virtual void SetChannelTxPriority(Cid local_cid, bool high_priority) {} }; } // namespace internal } // namespace l2cap diff --git a/main/shim/l2c_api.cc b/main/shim/l2c_api.cc index 700af4545..19d4b73ff 100644 --- a/main/shim/l2c_api.cc +++ b/main/shim/l2c_api.cc @@ -252,6 +252,16 @@ struct ClassicDynamicChannelHelper { return channel->second->HACK_GetRemoteCid(); } + bool SetChannelTxPriority(uint16_t cid, bool high_priority) { + auto channel = channels_.find(cid); + if (channel == channels_.end()) { + LOG_ERROR("Channel is not open"); + return false; + } + channel->second->HACK_SetChannelTxPriority(high_priority); + return true; + } + std::unordered_map> channels_; std::unordered_mapSetChannelTxPriority( + cid, high_priority); } bool L2CA_SetLeGattTimeout(const RawAddress& rem_bda, uint16_t idle_tout) {