diff options
author | Mattias Agren <magren@broadcom.com> | 2012-03-26 08:25:00 -0700 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-07-14 11:19:13 -0700 |
commit | 254588bfe6c3e70625b0f725b908598f30f476c8 (patch) | |
tree | 259c87422e70b74abeab96b3e3155c88791e5b6d /btif/src/btif_sm.c | |
parent | 3e6f399bdbaca7f8ab0a8b1c6eab7cc1088ab74a (diff) | |
download | external_bluetooth_bluedroid-254588bfe6c3e70625b0f725b908598f30f476c8.zip external_bluetooth_bluedroid-254588bfe6c3e70625b0f725b908598f30f476c8.tar.gz external_bluetooth_bluedroid-254588bfe6c3e70625b0f725b908598f30f476c8.tar.bz2 |
Added new control and data path interface between audioflinger a2dp HAL
and stack. Added support for suspend and a dedicated HAL callback
notifying framework on audiopath events. Cleanup.
Change-Id: I3b738611bc8e1d84794f7207413fd9e7dd1fc668
Diffstat (limited to 'btif/src/btif_sm.c')
-rw-r--r-- | btif/src/btif_sm.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/btif/src/btif_sm.c b/btif/src/btif_sm.c index 77d12d9..c260119 100644 --- a/btif/src/btif_sm.c +++ b/btif/src/btif_sm.c @@ -51,7 +51,7 @@ * Filename: btif_sm.c * * Description: Generic BTIF state machine API - * + * *****************************************************************************/ #include <hardware/bluetooth.h> @@ -69,8 +69,8 @@ ** Local type definitions ******************************************************************************/ typedef struct { - btif_sm_state_t state; - btif_sm_handler_t *p_handlers; + btif_sm_state_t state; + btif_sm_handler_t *p_handlers; } btif_sm_cb_t; /***************************************************************************** @@ -101,6 +101,7 @@ typedef struct { ** Returns Returns a pointer to the initialized state machine handle. ** ******************************************************************************/ + btif_sm_handle_t btif_sm_init(const btif_sm_handler_t *p_handlers, btif_sm_state_t initial_state) { btif_sm_cb_t *p_cb; @@ -117,7 +118,7 @@ btif_sm_handle_t btif_sm_init(const btif_sm_handler_t *p_handlers, btif_sm_state /* Send BTIF_SM_ENTER_EVT to the initial state */ p_cb->p_handlers[initial_state](BTIF_SM_ENTER_EVT, NULL); - + return (btif_sm_handle_t)p_cb; } @@ -170,12 +171,16 @@ btif_sm_state_t btif_sm_get_state(btif_sm_handle_t handle) ** ** Description Dispatches the 'event' along with 'data' to the current state handler ** -** Returns Returns BT_STATUS_OK on success, BT_STATUS_FAIL otherwise +** Returns BT_STATUS_SUCCESS on success +** BT_STATUS_UNHANDLED if event was not processed +** BT_STATUS_FAIL otherwise ** ******************************************************************************/ bt_status_t btif_sm_dispatch(btif_sm_handle_t handle, btif_sm_event_t event, void *data) { + bt_status_t status = BT_STATUS_SUCCESS; + btif_sm_cb_t *p_cb = (btif_sm_cb_t*)handle; if (p_cb == NULL) @@ -184,9 +189,10 @@ bt_status_t btif_sm_dispatch(btif_sm_handle_t handle, btif_sm_event_t event, return BT_STATUS_FAIL; } - p_cb->p_handlers[p_cb->state](event, data); + if (p_cb->p_handlers[p_cb->state](event, data) == FALSE) + return BT_STATUS_UNHANDLED; - return BT_STATUS_SUCCESS; + return status; } /***************************************************************************** @@ -197,11 +203,14 @@ bt_status_t btif_sm_dispatch(btif_sm_handle_t handle, btif_sm_event_t event, ** shall be invoked before exiting the current state. The ** 'BTIF_SM_ENTER_EVT' shall be invoked before entering the new state ** -** Returns Returns BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise +** Returns BT_STATUS_SUCCESS on success +** BT_STATUS_UNHANDLED if event was not processed +** BT_STATUS_FAIL otherwise ** ******************************************************************************/ bt_status_t btif_sm_change_state(btif_sm_handle_t handle, btif_sm_state_t state) { + bt_status_t status = BT_STATUS_SUCCESS; btif_sm_cb_t *p_cb = (btif_sm_cb_t*)handle; if (p_cb == NULL) @@ -211,13 +220,15 @@ bt_status_t btif_sm_change_state(btif_sm_handle_t handle, btif_sm_state_t state) } /* Send exit event to the current state */ - p_cb->p_handlers[p_cb->state](BTIF_SM_EXIT_EVT, NULL); + if (p_cb->p_handlers[p_cb->state](BTIF_SM_EXIT_EVT, NULL) == FALSE) + status = BT_STATUS_UNHANDLED; /* Change to the new state */ p_cb->state = state; /* Send enter event to the new state */ - p_cb->p_handlers[p_cb->state](BTIF_SM_ENTER_EVT, NULL); + if (p_cb->p_handlers[p_cb->state](BTIF_SM_ENTER_EVT, NULL) == FALSE) + status = BT_STATUS_UNHANDLED; - return BT_STATUS_SUCCESS; + return status; } |