The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Jakub Pawlowski | 5b790fe | 2017-09-18 09:00:20 -0700 | [diff] [blame] | 3 | * Copyright 2004-2012 Broadcom Corporation |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | ******************************************************************************/ |
| 18 | |
| 19 | /****************************************************************************** |
| 20 | * |
| 21 | * This is the stream state machine for the BTA advanced audio/video. |
| 22 | * |
| 23 | ******************************************************************************/ |
Myles Watson | f355ef5 | 2016-11-09 13:04:33 -0800 | [diff] [blame] | 24 | #include <string.h> |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 25 | |
| 26 | #include "bt_target.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 27 | #include "bta_av_co.h" |
| 28 | #include "bta_av_int.h" |
| 29 | |
| 30 | /***************************************************************************** |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 31 | * Constants and types |
| 32 | ****************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 33 | |
| 34 | /* state machine states */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 35 | enum { |
| 36 | BTA_AV_INIT_SST, |
| 37 | BTA_AV_INCOMING_SST, |
| 38 | BTA_AV_OPENING_SST, |
| 39 | BTA_AV_OPEN_SST, |
| 40 | BTA_AV_RCFG_SST, |
| 41 | BTA_AV_CLOSING_SST |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 42 | }; |
| 43 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 44 | /* state machine action enumeration list */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 45 | enum { |
| 46 | BTA_AV_DO_DISC, |
| 47 | BTA_AV_CLEANUP, |
| 48 | BTA_AV_FREE_SDB, |
| 49 | BTA_AV_CONFIG_IND, |
| 50 | BTA_AV_DISCONNECT_REQ, |
| 51 | BTA_AV_SECURITY_REQ, |
| 52 | BTA_AV_SECURITY_RSP, |
| 53 | BTA_AV_SETCONFIG_RSP, |
| 54 | BTA_AV_ST_RC_TIMER, |
| 55 | BTA_AV_STR_OPENED, |
| 56 | BTA_AV_SECURITY_IND, |
| 57 | BTA_AV_SECURITY_CFM, |
| 58 | BTA_AV_DO_CLOSE, |
| 59 | BTA_AV_CONNECT_REQ, |
| 60 | BTA_AV_SDP_FAILED, |
| 61 | BTA_AV_DISC_RESULTS, |
| 62 | BTA_AV_DISC_RES_AS_ACP, |
| 63 | BTA_AV_OPEN_FAILED, |
| 64 | BTA_AV_GETCAP_RESULTS, |
| 65 | BTA_AV_SETCONFIG_REJ, |
| 66 | BTA_AV_DISCOVER_REQ, |
| 67 | BTA_AV_CONN_FAILED, |
| 68 | BTA_AV_DO_START, |
| 69 | BTA_AV_STR_STOPPED, |
| 70 | BTA_AV_RECONFIG, |
| 71 | BTA_AV_DATA_PATH, |
| 72 | BTA_AV_START_OK, |
| 73 | BTA_AV_START_FAILED, |
| 74 | BTA_AV_STR_CLOSED, |
| 75 | BTA_AV_CLR_CONG, |
| 76 | BTA_AV_SUSPEND_CFM, |
| 77 | BTA_AV_RCFG_STR_OK, |
| 78 | BTA_AV_RCFG_FAILED, |
| 79 | BTA_AV_RCFG_CONNECT, |
| 80 | BTA_AV_RCFG_DISCNTD, |
| 81 | BTA_AV_SUSPEND_CONT, |
| 82 | BTA_AV_RCFG_CFM, |
| 83 | BTA_AV_RCFG_OPEN, |
| 84 | BTA_AV_SECURITY_REJ, |
| 85 | BTA_AV_OPEN_RC, |
| 86 | BTA_AV_CHK_2ND_START, |
| 87 | BTA_AV_SAVE_CAPS, |
| 88 | BTA_AV_SET_USE_RC, |
| 89 | BTA_AV_CCO_CLOSE, |
| 90 | BTA_AV_SWITCH_ROLE, |
| 91 | BTA_AV_ROLE_RES, |
| 92 | BTA_AV_DELAY_CO, |
| 93 | BTA_AV_OPEN_AT_INC, |
| 94 | BTA_AV_OFFLOAD_REQ, |
| 95 | BTA_AV_OFFLOAD_RSP, |
| 96 | BTA_AV_NUM_SACTIONS |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 97 | }; |
| 98 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 99 | #define BTA_AV_SIGNORE BTA_AV_NUM_SACTIONS |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 100 | |
| 101 | /* state table information */ |
| 102 | /* #define BTA_AV_SACTION_COL 0 position of actions */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 103 | #define BTA_AV_SACTIONS 2 /* number of actions */ |
| 104 | #define BTA_AV_SNEXT_STATE 2 /* position of next state */ |
| 105 | #define BTA_AV_NUM_COLS 3 /* number of columns in state tables */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 106 | |
| 107 | /* state table for init state */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 108 | static const uint8_t bta_av_sst_init[][BTA_AV_NUM_COLS] = { |
| 109 | /* Event Action 1 Action 2 Next state */ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 110 | /* API_OPEN_EVT */ {BTA_AV_DO_DISC, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 111 | /* API_CLOSE_EVT */ {BTA_AV_CLEANUP, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 112 | /* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 113 | /* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 114 | /* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 115 | /* API_PROTECT_REQ_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 116 | /* API_PROTECT_RSP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 117 | /* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 118 | /* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 119 | /* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 120 | /* CI_SETCONFIG_FAIL_EVT */ |
| 121 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 122 | /* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 123 | /* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 124 | /* STR_DISC_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 125 | /* STR_DISC_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 126 | /* STR_GETCAP_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 127 | /* STR_GETCAP_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 128 | /* STR_OPEN_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 129 | /* STR_OPEN_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 130 | /* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 131 | /* STR_START_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 132 | /* STR_CLOSE_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 133 | /* STR_CONFIG_IND_EVT */ |
| 134 | {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 135 | /* STR_SECURITY_IND_EVT */ |
| 136 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 137 | /* STR_SECURITY_CFM_EVT */ |
| 138 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 139 | /* STR_WRITE_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 140 | /* STR_SUSPEND_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 141 | /* STR_RECONFIG_CFM_EVT */ |
| 142 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 143 | /* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 144 | /* AVDT_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 145 | /* AVDT_DISCONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 146 | /* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 147 | /* AVDT_DELAY_RPT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 148 | /* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 149 | /* API_OFFLOAD_START_EVT */ |
| 150 | {BTA_AV_OFFLOAD_REQ, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 151 | /* API_OFFLOAD_START_RSP_EVT */ |
| 152 | {BTA_AV_OFFLOAD_RSP, BTA_AV_SIGNORE, BTA_AV_INIT_SST}}; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 153 | |
| 154 | /* state table for incoming state */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 155 | static const uint8_t bta_av_sst_incoming[][BTA_AV_NUM_COLS] = { |
| 156 | /* Event Action 1 Action 2 Next state */ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 157 | /* API_OPEN_EVT */ {BTA_AV_OPEN_AT_INC, BTA_AV_SIGNORE, |
| 158 | BTA_AV_INCOMING_SST}, |
| 159 | /* API_CLOSE_EVT */ |
| 160 | {BTA_AV_CCO_CLOSE, BTA_AV_DISCONNECT_REQ, BTA_AV_CLOSING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 161 | /* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 162 | /* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 163 | /* API_RECONFIG_EVT */ |
| 164 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 165 | /* API_PROTECT_REQ_EVT */ |
| 166 | {BTA_AV_SECURITY_REQ, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 167 | /* API_PROTECT_RSP_EVT */ |
| 168 | {BTA_AV_SECURITY_RSP, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 169 | /* API_RC_OPEN_EVT */ |
| 170 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 171 | /* SRC_DATA_READY_EVT */ |
| 172 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 173 | /* CI_SETCONFIG_OK_EVT */ |
| 174 | {BTA_AV_SETCONFIG_RSP, BTA_AV_ST_RC_TIMER, BTA_AV_INCOMING_SST}, |
| 175 | /* CI_SETCONFIG_FAIL_EVT */ |
| 176 | {BTA_AV_SETCONFIG_REJ, BTA_AV_CLEANUP, BTA_AV_INIT_SST}, |
| 177 | /* SDP_DISC_OK_EVT */ |
| 178 | {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 179 | /* SDP_DISC_FAIL_EVT */ |
| 180 | {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 181 | /* STR_DISC_OK_EVT */ |
| 182 | {BTA_AV_DISC_RES_AS_ACP, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 183 | /* STR_DISC_FAIL_EVT */ |
| 184 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 185 | /* STR_GETCAP_OK_EVT */ |
| 186 | {BTA_AV_SAVE_CAPS, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 187 | /* STR_GETCAP_FAIL_EVT */ |
| 188 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 189 | /* STR_OPEN_OK_EVT */ {BTA_AV_STR_OPENED, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 190 | /* STR_OPEN_FAIL_EVT */ |
| 191 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 192 | /* STR_START_OK_EVT */ |
| 193 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 194 | /* STR_START_FAIL_EVT */ |
| 195 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 196 | /* STR_CLOSE_EVT */ {BTA_AV_CCO_CLOSE, BTA_AV_CLEANUP, BTA_AV_INIT_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 197 | /* STR_CONFIG_IND_EVT */ |
| 198 | {BTA_AV_CONFIG_IND, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 199 | /* STR_SECURITY_IND_EVT */ |
| 200 | {BTA_AV_SECURITY_IND, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 201 | /* STR_SECURITY_CFM_EVT */ |
| 202 | {BTA_AV_SECURITY_CFM, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 203 | /* STR_WRITE_CFM_EVT */ |
| 204 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 205 | /* STR_SUSPEND_CFM_EVT */ |
| 206 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 207 | /* STR_RECONFIG_CFM_EVT */ |
| 208 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 209 | /* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 210 | /* AVDT_CONNECT_EVT */ |
| 211 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 212 | /* AVDT_DISCONNECT_EVT */ |
| 213 | {BTA_AV_CCO_CLOSE, BTA_AV_DISCONNECT_REQ, BTA_AV_CLOSING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 214 | /* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 215 | /* AVDT_DELAY_RPT_EVT */ |
| 216 | {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 217 | /* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 218 | /* API_OFFLOAD_START_EVT */ |
| 219 | {BTA_AV_OFFLOAD_REQ, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 220 | /* API_OFFLOAD_START_RSP_EVT */ |
| 221 | {BTA_AV_OFFLOAD_RSP, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}}; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 222 | |
| 223 | /* state table for opening state */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 224 | static const uint8_t bta_av_sst_opening[][BTA_AV_NUM_COLS] = { |
| 225 | /* Event Action 1 Action 2 Next state */ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 226 | /* API_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 227 | /* API_CLOSE_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 228 | /* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 229 | /* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 230 | /* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 231 | /* API_PROTECT_REQ_EVT */ |
| 232 | {BTA_AV_SECURITY_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 233 | /* API_PROTECT_RSP_EVT */ |
| 234 | {BTA_AV_SECURITY_RSP, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 235 | /* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 236 | /* SRC_DATA_READY_EVT */ |
| 237 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 238 | /* CI_SETCONFIG_OK_EVT */ |
| 239 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 240 | /* CI_SETCONFIG_FAIL_EVT */ |
| 241 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 242 | /* SDP_DISC_OK_EVT */ |
| 243 | {BTA_AV_CONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 244 | /* SDP_DISC_FAIL_EVT */ |
| 245 | {BTA_AV_CONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 246 | /* STR_DISC_OK_EVT */ |
| 247 | {BTA_AV_DISC_RESULTS, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 248 | /* STR_DISC_FAIL_EVT */ |
| 249 | {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 250 | /* STR_GETCAP_OK_EVT */ |
| 251 | {BTA_AV_GETCAP_RESULTS, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 252 | /* STR_GETCAP_FAIL_EVT */ |
| 253 | {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 254 | /* STR_OPEN_OK_EVT */ |
| 255 | {BTA_AV_ST_RC_TIMER, BTA_AV_STR_OPENED, BTA_AV_OPEN_SST}, |
| 256 | /* STR_OPEN_FAIL_EVT */ |
| 257 | {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 258 | /* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 259 | /* STR_START_FAIL_EVT */ |
| 260 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 261 | /* STR_CLOSE_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 262 | /* STR_CONFIG_IND_EVT */ |
| 263 | {BTA_AV_CONFIG_IND, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST}, |
| 264 | /* STR_SECURITY_IND_EVT */ |
| 265 | {BTA_AV_SECURITY_IND, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 266 | /* STR_SECURITY_CFM_EVT */ |
| 267 | {BTA_AV_SECURITY_CFM, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 268 | /* STR_WRITE_CFM_EVT */ |
| 269 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 270 | /* STR_SUSPEND_CFM_EVT */ |
| 271 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 272 | /* STR_RECONFIG_CFM_EVT */ |
| 273 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 274 | /* AVRC_TIMER_EVT */ |
| 275 | {BTA_AV_SWITCH_ROLE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 276 | /* AVDT_CONNECT_EVT */ |
| 277 | {BTA_AV_DISCOVER_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 278 | /* AVDT_DISCONNECT_EVT */ |
| 279 | {BTA_AV_CONN_FAILED, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 280 | /* ROLE_CHANGE_EVT*/ {BTA_AV_ROLE_RES, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 281 | /* AVDT_DELAY_RPT_EVT */ |
| 282 | {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 283 | /* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 284 | /* API_OFFLOAD_START_EVT */ |
| 285 | {BTA_AV_OFFLOAD_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}, |
| 286 | /* API_OFFLOAD_START_RSP_EVT */ |
| 287 | {BTA_AV_OFFLOAD_RSP, BTA_AV_SIGNORE, BTA_AV_OPENING_SST}}; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 288 | |
| 289 | /* state table for open state */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 290 | static const uint8_t bta_av_sst_open[][BTA_AV_NUM_COLS] = { |
| 291 | /* Event Action 1 Action 2 Next state */ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 292 | /* API_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 293 | /* API_CLOSE_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 294 | /* AP_START_EVT */ {BTA_AV_DO_START, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 295 | /* AP_STOP_EVT */ {BTA_AV_STR_STOPPED, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 296 | /* API_RECONFIG_EVT */ {BTA_AV_RECONFIG, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 297 | /* API_PROTECT_REQ_EVT */ |
| 298 | {BTA_AV_SECURITY_REQ, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 299 | /* API_PROTECT_RSP_EVT */ |
| 300 | {BTA_AV_SECURITY_RSP, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 301 | /* API_RC_OPEN_EVT */ {BTA_AV_SET_USE_RC, BTA_AV_OPEN_RC, BTA_AV_OPEN_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 302 | /* SRC_DATA_READY_EVT */ |
| 303 | {BTA_AV_DATA_PATH, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 304 | /* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 305 | /* CI_SETCONFIG_FAIL_EVT */ |
| 306 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 307 | /* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 308 | /* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 309 | /* STR_DISC_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 310 | /* STR_DISC_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 311 | /* STR_GETCAP_OK_EVT */ {BTA_AV_SAVE_CAPS, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 312 | /* STR_GETCAP_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 313 | /* STR_OPEN_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 314 | /* STR_OPEN_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 315 | /* STR_START_OK_EVT */ {BTA_AV_START_OK, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 316 | /* STR_START_FAIL_EVT */ |
| 317 | {BTA_AV_START_FAILED, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 318 | /* STR_CLOSE_EVT */ {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 319 | /* STR_CONFIG_IND_EVT */ |
| 320 | {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 321 | /* STR_SECURITY_IND_EVT */ |
| 322 | {BTA_AV_SECURITY_IND, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 323 | /* STR_SECURITY_CFM_EVT */ |
| 324 | {BTA_AV_SECURITY_CFM, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 325 | /* STR_WRITE_CFM_EVT */ |
| 326 | {BTA_AV_CLR_CONG, BTA_AV_DATA_PATH, BTA_AV_OPEN_SST}, |
| 327 | /* STR_SUSPEND_CFM_EVT */ |
| 328 | {BTA_AV_SUSPEND_CFM, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 329 | /* STR_RECONFIG_CFM_EVT */ |
| 330 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 331 | /* AVRC_TIMER_EVT */ |
| 332 | {BTA_AV_OPEN_RC, BTA_AV_CHK_2ND_START, BTA_AV_OPEN_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 333 | /* AVDT_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 334 | /* AVDT_DISCONNECT_EVT */ |
| 335 | {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 336 | /* ROLE_CHANGE_EVT*/ {BTA_AV_ROLE_RES, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 337 | /* AVDT_DELAY_RPT_EVT */ {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 338 | /* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 339 | /* API_OFFLOAD_START_EVT */ |
| 340 | {BTA_AV_OFFLOAD_REQ, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
| 341 | /* API_OFFLOAD_START_RSP_EVT */ |
| 342 | {BTA_AV_OFFLOAD_RSP, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}}; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 343 | |
| 344 | /* state table for reconfig state */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 345 | static const uint8_t bta_av_sst_rcfg[][BTA_AV_NUM_COLS] = { |
| 346 | /* Event Action 1 Action 2 Next state */ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 347 | /* API_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 348 | /* API_CLOSE_EVT */ |
| 349 | {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 350 | /* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 351 | /* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
Pavlin Radoslavov | a72b0e2 | 2017-02-11 01:20:49 -0800 | [diff] [blame] | 352 | /* API_RECONFIG_EVT */ {BTA_AV_RECONFIG, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 353 | /* API_PROTECT_REQ_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 354 | /* API_PROTECT_RSP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 355 | /* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 356 | /* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 357 | /* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 358 | /* CI_SETCONFIG_FAIL_EVT */ |
| 359 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 360 | /* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 361 | /* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 362 | /* STR_DISC_OK_EVT */ |
| 363 | {BTA_AV_DISC_RESULTS, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 364 | /* STR_DISC_FAIL_EVT */ |
| 365 | {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
| 366 | /* STR_GETCAP_OK_EVT */ |
| 367 | {BTA_AV_GETCAP_RESULTS, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 368 | /* STR_GETCAP_FAIL_EVT */ |
| 369 | {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 370 | /* STR_OPEN_OK_EVT */ {BTA_AV_RCFG_STR_OK, BTA_AV_SIGNORE, BTA_AV_OPEN_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 371 | /* STR_OPEN_FAIL_EVT */ |
| 372 | {BTA_AV_RCFG_FAILED, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 373 | /* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 374 | /* STR_START_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 375 | /* STR_CLOSE_EVT */ {BTA_AV_RCFG_CONNECT, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 376 | /* STR_CONFIG_IND_EVT */ |
| 377 | {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 378 | /* STR_SECURITY_IND_EVT */ |
| 379 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 380 | /* STR_SECURITY_CFM_EVT */ |
| 381 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 382 | /* STR_WRITE_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 383 | /* STR_SUSPEND_CFM_EVT */ |
| 384 | {BTA_AV_SUSPEND_CFM, BTA_AV_SUSPEND_CONT, BTA_AV_RCFG_SST}, |
| 385 | /* STR_RECONFIG_CFM_EVT */ |
| 386 | {BTA_AV_RCFG_CFM, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 387 | /* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 388 | /* AVDT_CONNECT_EVT */ {BTA_AV_RCFG_OPEN, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 389 | /* AVDT_DISCONNECT_EVT */ |
| 390 | {BTA_AV_RCFG_DISCNTD, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 391 | /* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 392 | /* AVDT_DELAY_RPT_EVT */ {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 393 | /* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 394 | /* API_OFFLOAD_START_EVT */ |
| 395 | {BTA_AV_OFFLOAD_REQ, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}, |
| 396 | /* API_OFFLOAD_START_RSP_EVT */ |
| 397 | {BTA_AV_OFFLOAD_RSP, BTA_AV_SIGNORE, BTA_AV_RCFG_SST}}; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 398 | |
| 399 | /* state table for closing state */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 400 | static const uint8_t bta_av_sst_closing[][BTA_AV_NUM_COLS] = { |
| 401 | /* Event Action 1 Action 2 Next state */ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 402 | /* API_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 403 | /* API_CLOSE_EVT */ |
| 404 | {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 405 | /* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 406 | /* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 407 | /* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 408 | /* API_PROTECT_REQ_EVT */ |
| 409 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 410 | /* API_PROTECT_RSP_EVT */ |
| 411 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 412 | /* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 413 | /* SRC_DATA_READY_EVT */ |
| 414 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 415 | /* CI_SETCONFIG_OK_EVT */ |
| 416 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 417 | /* CI_SETCONFIG_FAIL_EVT */ |
| 418 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 419 | /* SDP_DISC_OK_EVT */ {BTA_AV_SDP_FAILED, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 420 | /* SDP_DISC_FAIL_EVT */ |
| 421 | {BTA_AV_SDP_FAILED, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 422 | /* STR_DISC_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 423 | /* STR_DISC_FAIL_EVT */ |
| 424 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 425 | /* STR_GETCAP_OK_EVT */ |
| 426 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 427 | /* STR_GETCAP_FAIL_EVT */ |
| 428 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 429 | /* STR_OPEN_OK_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 430 | /* STR_OPEN_FAIL_EVT */ |
| 431 | {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 432 | /* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 433 | /* STR_START_FAIL_EVT */ |
| 434 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 435 | /* STR_CLOSE_EVT */ |
| 436 | {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 437 | /* STR_CONFIG_IND_EVT */ |
| 438 | {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 439 | /* STR_SECURITY_IND_EVT */ |
| 440 | {BTA_AV_SECURITY_REJ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 441 | /* STR_SECURITY_CFM_EVT */ |
| 442 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 443 | /* STR_WRITE_CFM_EVT */ |
| 444 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 445 | /* STR_SUSPEND_CFM_EVT */ |
| 446 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 447 | /* STR_RECONFIG_CFM_EVT */ |
| 448 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 449 | /* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 450 | /* AVDT_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 451 | /* AVDT_DISCONNECT_EVT */ |
| 452 | {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 453 | /* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 454 | /* AVDT_DELAY_RPT_EVT */ |
| 455 | {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 456 | /* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 457 | /* API_OFFLOAD_START_EVT */ |
| 458 | {BTA_AV_OFFLOAD_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}, |
| 459 | /* API_OFFLOAD_START_RSP_EVT */ |
| 460 | {BTA_AV_OFFLOAD_RSP, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST}}; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 461 | |
| 462 | /* type for state table */ |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 463 | typedef const uint8_t (*tBTA_AV_SST_TBL)[BTA_AV_NUM_COLS]; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 464 | |
| 465 | /* state table */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 466 | static const tBTA_AV_SST_TBL bta_av_sst_tbl[] = { |
| 467 | bta_av_sst_init, bta_av_sst_incoming, bta_av_sst_opening, |
| 468 | bta_av_sst_open, bta_av_sst_rcfg, bta_av_sst_closing}; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 469 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 470 | |
| 471 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 472 | * |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 473 | * Function bta_av_ssm_execute |
| 474 | * |
| 475 | * Description Stream state machine event handling function for AV |
| 476 | * |
| 477 | * |
| 478 | * Returns void |
| 479 | * |
| 480 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 481 | void bta_av_ssm_execute(tBTA_AV_SCB* p_scb, uint16_t event, |
| 482 | tBTA_AV_DATA* p_data) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 483 | if (p_scb == NULL) { |
| 484 | /* this stream is not registered */ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 485 | APPL_TRACE_EVENT("%s: AV channel not registered", __func__); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 486 | return; |
| 487 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 488 | |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 489 | APPL_TRACE_VERBOSE( |
| 490 | "%s: peer %s AV event(0x%x)=0x%x(%s) state=%d(%s) p_scb=%p", __func__, |
Pavlin Radoslavov | a634f4e | 2018-04-23 13:36:33 -0700 | [diff] [blame] | 491 | p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, event, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 492 | bta_av_evt_code(event), p_scb->state, bta_av_sst_code(p_scb->state), |
| 493 | p_scb); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 494 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 495 | /* look up the state table for the current state */ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 496 | tBTA_AV_SST_TBL state_table = bta_av_sst_tbl[p_scb->state]; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 497 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 498 | /* set next state */ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 499 | event -= BTA_AV_FIRST_SSM_EVT; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 500 | p_scb->state = state_table[event][BTA_AV_SNEXT_STATE]; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 501 | |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 502 | APPL_TRACE_VERBOSE("%s: peer %s AV next state=%d(%s) p_scb=%p", __func__, |
Pavlin Radoslavov | a634f4e | 2018-04-23 13:36:33 -0700 | [diff] [blame] | 503 | p_scb->PeerAddress().ToString().c_str(), p_scb->state, |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 504 | bta_av_sst_code(p_scb->state), p_scb); |
| 505 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 506 | /* execute action functions */ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 507 | for (int i = 0; i < BTA_AV_SACTIONS; i++) { |
| 508 | uint8_t action = state_table[event][i]; |
Marie Janssen | f33b6f4 | 2016-11-22 15:01:42 -0800 | [diff] [blame] | 509 | if (action != BTA_AV_SIGNORE) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 510 | (*p_scb->p_act_tbl[action])(p_scb, p_data); |
| 511 | } else |
| 512 | break; |
| 513 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 517 | * |
| 518 | * Function bta_av_is_scb_opening |
| 519 | * |
| 520 | * Description Returns true is scb is in opening state. |
| 521 | * |
| 522 | * |
| 523 | * Returns true if scb is in opening state. |
| 524 | * |
| 525 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 526 | bool bta_av_is_scb_opening(tBTA_AV_SCB* p_scb) { |
| 527 | bool is_opening = false; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 528 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 529 | if (p_scb) { |
| 530 | if (p_scb->state == BTA_AV_OPENING_SST) is_opening = true; |
| 531 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 532 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 533 | return is_opening; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 537 | * |
| 538 | * Function bta_av_is_scb_incoming |
| 539 | * |
| 540 | * Description Returns true is scb is in incoming state. |
| 541 | * |
| 542 | * |
| 543 | * Returns true if scb is in incoming state. |
| 544 | * |
| 545 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 546 | bool bta_av_is_scb_incoming(tBTA_AV_SCB* p_scb) { |
| 547 | bool is_incoming = false; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 548 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 549 | if (p_scb) { |
| 550 | if (p_scb->state == BTA_AV_INCOMING_SST) is_incoming = true; |
| 551 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 552 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 553 | return is_incoming; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 557 | * |
| 558 | * Function bta_av_set_scb_sst_init |
| 559 | * |
| 560 | * Description Set SST state to INIT. |
| 561 | * Use this function to change SST outside of state machine. |
| 562 | * |
| 563 | * Returns None |
| 564 | * |
| 565 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 566 | void bta_av_set_scb_sst_init(tBTA_AV_SCB* p_scb) { |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 567 | if (p_scb == nullptr) { |
| 568 | return; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 569 | } |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 570 | |
| 571 | uint8_t next_state = BTA_AV_INIT_SST; |
| 572 | |
| 573 | APPL_TRACE_VERBOSE( |
| 574 | "%s: peer %s AV (hndl=0x%x) state=%d(%s) next state=%d(%s) p_scb=%p", |
Pavlin Radoslavov | a634f4e | 2018-04-23 13:36:33 -0700 | [diff] [blame] | 575 | __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->hndl, |
| 576 | p_scb->state, bta_av_sst_code(p_scb->state), next_state, |
| 577 | bta_av_sst_code(next_state), p_scb); |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 578 | |
| 579 | p_scb->state = next_state; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 583 | * |
| 584 | * Function bta_av_is_scb_init |
| 585 | * |
| 586 | * Description Returns true is scb is in init state. |
| 587 | * |
| 588 | * |
| 589 | * Returns true if scb is in incoming state. |
| 590 | * |
| 591 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 592 | bool bta_av_is_scb_init(tBTA_AV_SCB* p_scb) { |
| 593 | bool is_init = false; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 594 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 595 | if (p_scb) { |
| 596 | if (p_scb->state == BTA_AV_INIT_SST) is_init = true; |
| 597 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 598 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 599 | return is_init; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 600 | } |
| 601 | |
| 602 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 603 | * |
| 604 | * Function bta_av_set_scb_sst_incoming |
| 605 | * |
| 606 | * Description Set SST state to incoming. |
| 607 | * Use this function to change SST outside of state machine. |
| 608 | * |
| 609 | * Returns None |
| 610 | * |
| 611 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 612 | void bta_av_set_scb_sst_incoming(tBTA_AV_SCB* p_scb) { |
| 613 | if (p_scb) { |
| 614 | p_scb->state = BTA_AV_INCOMING_SST; |
| 615 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | /***************************************************************************** |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 619 | * Debug Functions |
| 620 | ****************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 621 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 622 | * |
| 623 | * Function bta_av_sst_code |
| 624 | * |
| 625 | * Description |
| 626 | * |
| 627 | * Returns char * |
| 628 | * |
| 629 | ******************************************************************************/ |
Pavlin Radoslavov | d752229 | 2017-11-24 19:12:11 -0800 | [diff] [blame] | 630 | const char* bta_av_sst_code(uint8_t state) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 631 | switch (state) { |
| 632 | case BTA_AV_INIT_SST: |
| 633 | return "INIT"; |
| 634 | case BTA_AV_INCOMING_SST: |
| 635 | return "INCOMING"; |
| 636 | case BTA_AV_OPENING_SST: |
| 637 | return "OPENING"; |
| 638 | case BTA_AV_OPEN_SST: |
| 639 | return "OPEN"; |
| 640 | case BTA_AV_RCFG_SST: |
| 641 | return "RCFG"; |
| 642 | case BTA_AV_CLOSING_SST: |
| 643 | return "CLOSING"; |
| 644 | default: |
| 645 | return "unknown"; |
| 646 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 647 | } |