OSDN Git Service

Add tSCO_CONN::get_sco_connection_from_index
authorChris Manton <cmanton@google.com>
Sat, 16 Jan 2021 00:52:36 +0000 (16:52 -0800)
committerChris Manton <cmanton@google.com>
Wed, 20 Jan 2021 07:12:57 +0000 (23:12 -0800)
Towards encapsulated code

Bug: 163134718
Tag: #refactor
Test: gd/cert/run

Change-Id: I39a87cb83e6e0572b407f1fccc5a11b11e96ee0e

stack/btm/btm_sco.h

index 5fafe9a..7441940 100644 (file)
@@ -22,6 +22,8 @@
 #include "device/include/esco_parameters.h"
 #include "stack/include/btm_api_types.h"
 
+constexpr uint16_t kMaxScoLinks = static_cast<uint16_t>(BTM_MAX_SCO_LINKS);
+
 /* Define the structures needed by sco
  */
 
@@ -92,6 +94,10 @@ typedef struct {
   bool esco_supported;        /* true if 1.2 cntlr AND supports eSCO links */
   esco_data_path_t sco_route; /* HCI, PCM, or TEST */
 
+  tSCO_CONN* get_sco_connection_from_index(uint16_t index) {
+    return (index < kMaxScoLinks) ? (&sco_db[index]) : nullptr;
+  }
+
   void Init() {
     sco_disc_reason = BTM_INVALID_SCO_DISC_REASON;
     def_esco_parms = esco_parameters_for_codec(ESCO_CODEC_CVSD);