Home | History | Annotate | Download | only in av
      1 /******************************************************************************
      2  *
      3  *  Copyright (C) 2004-2012 Broadcom Corporation
      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  ******************************************************************************/
     24 
     25 #include "bt_target.h"
     26 #if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
     27 
     28 #include <string.h>
     29 #include "bta_av_co.h"
     30 #include "bta_av_int.h"
     31 
     32 /*****************************************************************************
     33 ** Constants and types
     34 *****************************************************************************/
     35 
     36 /* state machine states */
     37 enum
     38 {
     39     BTA_AV_INIT_SST,
     40     BTA_AV_INCOMING_SST,
     41     BTA_AV_OPENING_SST,
     42     BTA_AV_OPEN_SST,
     43     BTA_AV_RCFG_SST,
     44     BTA_AV_CLOSING_SST
     45 };
     46 
     47 
     48 /* state machine action enumeration list */
     49 enum
     50 {
     51     BTA_AV_DO_DISC,
     52     BTA_AV_CLEANUP,
     53     BTA_AV_FREE_SDB,
     54     BTA_AV_CONFIG_IND,
     55     BTA_AV_DISCONNECT_REQ,
     56     BTA_AV_SECURITY_REQ,
     57     BTA_AV_SECURITY_RSP,
     58     BTA_AV_SETCONFIG_RSP,
     59     BTA_AV_ST_RC_TIMER,
     60     BTA_AV_STR_OPENED,
     61     BTA_AV_SECURITY_IND,
     62     BTA_AV_SECURITY_CFM,
     63     BTA_AV_DO_CLOSE,
     64     BTA_AV_CONNECT_REQ,
     65     BTA_AV_SDP_FAILED,
     66     BTA_AV_DISC_RESULTS,
     67     BTA_AV_DISC_RES_AS_ACP,
     68     BTA_AV_OPEN_FAILED,
     69     BTA_AV_GETCAP_RESULTS,
     70     BTA_AV_SETCONFIG_REJ,
     71     BTA_AV_DISCOVER_REQ,
     72     BTA_AV_CONN_FAILED,
     73     BTA_AV_DO_START,
     74     BTA_AV_STR_STOPPED,
     75     BTA_AV_RECONFIG,
     76     BTA_AV_DATA_PATH,
     77     BTA_AV_START_OK,
     78     BTA_AV_START_FAILED,
     79     BTA_AV_STR_CLOSED,
     80     BTA_AV_CLR_CONG,
     81     BTA_AV_SUSPEND_CFM,
     82     BTA_AV_RCFG_STR_OK,
     83     BTA_AV_RCFG_FAILED,
     84     BTA_AV_RCFG_CONNECT,
     85     BTA_AV_RCFG_DISCNTD,
     86     BTA_AV_SUSPEND_CONT,
     87     BTA_AV_RCFG_CFM,
     88     BTA_AV_RCFG_OPEN,
     89     BTA_AV_SECURITY_REJ,
     90     BTA_AV_OPEN_RC,
     91     BTA_AV_CHK_2ND_START,
     92     BTA_AV_SAVE_CAPS,
     93     BTA_AV_SET_USE_RC,
     94     BTA_AV_CCO_CLOSE,
     95     BTA_AV_SWITCH_ROLE,
     96     BTA_AV_ROLE_RES,
     97     BTA_AV_DELAY_CO,
     98     BTA_AV_OPEN_AT_INC,
     99     BTA_AV_OFFLOAD_REQ,
    100     BTA_AV_OFFLOAD_RSP,
    101     BTA_AV_NUM_SACTIONS
    102 };
    103 
    104 #define BTA_AV_SIGNORE       BTA_AV_NUM_SACTIONS
    105 
    106 
    107 /* state table information */
    108 /* #define BTA_AV_SACTION_COL           0       position of actions */
    109 #define BTA_AV_SACTIONS              2       /* number of actions */
    110 #define BTA_AV_SNEXT_STATE           2       /* position of next state */
    111 #define BTA_AV_NUM_COLS              3       /* number of columns in state tables */
    112 
    113 /* state table for init state */
    114 static const UINT8 bta_av_sst_init[][BTA_AV_NUM_COLS] =
    115 {
    116 /* Event                     Action 1               Action 2               Next state */
    117 /* AP_OPEN_EVT */           {BTA_AV_DO_DISC,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    118 /* AP_CLOSE_EVT */          {BTA_AV_CLEANUP,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    119 /* AP_START_EVT */          {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    120 /* AP_STOP_EVT */           {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    121 /* API_RECONFIG_EVT */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    122 /* API_PROTECT_REQ_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    123 /* API_PROTECT_RSP_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    124 /* API_RC_OPEN_EVT  */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    125 /* SRC_DATA_READY_EVT */    {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    126 /* CI_SETCONFIG_OK_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    127 /* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    128 /* SDP_DISC_OK_EVT */       {BTA_AV_FREE_SDB,       BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    129 /* SDP_DISC_FAIL_EVT */     {BTA_AV_FREE_SDB,       BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    130 /* STR_DISC_OK_EVT */       {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    131 /* STR_DISC_FAIL_EVT */     {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    132 /* STR_GETCAP_OK_EVT */     {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    133 /* STR_GETCAP_FAIL_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    134 /* STR_OPEN_OK_EVT */       {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    135 /* STR_OPEN_FAIL_EVT */     {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    136 /* STR_START_OK_EVT */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    137 /* STR_START_FAIL_EVT */    {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    138 /* STR_CLOSE_EVT */         {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    139 /* STR_CONFIG_IND_EVT */    {BTA_AV_SETCONFIG_REJ,  BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    140 /* STR_SECURITY_IND_EVT */  {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    141 /* STR_SECURITY_CFM_EVT */  {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    142 /* STR_WRITE_CFM_EVT */     {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    143 /* STR_SUSPEND_CFM_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    144 /* STR_RECONFIG_CFM_EVT */  {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    145 /* AVRC_TIMER_EVT */        {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    146 /* AVDT_CONNECT_EVT */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    147 /* AVDT_DISCONNECT_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    148 /* ROLE_CHANGE_EVT*/        {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    149 /* AVDT_DELAY_RPT_EVT */    {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    150 /* ACP_CONNECT_EVT */       {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    151 /* API_OFFLOAD_START_EVT */{BTA_AV_OFFLOAD_REQ,    BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    152 /* API_OFFLOAD_START_RSP_EVT */{BTA_AV_OFFLOAD_RSP,    BTA_AV_SIGNORE,        BTA_AV_INIT_SST }
    153 };
    154 
    155 /* state table for incoming state */
    156 static const UINT8 bta_av_sst_incoming[][BTA_AV_NUM_COLS] =
    157 {
    158 /* Event                     Action 1               Action 2               Next state */
    159 /* AP_OPEN_EVT */           {BTA_AV_OPEN_AT_INC,    BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    160 /* AP_CLOSE_EVT */          {BTA_AV_CCO_CLOSE,      BTA_AV_DISCONNECT_REQ, BTA_AV_CLOSING_SST },
    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 },
    163 /* API_RECONFIG_EVT */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    164 /* API_PROTECT_REQ_EVT */   {BTA_AV_SECURITY_REQ,   BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    165 /* API_PROTECT_RSP_EVT */   {BTA_AV_SECURITY_RSP,   BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    166 /* API_RC_OPEN_EVT  */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    167 /* SRC_DATA_READY_EVT */    {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    168 /* CI_SETCONFIG_OK_EVT */   {BTA_AV_SETCONFIG_RSP,  BTA_AV_ST_RC_TIMER,    BTA_AV_INCOMING_SST },
    169 /* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SETCONFIG_REJ,  BTA_AV_CLEANUP,        BTA_AV_INIT_SST },
    170 /* SDP_DISC_OK_EVT */       {BTA_AV_FREE_SDB,       BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    171 /* SDP_DISC_FAIL_EVT */     {BTA_AV_FREE_SDB,       BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    172 /* STR_DISC_OK_EVT */       {BTA_AV_DISC_RES_AS_ACP,BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    173 /* STR_DISC_FAIL_EVT */     {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    174 /* STR_GETCAP_OK_EVT */     {BTA_AV_SAVE_CAPS,      BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    175 /* STR_GETCAP_FAIL_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    176 /* STR_OPEN_OK_EVT */       {BTA_AV_STR_OPENED,     BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    177 /* STR_OPEN_FAIL_EVT */     {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    178 /* STR_START_OK_EVT */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    179 /* STR_START_FAIL_EVT */    {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    180 /* STR_CLOSE_EVT */         {BTA_AV_CCO_CLOSE,      BTA_AV_CLEANUP,        BTA_AV_INIT_SST },
    181 /* STR_CONFIG_IND_EVT */    {BTA_AV_CONFIG_IND,     BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    182 /* STR_SECURITY_IND_EVT */  {BTA_AV_SECURITY_IND,   BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    183 /* STR_SECURITY_CFM_EVT */  {BTA_AV_SECURITY_CFM,   BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    184 /* STR_WRITE_CFM_EVT */     {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    185 /* STR_SUSPEND_CFM_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    186 /* STR_RECONFIG_CFM_EVT */  {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    187 /* AVRC_TIMER_EVT */        {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    188 /* AVDT_CONNECT_EVT */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    189 /* AVDT_DISCONNECT_EVT */   {BTA_AV_CCO_CLOSE,      BTA_AV_DISCONNECT_REQ, BTA_AV_CLOSING_SST },
    190 /* ROLE_CHANGE_EVT*/        {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    191 /* AVDT_DELAY_RPT_EVT */    {BTA_AV_DELAY_CO,       BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    192 /* ACP_CONNECT_EVT */       {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    193 /* API_OFFLOAD_START_EVT */{BTA_AV_OFFLOAD_REQ,    BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    194 /* API_OFFLOAD_START_RSP_EVT */{BTA_AV_OFFLOAD_RSP,    BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST }
    195 };
    196 
    197 /* state table for opening state */
    198 static const UINT8 bta_av_sst_opening[][BTA_AV_NUM_COLS] =
    199 {
    200 /* Event                     Action 1               Action 2               Next state */
    201 /* AP_OPEN_EVT */           {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    202 /* AP_CLOSE_EVT */          {BTA_AV_DO_CLOSE,       BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    203 /* AP_START_EVT */          {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    204 /* AP_STOP_EVT */           {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    205 /* API_RECONFIG_EVT */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    206 /* API_PROTECT_REQ_EVT */   {BTA_AV_SECURITY_REQ,   BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    207 /* API_PROTECT_RSP_EVT */   {BTA_AV_SECURITY_RSP,   BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    208 /* API_RC_OPEN_EVT  */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    209 /* SRC_DATA_READY_EVT */    {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    210 /* CI_SETCONFIG_OK_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    211 /* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    212 /* SDP_DISC_OK_EVT */       {BTA_AV_CONNECT_REQ,    BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    213 /* SDP_DISC_FAIL_EVT */     {BTA_AV_CONNECT_REQ,    BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    214 /* STR_DISC_OK_EVT */       {BTA_AV_DISC_RESULTS,   BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    215 /* STR_DISC_FAIL_EVT */     {BTA_AV_OPEN_FAILED,    BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    216 /* STR_GETCAP_OK_EVT */     {BTA_AV_GETCAP_RESULTS, BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    217 /* STR_GETCAP_FAIL_EVT */   {BTA_AV_OPEN_FAILED,    BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    218 /* STR_OPEN_OK_EVT */       {BTA_AV_ST_RC_TIMER,    BTA_AV_STR_OPENED,     BTA_AV_OPEN_SST },
    219 /* STR_OPEN_FAIL_EVT */     {BTA_AV_OPEN_FAILED,    BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    220 /* STR_START_OK_EVT */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    221 /* STR_START_FAIL_EVT */    {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    222 /* STR_CLOSE_EVT */         {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    223 /* STR_CONFIG_IND_EVT */    {BTA_AV_CONFIG_IND,     BTA_AV_SIGNORE,        BTA_AV_INCOMING_SST },
    224 /* STR_SECURITY_IND_EVT */  {BTA_AV_SECURITY_IND,   BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    225 /* STR_SECURITY_CFM_EVT */  {BTA_AV_SECURITY_CFM,   BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    226 /* STR_WRITE_CFM_EVT */     {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    227 /* STR_SUSPEND_CFM_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    228 /* STR_RECONFIG_CFM_EVT */  {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    229 /* AVRC_TIMER_EVT */        {BTA_AV_SWITCH_ROLE,    BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    230 /* AVDT_CONNECT_EVT */      {BTA_AV_DISCOVER_REQ,   BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    231 /* AVDT_DISCONNECT_EVT */   {BTA_AV_CONN_FAILED,    BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    232 /* ROLE_CHANGE_EVT*/        {BTA_AV_ROLE_RES,       BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    233 /* AVDT_DELAY_RPT_EVT */    {BTA_AV_DELAY_CO,       BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    234 /* ACP_CONNECT_EVT */       {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    235 /* API_OFFLOAD_START_EVT */{BTA_AV_OFFLOAD_REQ,    BTA_AV_SIGNORE,        BTA_AV_OPENING_SST },
    236 /* API_OFFLOAD_START_RSP_EVT */{BTA_AV_OFFLOAD_RSP,    BTA_AV_SIGNORE,        BTA_AV_OPENING_SST }
    237 };
    238 
    239 /* state table for open state */
    240 static const UINT8 bta_av_sst_open[][BTA_AV_NUM_COLS] =
    241 {
    242 /* Event                     Action 1               Action 2               Next state */
    243 /* AP_OPEN_EVT */           {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    244 /* AP_CLOSE_EVT */          {BTA_AV_DO_CLOSE,       BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    245 /* AP_START_EVT */          {BTA_AV_DO_START,       BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    246 /* AP_STOP_EVT */           {BTA_AV_STR_STOPPED,    BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    247 /* API_RECONFIG_EVT */      {BTA_AV_RECONFIG,       BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    248 /* API_PROTECT_REQ_EVT */   {BTA_AV_SECURITY_REQ,   BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    249 /* API_PROTECT_RSP_EVT */   {BTA_AV_SECURITY_RSP,   BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    250 /* API_RC_OPEN_EVT  */      {BTA_AV_SET_USE_RC,     BTA_AV_OPEN_RC,        BTA_AV_OPEN_SST },
    251 /* SRC_DATA_READY_EVT */    {BTA_AV_DATA_PATH,      BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    252 /* CI_SETCONFIG_OK_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    253 /* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    254 /* SDP_DISC_OK_EVT */       {BTA_AV_FREE_SDB,       BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    255 /* SDP_DISC_FAIL_EVT */     {BTA_AV_FREE_SDB,       BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    256 /* STR_DISC_OK_EVT */       {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    257 /* STR_DISC_FAIL_EVT */     {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    258 /* STR_GETCAP_OK_EVT */     {BTA_AV_SAVE_CAPS,      BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    259 /* STR_GETCAP_FAIL_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    260 /* STR_OPEN_OK_EVT */       {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    261 /* STR_OPEN_FAIL_EVT */     {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    262 /* STR_START_OK_EVT */      {BTA_AV_START_OK,       BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    263 /* STR_START_FAIL_EVT */    {BTA_AV_START_FAILED,   BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    264 /* STR_CLOSE_EVT */         {BTA_AV_STR_CLOSED,     BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    265 /* STR_CONFIG_IND_EVT */    {BTA_AV_SETCONFIG_REJ,  BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    266 /* STR_SECURITY_IND_EVT */  {BTA_AV_SECURITY_IND,   BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    267 /* STR_SECURITY_CFM_EVT */  {BTA_AV_SECURITY_CFM,   BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    268 /* STR_WRITE_CFM_EVT */     {BTA_AV_CLR_CONG,       BTA_AV_DATA_PATH,      BTA_AV_OPEN_SST },
    269 /* STR_SUSPEND_CFM_EVT */   {BTA_AV_SUSPEND_CFM,    BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    270 /* STR_RECONFIG_CFM_EVT */  {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    271 /* AVRC_TIMER_EVT */        {BTA_AV_OPEN_RC,        BTA_AV_CHK_2ND_START,  BTA_AV_OPEN_SST },
    272 /* AVDT_CONNECT_EVT */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    273 /* AVDT_DISCONNECT_EVT */   {BTA_AV_STR_CLOSED,     BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    274 /* ROLE_CHANGE_EVT*/        {BTA_AV_ROLE_RES,       BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    275 /* AVDT_DELAY_RPT_EVT */    {BTA_AV_DELAY_CO,       BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    276 /* ACP_CONNECT_EVT */       {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    277 /* API_OFFLOAD_START_EVT */{BTA_AV_OFFLOAD_REQ,    BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    278 /* API_OFFLOAD_START_RSP_EVT */{BTA_AV_OFFLOAD_RSP,    BTA_AV_SIGNORE,        BTA_AV_OPEN_SST }
    279 };
    280 
    281 /* state table for reconfig state */
    282 static const UINT8 bta_av_sst_rcfg[][BTA_AV_NUM_COLS] =
    283 {
    284 /* Event                     Action 1               Action 2               Next state */
    285 /* AP_OPEN_EVT */           {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    286 /* AP_CLOSE_EVT */          {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    287 /* AP_START_EVT */          {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    288 /* AP_STOP_EVT */           {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    289 /* API_RECONFIG_EVT */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    290 /* API_PROTECT_REQ_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    291 /* API_PROTECT_RSP_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    292 /* API_RC_OPEN_EVT  */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    293 /* SRC_DATA_READY_EVT */    {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    294 /* CI_SETCONFIG_OK_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    295 /* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    296 /* SDP_DISC_OK_EVT */       {BTA_AV_FREE_SDB,       BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    297 /* SDP_DISC_FAIL_EVT */     {BTA_AV_FREE_SDB,       BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    298 /* STR_DISC_OK_EVT */       {BTA_AV_DISC_RESULTS,   BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    299 /* STR_DISC_FAIL_EVT */     {BTA_AV_STR_CLOSED,     BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    300 /* STR_GETCAP_OK_EVT */     {BTA_AV_GETCAP_RESULTS, BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    301 /* STR_GETCAP_FAIL_EVT */   {BTA_AV_STR_CLOSED,     BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    302 /* STR_OPEN_OK_EVT */       {BTA_AV_RCFG_STR_OK,    BTA_AV_SIGNORE,        BTA_AV_OPEN_SST },
    303 /* STR_OPEN_FAIL_EVT */     {BTA_AV_RCFG_FAILED,    BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    304 /* STR_START_OK_EVT */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    305 /* STR_START_FAIL_EVT */    {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    306 /* STR_CLOSE_EVT */         {BTA_AV_RCFG_CONNECT,   BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    307 /* STR_CONFIG_IND_EVT */    {BTA_AV_SETCONFIG_REJ,  BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    308 /* STR_SECURITY_IND_EVT */  {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    309 /* STR_SECURITY_CFM_EVT */  {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    310 /* STR_WRITE_CFM_EVT */     {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    311 /* STR_SUSPEND_CFM_EVT */   {BTA_AV_SUSPEND_CFM,    BTA_AV_SUSPEND_CONT,   BTA_AV_RCFG_SST },
    312 /* STR_RECONFIG_CFM_EVT */  {BTA_AV_RCFG_CFM,       BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    313 /* AVRC_TIMER_EVT */        {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    314 /* AVDT_CONNECT_EVT */      {BTA_AV_RCFG_OPEN,      BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    315 /* AVDT_DISCONNECT_EVT */   {BTA_AV_RCFG_DISCNTD,   BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    316 /* ROLE_CHANGE_EVT*/        {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    317 /* AVDT_DELAY_RPT_EVT */    {BTA_AV_DELAY_CO,       BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    318 /* ACP_CONNECT_EVT */       {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    319 /* API_OFFLOAD_START_EVT */{BTA_AV_OFFLOAD_REQ,    BTA_AV_SIGNORE,        BTA_AV_RCFG_SST },
    320 /* API_OFFLOAD_START_RSP_EVT */{BTA_AV_OFFLOAD_RSP,    BTA_AV_SIGNORE,        BTA_AV_RCFG_SST }
    321 };
    322 
    323 /* state table for closing state */
    324 static const UINT8 bta_av_sst_closing[][BTA_AV_NUM_COLS] =
    325 {
    326 /* Event                     Action 1               Action 2               Next state */
    327 /* AP_OPEN_EVT */           {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    328 /* AP_CLOSE_EVT */          {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    329 /* AP_START_EVT */          {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    330 /* AP_STOP_EVT */           {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    331 /* API_RECONFIG_EVT */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    332 /* API_PROTECT_REQ_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    333 /* API_PROTECT_RSP_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    334 /* API_RC_OPEN_EVT  */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    335 /* SRC_DATA_READY_EVT */    {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    336 /* CI_SETCONFIG_OK_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    337 /* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    338 /* SDP_DISC_OK_EVT */       {BTA_AV_SDP_FAILED,     BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    339 /* SDP_DISC_FAIL_EVT */     {BTA_AV_SDP_FAILED,     BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    340 /* STR_DISC_OK_EVT */       {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    341 /* STR_DISC_FAIL_EVT */     {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    342 /* STR_GETCAP_OK_EVT */     {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    343 /* STR_GETCAP_FAIL_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    344 /* STR_OPEN_OK_EVT */       {BTA_AV_DO_CLOSE,       BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    345 /* STR_OPEN_FAIL_EVT */     {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    346 /* STR_START_OK_EVT */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    347 /* STR_START_FAIL_EVT */    {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    348 /* STR_CLOSE_EVT */         {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    349 /* STR_CONFIG_IND_EVT */    {BTA_AV_SETCONFIG_REJ,  BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    350 /* STR_SECURITY_IND_EVT */  {BTA_AV_SECURITY_REJ,   BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    351 /* STR_SECURITY_CFM_EVT */  {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    352 /* STR_WRITE_CFM_EVT */     {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    353 /* STR_SUSPEND_CFM_EVT */   {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    354 /* STR_RECONFIG_CFM_EVT */  {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    355 /* AVRC_TIMER_EVT */        {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    356 /* AVDT_CONNECT_EVT */      {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    357 /* AVDT_DISCONNECT_EVT */   {BTA_AV_STR_CLOSED,     BTA_AV_SIGNORE,        BTA_AV_INIT_SST },
    358 /* ROLE_CHANGE_EVT*/        {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    359 /* AVDT_DELAY_RPT_EVT */    {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    360 /* ACP_CONNECT_EVT */       {BTA_AV_SIGNORE,        BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    361 /* API_OFFLOAD_START_EVT */{BTA_AV_OFFLOAD_REQ,    BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST },
    362 /* API_OFFLOAD_START_RSP_EVT */{BTA_AV_OFFLOAD_RSP,    BTA_AV_SIGNORE,        BTA_AV_CLOSING_SST }
    363 };
    364 
    365 /* type for state table */
    366 typedef const UINT8 (*tBTA_AV_SST_TBL)[BTA_AV_NUM_COLS];
    367 
    368 /* state table */
    369 static const tBTA_AV_SST_TBL bta_av_sst_tbl[] =
    370 {
    371     bta_av_sst_init,
    372     bta_av_sst_incoming,
    373     bta_av_sst_opening,
    374     bta_av_sst_open,
    375     bta_av_sst_rcfg,
    376     bta_av_sst_closing
    377 };
    378 
    379 
    380 
    381 #if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE)
    382 static char *bta_av_sst_code(UINT8 state);
    383 #endif
    384 
    385 /*******************************************************************************
    386 **
    387 ** Function         bta_av_is_rcfg_sst
    388 **
    389 ** Description      Check if stream state machine is in reconfig state.
    390 **
    391 **
    392 ** Returns          TRUE if stream state machine is in reconfig state.
    393 **
    394 *******************************************************************************/
    395 BOOLEAN bta_av_is_rcfg_sst (tBTA_AV_SCB *p_scb)
    396 {
    397     BOOLEAN is_rcfg_sst = FALSE;
    398 
    399     if (p_scb != NULL)
    400     {
    401         if (p_scb->state == BTA_AV_RCFG_SST)
    402             is_rcfg_sst = TRUE;
    403     }
    404 
    405     return is_rcfg_sst;
    406 }
    407 
    408 /*******************************************************************************
    409 **
    410 ** Function         bta_av_ssm_execute
    411 **
    412 ** Description      Stream state machine event handling function for AV
    413 **
    414 **
    415 ** Returns          void
    416 **
    417 *******************************************************************************/
    418 void bta_av_ssm_execute(tBTA_AV_SCB *p_scb, UINT16 event, tBTA_AV_DATA *p_data)
    419 {
    420     tBTA_AV_SST_TBL     state_table;
    421     UINT8               action;
    422     int                 i, xx;
    423 
    424     if(p_scb == NULL)
    425     {
    426         /* this stream is not registered */
    427         APPL_TRACE_EVENT("AV channel not registered");
    428         return;
    429     }
    430 
    431     /* In case incoming connection is for VDP, we need to swap scb.        */
    432     /* When ACP_CONNECT_EVT was received, we put first available scb to    */
    433     /* to Incoming state. Later, when STR_CONFIG_IND_EVT is coming, we     */
    434     /* know if it is A2DP or VDP.                                          */
    435     if ((p_scb->state == BTA_AV_INIT_SST) && (event == BTA_AV_STR_CONFIG_IND_EVT))
    436     {
    437         for (xx = 0; xx < BTA_AV_NUM_STRS; xx++)
    438         {
    439             if (bta_av_cb.p_scb[xx])
    440             {
    441                 if (bta_av_cb.p_scb[xx]->state == BTA_AV_INCOMING_SST)
    442                 {
    443                     bta_av_cb.p_scb[xx]->state = BTA_AV_INIT_SST;
    444                     bta_av_cb.p_scb[xx]->coll_mask = 0;
    445                     p_scb->state = BTA_AV_INCOMING_SST;
    446                     break;
    447                 }
    448             }
    449         }
    450     }
    451 
    452 #if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE)
    453     APPL_TRACE_VERBOSE("AV Sevent(0x%x)=0x%x(%s) state=%d(%s)",
    454         p_scb->hndl, event, bta_av_evt_code(event), p_scb->state, bta_av_sst_code(p_scb->state));
    455 #else
    456     APPL_TRACE_VERBOSE("AV Sevent=0x%x state=%d", event, p_scb->state);
    457 #endif
    458 
    459     /* look up the state table for the current state */
    460     state_table = bta_av_sst_tbl[p_scb->state];
    461 
    462     event -= BTA_AV_FIRST_SSM_EVT;
    463 
    464     /* set next state */
    465     p_scb->state = state_table[event][BTA_AV_SNEXT_STATE];
    466 
    467     /* execute action functions */
    468     for(i=0; i< BTA_AV_SACTIONS; i++)
    469     {
    470         if ((action = state_table[event][i]) != BTA_AV_SIGNORE)
    471         {
    472             (*p_scb->p_act_tbl[action])(p_scb, p_data);
    473         }
    474         else
    475             break;
    476     }
    477 
    478 }
    479 
    480 /*******************************************************************************
    481 **
    482 ** Function         bta_av_is_scb_opening
    483 **
    484 ** Description      Returns TRUE is scb is in opening state.
    485 **
    486 **
    487 ** Returns          TRUE if scb is in opening state.
    488 **
    489 *******************************************************************************/
    490 BOOLEAN bta_av_is_scb_opening (tBTA_AV_SCB *p_scb)
    491 {
    492     BOOLEAN is_opening = FALSE;
    493 
    494     if (p_scb)
    495     {
    496         if (p_scb->state == BTA_AV_OPENING_SST)
    497             is_opening = TRUE;
    498     }
    499 
    500     return is_opening;
    501 }
    502 
    503 /*******************************************************************************
    504 **
    505 ** Function         bta_av_is_scb_incoming
    506 **
    507 ** Description      Returns TRUE is scb is in incoming state.
    508 **
    509 **
    510 ** Returns          TRUE if scb is in incoming state.
    511 **
    512 *******************************************************************************/
    513 BOOLEAN bta_av_is_scb_incoming (tBTA_AV_SCB *p_scb)
    514 {
    515     BOOLEAN is_incoming = FALSE;
    516 
    517     if (p_scb)
    518     {
    519         if (p_scb->state == BTA_AV_INCOMING_SST)
    520             is_incoming = TRUE;
    521     }
    522 
    523     return is_incoming;
    524 }
    525 
    526 /*******************************************************************************
    527 **
    528 ** Function         bta_av_set_scb_sst_init
    529 **
    530 ** Description      Set SST state to INIT.
    531 **                  Use this function to change SST outside of state machine.
    532 **
    533 ** Returns          None
    534 **
    535 *******************************************************************************/
    536 void bta_av_set_scb_sst_init (tBTA_AV_SCB *p_scb)
    537 {
    538     if (p_scb)
    539     {
    540         p_scb->state = BTA_AV_INIT_SST;
    541     }
    542 }
    543 
    544 /*******************************************************************************
    545 **
    546 ** Function         bta_av_is_scb_init
    547 **
    548 ** Description      Returns TRUE is scb is in init state.
    549 **
    550 **
    551 ** Returns          TRUE if scb is in incoming state.
    552 **
    553 *******************************************************************************/
    554 BOOLEAN bta_av_is_scb_init (tBTA_AV_SCB *p_scb)
    555 {
    556     BOOLEAN is_init = FALSE;
    557 
    558     if (p_scb)
    559     {
    560         if (p_scb->state == BTA_AV_INIT_SST)
    561             is_init = TRUE;
    562     }
    563 
    564     return is_init;
    565 }
    566 
    567 /*******************************************************************************
    568 **
    569 ** Function         bta_av_set_scb_sst_incoming
    570 **
    571 ** Description      Set SST state to incoming.
    572 **                  Use this function to change SST outside of state machine.
    573 **
    574 ** Returns          None
    575 **
    576 *******************************************************************************/
    577 void bta_av_set_scb_sst_incoming (tBTA_AV_SCB *p_scb)
    578 {
    579     if (p_scb)
    580     {
    581         p_scb->state = BTA_AV_INCOMING_SST;
    582     }
    583 }
    584 
    585 /*****************************************************************************
    586 **  Debug Functions
    587 *****************************************************************************/
    588 #if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE)
    589 /*******************************************************************************
    590 **
    591 ** Function         bta_av_sst_code
    592 **
    593 ** Description
    594 **
    595 ** Returns          char *
    596 **
    597 *******************************************************************************/
    598 static char *bta_av_sst_code(UINT8 state)
    599 {
    600     switch(state)
    601     {
    602     case BTA_AV_INIT_SST: return "INIT";
    603     case BTA_AV_INCOMING_SST: return "INCOMING";
    604     case BTA_AV_OPENING_SST: return "OPENING";
    605     case BTA_AV_OPEN_SST: return "OPEN";
    606     case BTA_AV_RCFG_SST: return "RCFG";
    607     case BTA_AV_CLOSING_SST: return "CLOSING";
    608     default:             return "unknown";
    609     }
    610 }
    611 
    612 #endif
    613 #endif /* BTA_AV_INCLUDED */
    614