summaryrefslogtreecommitdiffstats
path: root/btif/src
diff options
context:
space:
mode:
Diffstat (limited to 'btif/src')
-rw-r--r--btif/src/bluetooth.c78
-rw-r--r--btif/src/btif_av.c576
-rw-r--r--btif/src/btif_core.c172
-rw-r--r--[-rwxr-xr-x]btif/src/btif_dm.c116
-rw-r--r--btif/src/btif_hf.c117
-rw-r--r--btif/src/btif_media_task.c616
-rw-r--r--btif/src/btif_rc.c42
-rw-r--r--btif/src/btif_sm.c33
-rw-r--r--btif/src/btif_storage.c154
-rw-r--r--btif/src/btif_util.c103
10 files changed, 1352 insertions, 655 deletions
diff --git a/btif/src/bluetooth.c b/btif/src/bluetooth.c
index 0b839ac..2480e28 100644
--- a/btif/src/bluetooth.c
+++ b/btif/src/bluetooth.c
@@ -3,44 +3,44 @@
* Copyright (C) 2009-2012 Broadcom Corporation
*
* This program is the proprietary software of Broadcom Corporation and/or its
- * licensors, and may only be used, duplicated, modified or distributed
- * pursuant to the terms and conditions of a separate, written license
- * agreement executed between you and Broadcom (an "Authorized License").
- * Except as set forth in an Authorized License, Broadcom grants no license
- * (express or implied), right to use, or waiver of any kind with respect to
- * the Software, and Broadcom expressly reserves all rights in and to the
- * Software and all intellectual property rights therein.
- * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
- * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
- * ALL USE OF THE SOFTWARE.
+ * licensors, and may only be used, duplicated, modified or distributed
+ * pursuant to the terms and conditions of a separate, written license
+ * agreement executed between you and Broadcom (an "Authorized License").
+ * Except as set forth in an Authorized License, Broadcom grants no license
+ * (express or implied), right to use, or waiver of any kind with respect to
+ * the Software, and Broadcom expressly reserves all rights in and to the
+ * Software and all intellectual property rights therein.
+ * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
+ * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
+ * ALL USE OF THE SOFTWARE.
*
* Except as expressly set forth in the Authorized License,
*
- * 1. This program, including its structure, sequence and organization,
- * constitutes the valuable trade secrets of Broadcom, and you shall
- * use all reasonable efforts to protect the confidentiality thereof,
- * and to use this information only in connection with your use of
+ * 1. This program, including its structure, sequence and organization,
+ * constitutes the valuable trade secrets of Broadcom, and you shall
+ * use all reasonable efforts to protect the confidentiality thereof,
+ * and to use this information only in connection with your use of
* Broadcom integrated circuit products.
*
- * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
- * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
- * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
- * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
- * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
- * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
- * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
+ * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
+ * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
+ * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
+ * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
+ * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
+ * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
+ * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
* CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT
* OF USE OR PERFORMANCE OF THE SOFTWARE.
*
* 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR
- * ITS LICENSORS BE LIABLE FOR
- * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
- * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
- * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
- * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
- * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
- * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
- * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
+ * ITS LICENSORS BE LIABLE FOR
+ * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
+ * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
+ * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
+ * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
+ * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
+ * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
+ * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
* ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
*
************************************************************************************/
@@ -50,7 +50,7 @@
* Filename: bluetooth.c
*
* Description: Bluetooth HAL implementation
- *
+ *
***********************************************************************************/
#include <stdio.h>
@@ -63,8 +63,8 @@
#define LOG_NDDEBUG 0
#define LOG_TAG "bluedroid"
-
-#include "btif_api.h"
+
+#include "btif_api.h"
/************************************************************************************
** Constants & Macros
@@ -121,6 +121,10 @@ static int init(bt_callbacks_t* callbacks )
{
LOGI("init");
+ /* sanity check */
+ if (interface_ready() == TRUE)
+ return BT_STATUS_DONE;
+
/* store reference to user callbacks */
bt_hal_cbacks = callbacks;
@@ -307,7 +311,7 @@ static const void* get_profile_interface (const char *profile_id)
if (is_profile(profile_id, BT_PROFILE_ADVANCED_AUDIO_ID))
return btif_av_get_interface();
-
+
return NULL;
}
@@ -330,15 +334,15 @@ static const bt_interface_t bluetoothInterface = {
remove_bond,
cancel_bond,
pin_reply,
- ssp_reply,
+ ssp_reply,
get_profile_interface
};
const bt_interface_t* bluetooth__get_bluetooth_interface ()
{
/* fixme -- add property to disable bt interface ? */
-
- return &bluetoothInterface;
+
+ return &bluetoothInterface;
}
static int close_bluetooth_stack(struct hw_device_t* device)
@@ -358,7 +362,7 @@ struct hw_device_t** abstraction)
stack->common.close = close_bluetooth_stack;
stack->get_bluetooth_interface = bluetooth__get_bluetooth_interface;
*abstraction = (struct hw_device_t*)stack;
- return 0;
+ return 0;
}
diff --git a/btif/src/btif_av.c b/btif/src/btif_av.c
index a822c7f..87ee8fb 100644
--- a/btif/src/btif_av.c
+++ b/btif/src/btif_av.c
@@ -3,44 +3,44 @@
* Copyright (C) 2009-2012 Broadcom Corporation
*
* This program is the proprietary software of Broadcom Corporation and/or its
- * licensors, and may only be used, duplicated, modified or distributed
- * pursuant to the terms and conditions of a separate, written license
- * agreement executed between you and Broadcom (an "Authorized License").
- * Except as set forth in an Authorized License, Broadcom grants no license
- * (express or implied), right to use, or waiver of any kind with respect to
- * the Software, and Broadcom expressly reserves all rights in and to the
- * Software and all intellectual property rights therein.
- * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
- * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
- * ALL USE OF THE SOFTWARE.
+ * licensors, and may only be used, duplicated, modified or distributed
+ * pursuant to the terms and conditions of a separate, written license
+ * agreement executed between you and Broadcom (an "Authorized License").
+ * Except as set forth in an Authorized License, Broadcom grants no license
+ * (express or implied), right to use, or waiver of any kind with respect to
+ * the Software, and Broadcom expressly reserves all rights in and to the
+ * Software and all intellectual property rights therein.
+ * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
+ * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
+ * ALL USE OF THE SOFTWARE.
*
* Except as expressly set forth in the Authorized License,
*
- * 1. This program, including its structure, sequence and organization,
- * constitutes the valuable trade secrets of Broadcom, and you shall
- * use all reasonable efforts to protect the confidentiality thereof,
- * and to use this information only in connection with your use of
+ * 1. This program, including its structure, sequence and organization,
+ * constitutes the valuable trade secrets of Broadcom, and you shall
+ * use all reasonable efforts to protect the confidentiality thereof,
+ * and to use this information only in connection with your use of
* Broadcom integrated circuit products.
*
- * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
- * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
- * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
- * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
- * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
- * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
- * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
+ * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
+ * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
+ * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
+ * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
+ * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
+ * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
+ * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
* CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING
* OUT OF USE OR PERFORMANCE OF THE SOFTWARE.
*
* 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM
- * OR ITS LICENSORS BE LIABLE FOR
- * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
- * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
+ * OR ITS LICENSORS BE LIABLE FOR
+ * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
+ * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
* YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
- * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
- * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
- * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
- * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
+ * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
+ * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
+ * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
+ * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
* ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
*
*****************************************************************************/
@@ -51,15 +51,18 @@
* Filename: btif_av.c
*
* Description: Bluedroid AV implementation
- *
+ *
*****************************************************************************/
+
#include <hardware/bluetooth.h>
#include "hardware/bt_av.h"
#define LOG_TAG "BTIF_AV"
-#include "btif_common.h"
-#include "btif_sm.h"
+
+#include "btif_av.h"
+#include "btif_util.h"
#include "bta_api.h"
+#include "btif_media.h"
#include "bta_av_api.h"
#include "gki.h"
#include "bd.h"
@@ -70,24 +73,16 @@
******************************************************************************/
#define BTIF_AV_SERVICE_NAME "Advanced Audio"
-#define BTIF_TIMEOUT_AV_OPEN_ON_RC 2 /* 2 seconds */
+#define BTIF_TIMEOUT_AV_OPEN_ON_RC_SECS 2
typedef enum {
BTIF_AV_STATE_IDLE = 0x0,
BTIF_AV_STATE_OPENING,
BTIF_AV_STATE_OPENED,
- BTIF_AV_STATE_STARTED
+ BTIF_AV_STATE_STARTED,
+ BTIF_AV_STATE_CLOSING
} btif_av_state_t;
-typedef enum {
- /* Reuse BTA_AV_XXX_EVT - No need to redefine them here */
- BTIF_AV_CONNECT_REQ_EVT = BTA_AV_MAX_EVT,
- BTIF_AV_DISCONNECT_REQ_EVT,
- BTIF_AV_START_STREAM_REQ_EVT,
- BTIF_AV_STOP_STREAM_REQ_EVT,
- BTIF_AV_SUSPEND_STREAM_REQ_EVT,
- BTIF_AV_RECONFIGURE_REQ_EVT,
-} btif_av_sm_event_t;
/*****************************************************************************
** Local type definitions
******************************************************************************/
@@ -131,16 +126,17 @@ static BOOLEAN btif_av_state_idle_handler(btif_sm_event_t event, void *data);
static BOOLEAN btif_av_state_opening_handler(btif_sm_event_t event, void *data);
static BOOLEAN btif_av_state_opened_handler(btif_sm_event_t event, void *data);
static BOOLEAN btif_av_state_started_handler(btif_sm_event_t event, void *data);
+static BOOLEAN btif_av_state_closing_handler(btif_sm_event_t event, void *data);
static const btif_sm_handler_t btif_av_state_handlers[] =
{
btif_av_state_idle_handler,
btif_av_state_opening_handler,
btif_av_state_opened_handler,
- btif_av_state_started_handler
+ btif_av_state_started_handler,
+ btif_av_state_closing_handler
};
-
/*************************************************************************
** Extern functions
*************************************************************************/
@@ -151,54 +147,57 @@ extern BOOLEAN btif_rc_get_connected_peer(BD_ADDR peer_addr);
/*****************************************************************************
** Local helper functions
******************************************************************************/
+
const char *dump_av_sm_state_name(btif_av_state_t state)
{
- switch (state) {
- case BTIF_AV_STATE_IDLE: return "BTIF_AV_STATE_IDLE";
- case BTIF_AV_STATE_OPENING: return "BTIF_AV_STATE_OPENING";
- case BTIF_AV_STATE_OPENED: return "BTIF_AV_STATE_OPENED";
- case BTIF_AV_STATE_STARTED: return "BTIF_AV_STATE_STARTED";
- default: return "UNKNOWN_STATE";
- }
+ switch (state)
+ {
+ CASE_RETURN_STR(BTIF_AV_STATE_IDLE)
+ CASE_RETURN_STR(BTIF_AV_STATE_OPENING)
+ CASE_RETURN_STR(BTIF_AV_STATE_OPENED)
+ CASE_RETURN_STR(BTIF_AV_STATE_STARTED)
+ CASE_RETURN_STR(BTIF_AV_STATE_CLOSING)
+ default: return "UNKNOWN_STATE";
+ }
}
const char *dump_av_sm_event_name(btif_av_sm_event_t event)
{
- switch(event) {
- case BTA_AV_ENABLE_EVT: return "BTA_AV_ENABLE_EVT";
- case BTA_AV_REGISTER_EVT: return "BTA_AV_REGISTER_EVT";
- case BTA_AV_OPEN_EVT: return "BTA_AV_OPEN_EVT";
- case BTA_AV_CLOSE_EVT: return "BTA_AV_CLOSE_EVT";
- case BTA_AV_START_EVT: return "BTA_AV_START_EVT";
- case BTA_AV_STOP_EVT: return "BTA_AV_STOP_EVT";
- case BTA_AV_PROTECT_REQ_EVT: return "BTA_AV_PROTECT_REQ_EVT";
- case BTA_AV_PROTECT_RSP_EVT: return "BTA_AV_PROTECT_RSP_EVT";
- case BTA_AV_RC_OPEN_EVT: return "BTA_AV_RC_OPEN_EVT";
- case BTA_AV_RC_CLOSE_EVT: return "BTA_AV_RC_CLOSE_EVT";
- case BTA_AV_REMOTE_CMD_EVT: return "BTA_AV_REMOTE_CMD_EVT";
- case BTA_AV_REMOTE_RSP_EVT: return "BTA_AV_REMOTE_RSP_EVT";
- case BTA_AV_VENDOR_CMD_EVT: return "BTA_AV_VENDOR_CMD_EVT";
- case BTA_AV_VENDOR_RSP_EVT: return "BTA_AV_VENDOR_RSP_EVT";
- case BTA_AV_RECONFIG_EVT: return "BTA_AV_RECONFIG_EVT";
- case BTA_AV_SUSPEND_EVT: return "BTA_AV_SUSPEND_EVT";
- case BTA_AV_PENDING_EVT: return "BTA_AV_PENDING_EVT";
- case BTA_AV_META_MSG_EVT: return "BTA_AV_META_MSG_EVT";
- case BTA_AV_REJECT_EVT: return "BTA_AV_REJECT_EVT";
- case BTA_AV_RC_FEAT_EVT: return "BTA_AV_RC_FEAT_EVT";
-
- case BTIF_SM_ENTER_EVT: return "BTIF_SM_ENTER_EVT";
- case BTIF_SM_EXIT_EVT: return "BTIF_SM_EXIT_EVT";
- case BTIF_AV_CONNECT_REQ_EVT: return "BTIF_AV_CONNECT_REQ_EVT";
- case BTIF_AV_DISCONNECT_REQ_EVT: return "BTIF_AV_DISCONNECT_REQ_EVT";
- case BTIF_AV_START_STREAM_REQ_EVT: return "BTIF_AV_START_STREAM_REQ_EVT";
- case BTIF_AV_STOP_STREAM_REQ_EVT: return "BTIF_AV_STOP_STREAM_REQ_EVT";
- case BTIF_AV_SUSPEND_STREAM_REQ_EVT: return "BTIF_AV_SUSPEND_STREAM_REQ_EVT";
- case BTIF_AV_RECONFIGURE_REQ_EVT: return "BTIF_AV_RECONFIGURE_REQ_EVT";
+ switch(event)
+ {
+ CASE_RETURN_STR(BTA_AV_ENABLE_EVT)
+ CASE_RETURN_STR(BTA_AV_REGISTER_EVT)
+ CASE_RETURN_STR(BTA_AV_OPEN_EVT)
+ CASE_RETURN_STR(BTA_AV_CLOSE_EVT)
+ CASE_RETURN_STR(BTA_AV_START_EVT)
+ CASE_RETURN_STR(BTA_AV_STOP_EVT)
+ CASE_RETURN_STR(BTA_AV_PROTECT_REQ_EVT)
+ CASE_RETURN_STR(BTA_AV_PROTECT_RSP_EVT)
+ CASE_RETURN_STR(BTA_AV_RC_OPEN_EVT)
+ CASE_RETURN_STR(BTA_AV_RC_CLOSE_EVT)
+ CASE_RETURN_STR(BTA_AV_REMOTE_CMD_EVT)
+ CASE_RETURN_STR(BTA_AV_REMOTE_RSP_EVT)
+ CASE_RETURN_STR(BTA_AV_VENDOR_CMD_EVT)
+ CASE_RETURN_STR(BTA_AV_VENDOR_RSP_EVT)
+ CASE_RETURN_STR(BTA_AV_RECONFIG_EVT)
+ CASE_RETURN_STR(BTA_AV_SUSPEND_EVT)
+ CASE_RETURN_STR(BTA_AV_PENDING_EVT)
+ CASE_RETURN_STR(BTA_AV_META_MSG_EVT)
+ CASE_RETURN_STR(BTA_AV_REJECT_EVT)
+ CASE_RETURN_STR(BTA_AV_RC_FEAT_EVT)
+ CASE_RETURN_STR(BTIF_SM_ENTER_EVT)
+ CASE_RETURN_STR(BTIF_SM_EXIT_EVT)
+ CASE_RETURN_STR(BTIF_AV_CONNECT_REQ_EVT)
+ CASE_RETURN_STR(BTIF_AV_DISCONNECT_REQ_EVT)
+ CASE_RETURN_STR(BTIF_AV_START_STREAM_REQ_EVT)
+ CASE_RETURN_STR(BTIF_AV_STOP_STREAM_REQ_EVT)
+ CASE_RETURN_STR(BTIF_AV_SUSPEND_STREAM_REQ_EVT)
+ CASE_RETURN_STR(BTIF_AV_RECONFIGURE_REQ_EVT)
+
default: return "UNKNOWN_EVENT";
}
}
-
/****************************************************************************
** Local helper functions
*****************************************************************************/
@@ -232,13 +231,15 @@ static void btif_initiate_av_open_tmr_hdlr(TIMER_LIST_ENT *tle)
** Static functions
******************************************************************************/
-void btif_a2dp_set_busy_level(UINT8 level);
-void btif_a2dp_upon_init(void);
-void btif_a2dp_upon_idle(void);
-void btif_a2dp_upon_start_req(void);
-void btif_a2dp_upon_started(void);
-int btif_a2dp_start_media_task(void);
-void btif_a2dp_stop_media_task(void);
+/*****************************************************************************
+**
+** Function btif_av_state_idle_handler
+**
+** Description State managing disconnected AV link
+**
+** Returns TRUE if event was processed, FALSE otherwise
+**
+*******************************************************************************/
static BOOLEAN btif_av_state_idle_handler(btif_sm_event_t event, void *p_data)
{
@@ -247,41 +248,38 @@ static BOOLEAN btif_av_state_idle_handler(btif_sm_event_t event, void *p_data)
switch (event)
{
case BTIF_SM_ENTER_EVT:
- {
/* clear the peer_bda */
memset(&btif_av_cb.peer_bda, 0, sizeof(bt_bdaddr_t));
- btif_a2dp_upon_idle();
- } break;
-
+ btif_a2dp_on_idle();
+ break;
+
case BTIF_SM_EXIT_EVT:
break;
case BTA_AV_ENABLE_EVT:
- {
- BTA_AvRegister(BTA_AV_CHNL_AUDIO, BTIF_AV_SERVICE_NAME, 0);
- } break;
+ break;
case BTA_AV_REGISTER_EVT:
- {
btif_av_cb.bta_handle = ((tBTA_AV*)p_data)->registr.hndl;
- } break;
+ break;
+
case BTA_AV_PENDING_EVT:
case BTIF_AV_CONNECT_REQ_EVT:
{
if (event == BTIF_AV_CONNECT_REQ_EVT)
{
- memcpy(&btif_av_cb.peer_bda, (bt_bdaddr_t*)p_data, sizeof(bt_bdaddr_t));
- BTA_AvOpen(btif_av_cb.peer_bda.address, btif_av_cb.bta_handle,
- TRUE, BTA_SEC_NONE);
+ memcpy(&btif_av_cb.peer_bda, (bt_bdaddr_t*)p_data, sizeof(bt_bdaddr_t));
}
else if (event == BTA_AV_PENDING_EVT)
{
bdcpy(btif_av_cb.peer_bda.address, ((tBTA_AV*)p_data)->pend.bd_addr);
}
+ BTA_AvOpen(btif_av_cb.peer_bda.address, btif_av_cb.bta_handle,
+ TRUE, BTA_SEC_NONE);
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_OPENING);
} break;
+
case BTA_AV_RC_OPEN_EVT:
- {
/* IOP_FIX: Jabra 620 only does RC open without AV open whenever it connects. So
* as per the AV WP, an AVRC connection cannot exist without an AV connection. Therefore,
* we initiate an AV connection if an RC_OPEN_EVT is received when we are in AV_CLOSED state.
@@ -291,35 +289,48 @@ static BOOLEAN btif_av_state_idle_handler(btif_sm_event_t event, void *p_data)
*
* TODO: We may need to do this only on an AVRCP Play. FixMe
*/
+
BTIF_TRACE_DEBUG0("BTA_AV_RC_OPEN_EVT received w/o AV");
memset(&tle_av_open_on_rc, 0, sizeof(tle_av_open_on_rc));
tle_av_open_on_rc.param = (UINT32)btif_initiate_av_open_tmr_hdlr;
btu_start_timer(&tle_av_open_on_rc, BTU_TTYPE_USER_FUNC,
- BTIF_TIMEOUT_AV_OPEN_ON_RC);
+ BTIF_TIMEOUT_AV_OPEN_ON_RC_SECS);
btif_rc_handler(event, p_data);
- }break;
+ break;
+
case BTA_AV_REMOTE_CMD_EVT:
case BTA_AV_VENDOR_CMD_EVT:
case BTA_AV_META_MSG_EVT:
case BTA_AV_RC_FEAT_EVT:
- {
btif_rc_handler(event, (tBTA_AV*)p_data);
- }break;
+ break;
+
case BTA_AV_RC_CLOSE_EVT:
- {
if (tle_av_open_on_rc.in_use) {
BTIF_TRACE_DEBUG0("BTA_AV_RC_CLOSE_EVT: Stopping AV timer.");
btu_stop_timer(&tle_av_open_on_rc);
}
btif_rc_handler(event, p_data);
- }break;
+ break;
default:
- BTIF_TRACE_WARNING2("%s Unhandled event:%s", __FUNCTION__,
+ BTIF_TRACE_WARNING2("%s : unhandled event:%s", __FUNCTION__,
dump_av_sm_event_name(event));
+ return FALSE;
+
}
return TRUE;
}
+/*****************************************************************************
+**
+** Function btif_av_state_opening_handler
+**
+** Description Intermediate state managing events during establishment
+** of avdtp channel
+**
+** Returns TRUE if event was processed, FALSE otherwise
+**
+*******************************************************************************/
static BOOLEAN btif_av_state_opening_handler(btif_sm_event_t event, void *p_data)
{
@@ -328,11 +339,10 @@ static BOOLEAN btif_av_state_opening_handler(btif_sm_event_t event, void *p_data
switch (event)
{
case BTIF_SM_ENTER_EVT:
- {
- /* inform the application that we are entering connecting state */
- CHECK_CALL_CBACK(bt_av_callbacks, connection_state_cb,
+ /* inform the application that we are entering connecting state */
+ HAL_CBACK(bt_av_callbacks, connection_state_cb,
BTAV_CONNECTION_STATE_CONNECTING, &(btif_av_cb.peer_bda));
- } break;
+ break;
case BTIF_SM_EXIT_EVT:
break;
@@ -343,6 +353,7 @@ static BOOLEAN btif_av_state_opening_handler(btif_sm_event_t event, void *p_data
btav_connection_state_t state;
btif_sm_state_t av_state;
BTIF_TRACE_DEBUG1("status:%d", p_bta_data->open.status);
+
if (p_bta_data->open.status == BTA_AV_SUCCESS)
{
state = BTAV_CONNECTION_STATE_CONNECTED;
@@ -355,9 +366,11 @@ static BOOLEAN btif_av_state_opening_handler(btif_sm_event_t event, void *p_data
state = BTAV_CONNECTION_STATE_DISCONNECTED;
av_state = BTIF_AV_STATE_IDLE;
}
+
/* inform the application of the event */
- CHECK_CALL_CBACK(bt_av_callbacks, connection_state_cb,
+ HAL_CBACK(bt_av_callbacks, connection_state_cb,
state, &(btif_av_cb.peer_bda));
+
/* change state to open/idle based on the status */
btif_sm_change_state(btif_av_cb.sm_handle, av_state);
} break;
@@ -365,14 +378,27 @@ static BOOLEAN btif_av_state_opening_handler(btif_sm_event_t event, void *p_data
CHECK_RC_EVENT(event, p_data);
default:
- BTIF_TRACE_WARNING2("%s Unhandled event:%s", __FUNCTION__,
+ BTIF_TRACE_WARNING2("%s : unhandled event:%s", __FUNCTION__,
dump_av_sm_event_name(event));
+ return FALSE;
+
}
return TRUE;
}
-static BOOLEAN btif_av_state_opened_handler(btif_sm_event_t event, void *p_data)
+/*****************************************************************************
+**
+** Function btif_av_state_closing_handler
+**
+** Description Intermediate state managing events during closing
+** of avdtp channel
+**
+** Returns TRUE if event was processed, FALSE otherwise
+**
+*******************************************************************************/
+
+static BOOLEAN btif_av_state_closing_handler(btif_sm_event_t event, void *p_data)
{
BTIF_TRACE_DEBUG2("%s event:%s", __FUNCTION__, dump_av_sm_event_name(event));
@@ -380,105 +406,251 @@ static BOOLEAN btif_av_state_opened_handler(btif_sm_event_t event, void *p_data)
{
case BTIF_SM_ENTER_EVT:
- BTIF_TRACE_DEBUG0("starting av...sleeping before that");
+ /* immediately stop transmission of frames */
+ btif_a2dp_set_tx_flush(TRUE);
- /* Auto-starting on Open could introduce race conditions. So delaying
- * the start.
- *
- * This is anyway temporary and will be removed once the START/STOP stream
- * requests are processed.
- */
- GKI_delay(3000);
+ /* wait for audioflinger to stop a2dp */
+ break;
- btif_a2dp_upon_start_req();
+ case BTIF_AV_STOP_STREAM_REQ_EVT:
+ /* immediately flush any pending tx frames while suspend is pending */
+ btif_a2dp_set_tx_flush(TRUE);
- /* autostart for now to test media task */
- BTA_AvStart();
+ btif_a2dp_on_stopped(NULL);
+
+ break;
+
+ case BTIF_SM_EXIT_EVT:
+ break;
+
+ case BTA_AV_CLOSE_EVT:
+
+ /* inform the application that we are disconnecting */
+ HAL_CBACK(bt_av_callbacks, connection_state_cb,
+ BTAV_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
+
+ btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_IDLE);
+ break;
+
+ default:
+ BTIF_TRACE_WARNING2("%s : unhandled event:%s", __FUNCTION__,
+ dump_av_sm_event_name(event));
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+/*****************************************************************************
+**
+** Function btif_av_state_opened_handler
+**
+** Description Handles AV events while AVDTP is in OPEN state
+**
+** Returns TRUE if event was processed, FALSE otherwise
+**
+*******************************************************************************/
+
+static BOOLEAN btif_av_state_opened_handler(btif_sm_event_t event, void *p_data)
+{
+ tBTA_AV *p_av = (tBTA_AV*)p_data;
+
+ BTIF_TRACE_DEBUG2("%s event:%s", __FUNCTION__, dump_av_sm_event_name(event));
+ switch (event)
+ {
+ case BTIF_SM_ENTER_EVT:
break;
case BTIF_SM_EXIT_EVT:
break;
case BTIF_AV_START_STREAM_REQ_EVT:
- /* fixme */
+ /* prepare media task */
+ btif_a2dp_on_start_req();
+ BTA_AvStart();
break;
case BTA_AV_START_EVT:
{
- tBTA_AV *p_bta_data = (tBTA_AV*)p_data;
+ BTIF_TRACE_EVENT3("BTA_AV_START_EVT status %d, suspending %d, init %d",
+ p_av->start.status, p_av->start.suspending, p_av->start.initiator);
+
+ if ((p_av->start.status == BTA_SUCCESS) && (p_av->start.suspending == TRUE))
+ return TRUE;
+
+ btif_a2dp_on_started(&p_av->start);
+
+ /* remain in open state if status failed */
+ if (p_av->start.status != BTA_AV_SUCCESS)
+ return FALSE;
+
+ /* change state to started */
+ btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_STARTED);
- if (p_bta_data->start.status == BTA_AV_SUCCESS)
- {
- /* change state to started */
- btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_STARTED);
- }
- else
- {
- /* fixme */
- }
} break;
case BTIF_AV_DISCONNECT_REQ_EVT:
- {
- BTA_AvClose(btif_av_cb.bta_handle);
- /* inform the application that we are disconnecting */
- CHECK_CALL_CBACK(bt_av_callbacks, connection_state_cb,
+ BTA_AvClose(btif_av_cb.bta_handle);
+
+ /* inform the application that we are disconnecting */
+ HAL_CBACK(bt_av_callbacks, connection_state_cb,
BTAV_CONNECTION_STATE_DISCONNECTING, &(btif_av_cb.peer_bda));
- } break;
+ break;
case BTA_AV_CLOSE_EVT:
- {
- /* inform the application that we are disconnecting */
- CHECK_CALL_CBACK(bt_av_callbacks, connection_state_cb,
+
+ /* inform the application that we are disconnected */
+ HAL_CBACK(bt_av_callbacks, connection_state_cb,
BTAV_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
+
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_IDLE);
- } break;
+ break;
CHECK_RC_EVENT(event, p_data);
default:
- BTIF_TRACE_WARNING2("%s Unhandled event:%s", __FUNCTION__,
+ BTIF_TRACE_WARNING2("%s : unhandled event:%s", __FUNCTION__,
dump_av_sm_event_name(event));
+ return FALSE;
+
}
return TRUE;
}
+/*****************************************************************************
+**
+** Function btif_av_state_started_handler
+**
+** Description Handles AV events while A2DP stream is started
+**
+** Returns TRUE if event was processed, FALSE otherwise
+**
+*******************************************************************************/
+
static BOOLEAN btif_av_state_started_handler(btif_sm_event_t event, void *p_data)
{
+ tBTA_AV *p_av = (tBTA_AV*)p_data;
+
BTIF_TRACE_DEBUG2("%s event:%s", __FUNCTION__, dump_av_sm_event_name(event));
switch (event)
{
- case BTIF_SM_ENTER_EVT:
- btif_a2dp_upon_started();
+ case BTIF_SM_ENTER_EVT:
+#ifdef ENABLE_AUDIO_STATE_CB
+ HAL_CBACK(bt_av_callbacks, audio_state_cb,
+ BTAV_AUDIO_STATE_STARTED, &(btif_av_cb.peer_bda));
+#endif
break;
-
+
case BTIF_SM_EXIT_EVT:
break;
+
+ case BTIF_AV_STOP_STREAM_REQ_EVT:
+ /* immediately flush any pending tx frames while suspend is pending */
+ btif_a2dp_set_tx_flush(TRUE);
+
+ BTA_AvStop(TRUE);
+ break;
+
+ case BTIF_AV_SUSPEND_STREAM_REQ_EVT:
+
+ /* immediately stop transmission of frames whiel suspend is pending */
+ btif_a2dp_set_tx_flush(TRUE);
+
+ BTA_AvStop(TRUE);
+ break;
+
case BTIF_AV_DISCONNECT_REQ_EVT:
- {
- BTA_AvClose(btif_av_cb.bta_handle);
- /* inform the application that we are disconnecting */
- CHECK_CALL_CBACK(bt_av_callbacks, connection_state_cb,
- BTAV_CONNECTION_STATE_DISCONNECTING, &(btif_av_cb.peer_bda));
- } break;
- case BTA_AV_STOP_EVT:
- {
+ /* request avdtp to close */
+ BTA_AvClose(btif_av_cb.bta_handle);
+
/* inform the application that we are disconnecting */
+ HAL_CBACK(bt_av_callbacks, connection_state_cb,
+ BTAV_CONNECTION_STATE_DISCONNECTING, &(btif_av_cb.peer_bda));
+
+ /* wait in closing state until fully closed */
+ btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_CLOSING);
+ break;
+
+ case BTA_AV_SUSPEND_EVT:
+
+ BTIF_TRACE_EVENT2("BTA_AV_SUSPEND_EVT status %d, init %d",
+ p_av->suspend.status, p_av->suspend.initiator);
+
+ /* a2dp suspended, stop media task until resumed */
+ btif_a2dp_on_suspended(&p_av->suspend);
+
+ /* if not successful, remain in current state */
+ if (p_av->suspend.status != BTA_AV_SUCCESS)
+ {
+ /* suspend failed, reset back tx flush state */
+ btif_a2dp_set_tx_flush(FALSE);
+ return FALSE;
+ }
+
+#ifdef ENABLE_AUDIO_STATE_CB
+ if (p_av->suspend.initiator != TRUE)
+ {
+ /* remote suspend, notify HAL and await audioflinger to
+ suspend/stop stream */
+
+ HAL_CBACK(bt_av_callbacks, audio_state_cb,
+ BTAV_AUDIO_STATE_REMOTE_SUSPEND, &(btif_av_cb.peer_bda));
+ }
+ else
+ {
+ HAL_CBACK(bt_av_callbacks, audio_state_cb,
+ BTAV_AUDIO_STATE_STOPPED, &(btif_av_cb.peer_bda));
+ }
+#endif
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_OPENED);
- } break;
+ break;
+
+ case BTA_AV_STOP_EVT:
+
+ btif_a2dp_on_stopped(&p_av->suspend);
+
+#ifdef ENABLE_AUDIO_STATE_CB
+ HAL_CBACK(bt_av_callbacks, audio_state_cb,
+ BTAV_AUDIO_STATE_STOPPED, &(btif_av_cb.peer_bda));
+#endif
+
+ /* if stop was successful, change state to open */
+ if (p_av->suspend.status == BTA_AV_SUCCESS)
+ btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_OPENED);
+
+ break;
+
+ case BTA_AV_CLOSE_EVT:
+
+ /* avdtp link is closed */
+
+ btif_a2dp_on_stopped(NULL);
+
+ /* inform the application that we are disconnected */
+ HAL_CBACK(bt_av_callbacks, connection_state_cb,
+ BTAV_CONNECTION_STATE_DISCONNECTED, &(btif_av_cb.peer_bda));
+
+ btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_IDLE);
+ break;
CHECK_RC_EVENT(event, p_data);
default:
- BTIF_TRACE_WARNING2("%s Unhandled event:%s", __FUNCTION__,
+ BTIF_TRACE_WARNING2("%s : unhandled event:%s", __FUNCTION__,
dump_av_sm_event_name(event));
+ return FALSE;
+
}
return TRUE;
}
+/*****************************************************************************
+** Local event handlers
+******************************************************************************/
+
static void btif_av_handle_event(UINT16 event, char* p_param)
{
btif_sm_dispatch(btif_av_cb.sm_handle, event, (void*)p_param);
@@ -490,13 +662,6 @@ static void bte_av_callback(tBTA_AV_EVT event, tBTA_AV *p_data)
btif_transfer_context(btif_av_handle_event, event,
(char*)p_data, sizeof(tBTA_AV), NULL);
}
-/*****************************************************************************
-** Externs
-******************************************************************************/
-
-/*****************************************************************************
-** Functions
-******************************************************************************/
/*******************************************************************************
**
@@ -522,12 +687,14 @@ static bt_status_t init(btav_callbacks_t* callbacks )
bt_av_callbacks = callbacks;
btif_enable_service(BTA_A2DP_SERVICE_ID);
+
/* Initialize the AVRC CB */
btif_rc_init();
+
/* Also initialize the AV state machine */
btif_av_cb.sm_handle = btif_sm_init((const btif_sm_handler_t*)btif_av_state_handlers, BTIF_AV_STATE_IDLE);
- btif_a2dp_upon_init();
+ btif_a2dp_on_init();
return BT_STATUS_SUCCESS;
}
@@ -610,6 +777,75 @@ static const btav_interface_t bt_av_interface = {
/*******************************************************************************
**
+** Function btif_av_get_sm_handle
+**
+** Description Fetches current av SM handle
+**
+** Returns None
+**
+*******************************************************************************/
+
+btif_sm_handle_t btif_av_get_sm_handle(void)
+{
+ return btif_av_cb.sm_handle;
+}
+
+/*******************************************************************************
+**
+** Function btif_av_stream_ready
+**
+** Description Checks whether AV is ready for starting a stream
+**
+** Returns None
+**
+*******************************************************************************/
+
+BOOLEAN btif_av_stream_ready(void)
+{
+ btif_sm_state_t state = btif_sm_get_state(btif_av_cb.sm_handle);
+ BTIF_TRACE_EVENT2("btif_av_stream_ready : sm hdl %d, state %d",
+ btif_av_cb.sm_handle, state);
+ return (state == BTIF_AV_STATE_OPENED);
+}
+
+/*******************************************************************************
+**
+** Function btif_av_stream_started
+**
+** Description Checks whether AV is already started (remotely)
+**
+** Returns None
+**
+*******************************************************************************/
+
+BOOLEAN btif_av_stream_started(void)
+{
+ btif_sm_state_t state = btif_sm_get_state(btif_av_cb.sm_handle);
+ BTIF_TRACE_EVENT2("btif_av_stream_started : sm hdl %d, state %d",
+ btif_av_cb.sm_handle, state);
+ return (state == BTIF_AV_STATE_STARTED);
+}
+
+/*******************************************************************************
+**
+** Function btif_dispatch_sm_event
+**
+** Description Send event to AV statemachine
+**
+** Returns None
+**
+*******************************************************************************/
+
+/* used to pass events to AV statemachine from other tasks */
+void btif_dispatch_sm_event(btif_av_sm_event_t event, void *p_data, int len)
+{
+ /* Switch to BTIF context */
+ btif_transfer_context(btif_av_handle_event, event,
+ (char*)p_data, len, NULL);
+}
+
+/*******************************************************************************
+**
** Function btif_av_execute_service
**
** Description Initializes/Shuts down the service
@@ -650,7 +886,7 @@ bt_status_t btif_av_execute_service(BOOLEAN b_enable)
** Returns btav_interface_t
**
*******************************************************************************/
-const btav_interface_t *btif_av_get_interface()
+const btav_interface_t *btif_av_get_interface(void)
{
BTIF_TRACE_EVENT1("%s", __FUNCTION__);
return &bt_av_interface;
diff --git a/btif/src/btif_core.c b/btif/src/btif_core.c
index 50ee650..2226a0f 100644
--- a/btif/src/btif_core.c
+++ b/btif/src/btif_core.c
@@ -3,44 +3,44 @@
* Copyright (C) 2009-2012 Broadcom Corporation
*
* This program is the proprietary software of Broadcom Corporation and/or its
- * licensors, and may only be used, duplicated, modified or distributed
- * pursuant to the terms and conditions of a separate, written license
- * agreement executed between you and Broadcom (an "Authorized License").
- * Except as set forth in an Authorized License, Broadcom grants no license
- * (express or implied), right to use, or waiver of any kind with respect to
- * the Software, and Broadcom expressly reserves all rights in and to the
- * Software and all intellectual property rights therein.
- * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
- * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
- * ALL USE OF THE SOFTWARE.
+ * licensors, and may only be used, duplicated, modified or distributed
+ * pursuant to the terms and conditions of a separate, written license
+ * agreement executed between you and Broadcom (an "Authorized License").
+ * Except as set forth in an Authorized License, Broadcom grants no license
+ * (express or implied), right to use, or waiver of any kind with respect to
+ * the Software, and Broadcom expressly reserves all rights in and to the
+ * Software and all intellectual property rights therein.
+ * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
+ * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
+ * ALL USE OF THE SOFTWARE.
*
* Except as expressly set forth in the Authorized License,
*
- * 1. This program, including its structure, sequence and organization,
- * constitutes the valuable trade secrets of Broadcom, and you shall
- * use all reasonable efforts to protect the confidentiality thereof,
- * and to use this information only in connection with your use of
+ * 1. This program, including its structure, sequence and organization,
+ * constitutes the valuable trade secrets of Broadcom, and you shall
+ * use all reasonable efforts to protect the confidentiality thereof,
+ * and to use this information only in connection with your use of
* Broadcom integrated circuit products.
*
- * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
- * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
- * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
- * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
- * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
- * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
- * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
+ * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
+ * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
+ * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
+ * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
+ * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
+ * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
+ * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
* CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT
* OF USE OR PERFORMANCE OF THE SOFTWARE.
*
* 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR
- * ITS LICENSORS BE LIABLE FOR
- * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
- * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
- * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
- * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
- * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
- * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
- * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
+ * ITS LICENSORS BE LIABLE FOR
+ * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
+ * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
+ * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
+ * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
+ * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
+ * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
+ * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
* ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
*
************************************************************************************/
@@ -51,7 +51,7 @@
*
* Description: Contains core functionality related to interfacing between
* Bluetooth HAL and BTE core stack.
- *
+ *
***********************************************************************************/
#include <hardware/bluetooth.h>
@@ -177,9 +177,9 @@ static void btif_context_switched(void *p_msg)
** event : event id of message
** p_params : parameter area passed to callback (copied)
** param_len : length of parameter area
-** p_copy_cback : If set this function will be invoked for deep copy
+** p_copy_cback : If set this function will be invoked for deep copy
**
-** Returns void
+** Returns void
**
*******************************************************************************/
@@ -191,7 +191,7 @@ bt_status_t btif_transfer_context (tBTIF_CBACK *p_cback, UINT16 event, char* p_p
/* allocate and send message that will be executed in btif context */
if ((p_msg = (tBTIF_CONTEXT_SWITCH_CBACK *) GKI_getbuf(sizeof(tBTIF_CONTEXT_SWITCH_CBACK) + param_len)) != NULL)
- {
+ {
p_msg->hdr.event = BT_EVT_CONTEXT_SWITCH_EVT; /* internal event */
p_msg->p_cb = p_cback;
@@ -242,12 +242,12 @@ static void btif_task(UINT32 params)
/* wait for specified events */
event = GKI_wait(0xFFFF, 0);
- /*
+ /*
* Wait for the trigger to init chip and stack. This trigger will
- * be received by btu_task once the UART is opened and ready
+ * be received by btu_task once the UART is opened and ready
*/
- if (event == BT_EVT_TRIGGER_STACK_INIT)
+ if (event == BT_EVT_TRIGGER_STACK_INIT)
{
BTIF_TRACE_DEBUG0("btif_task: received trigger stack init event");
BTA_EnableBluetooth(bte_dm_evt);
@@ -280,11 +280,11 @@ static void btif_task(UINT32 params)
btif_disassociate_evt();
GKI_task_self_cleanup(BTIF_TASK);
-
+
if (btif_shutdown_pending)
{
btif_shutdown_pending = 0;
-
+
bte_main_shutdown();
/* shutdown complete, all events notified and we reset HAL callbacks */
@@ -301,7 +301,7 @@ static void btif_task(UINT32 params)
**
** Description Sends msg to BTIF task
**
-** Returns void
+** Returns void
**
*******************************************************************************/
@@ -321,14 +321,13 @@ void btif_sendmsg(void *p_msg)
** Function btif_init_bluetooth
**
** Description Creates BTIF task and prepares BT scheduler for startup
-**
-** Returns bt_status_t
+**
+** Returns bt_status_t
**
*******************************************************************************/
bt_status_t btif_init_bluetooth(void)
{
-
bte_main_boot_entry();
return BT_STATUS_SUCCESS;
@@ -348,7 +347,7 @@ bt_status_t btif_init_bluetooth(void)
static bt_status_t btif_associate_evt(void)
{
BTIF_TRACE_DEBUG1("%s: notify ASSOCIATE_JVM", __FUNCTION__);
- CHECK_CALL_CBACK(bt_hal_cbacks, thread_evt_cb, ASSOCIATE_JVM);
+ HAL_CBACK(bt_hal_cbacks, thread_evt_cb, ASSOCIATE_JVM);
return BT_STATUS_SUCCESS;
}
@@ -359,8 +358,8 @@ static bt_status_t btif_associate_evt(void)
** Function btif_enable_bluetooth
**
** Description Performs chip power on and kickstarts OS scheduler
-**
-** Returns bt_status_t
+**
+** Returns bt_status_t
**
*******************************************************************************/
@@ -399,8 +398,8 @@ bt_status_t btif_enable_bluetooth(void)
**
** Description Event indicating bluetooth enable is completed
** Notifies HAL user with updated adapter state
-**
-** Returns void
+**
+** Returns void
**
*******************************************************************************/
@@ -424,12 +423,12 @@ void btif_enable_bluetooth_evt(tBTA_STATUS status, BD_ADDR local_bd)
{
/* store state */
btif_enabled = 1;
- CHECK_CALL_CBACK(bt_hal_cbacks, adapter_state_changed_cb, BT_STATE_ON);
+ HAL_CBACK(bt_hal_cbacks, adapter_state_changed_cb, BT_STATE_ON);
}
else
{
btif_enabled = 0;
- CHECK_CALL_CBACK(bt_hal_cbacks, adapter_state_changed_cb, BT_STATE_OFF);
+ HAL_CBACK(bt_hal_cbacks, adapter_state_changed_cb, BT_STATE_OFF);
}
}
@@ -440,8 +439,8 @@ void btif_enable_bluetooth_evt(tBTA_STATUS status, BD_ADDR local_bd)
** Description Inititates shutdown of Bluetooth system.
** Any active links will be dropped and device entering
** non connectable/discoverable mode
-**
-** Returns void
+**
+** Returns void
**
*******************************************************************************/
@@ -464,7 +463,7 @@ bt_status_t btif_disable_bluetooth(void)
BTIF_TRACE_ERROR1("disable bt failed (%d)", status);
return BT_STATUS_FAIL;
}
- return BT_STATUS_SUCCESS;
+ return BT_STATUS_SUCCESS;
}
/*******************************************************************************
@@ -472,10 +471,10 @@ bt_status_t btif_disable_bluetooth(void)
** Function btif_disable_bluetooth_evt
**
** Description Event notifying BT disable is now complete.
-** Terminates main stack tasks and notifies HAL
-** user with updated BT state.
-**
-** Returns void
+** Terminates main stack tasks and notifies HAL
+** user with updated BT state.
+**
+** Returns void
**
*******************************************************************************/
@@ -486,7 +485,7 @@ void btif_disable_bluetooth_evt(void)
bte_main_disable();
/* callback to HAL */
- CHECK_CALL_CBACK(bt_hal_cbacks, adapter_state_changed_cb, BT_STATE_OFF);
+ HAL_CBACK(bt_hal_cbacks, adapter_state_changed_cb, BT_STATE_OFF);
/* update local state */
btif_enabled = 0;
@@ -501,8 +500,8 @@ void btif_disable_bluetooth_evt(void)
**
** Description Finalizes BT scheduler shutdown and terminates BTIF
** task.
-**
-** Returns void
+**
+** Returns void
**
*******************************************************************************/
@@ -543,7 +542,8 @@ bt_status_t btif_shutdown_bluetooth(void)
static bt_status_t btif_disassociate_evt(void)
{
BTIF_TRACE_DEBUG1("%s: notify DISASSOCIATE_JVM", __FUNCTION__);
- CHECK_CALL_CBACK(bt_hal_cbacks, thread_evt_cb, DISASSOCIATE_JVM);
+
+ HAL_CBACK(bt_hal_cbacks, thread_evt_cb, DISASSOCIATE_JVM);
return BT_STATUS_SUCCESS;
}
@@ -605,7 +605,7 @@ static bt_status_t btif_in_get_adapter_properties(void)
btif_storage_get_adapter_property(&properties[num_props]);
num_props++;
- CHECK_CALL_CBACK(bt_hal_cbacks, adapter_properties_cb,
+ HAL_CBACK(bt_hal_cbacks, adapter_properties_cb,
BT_STATUS_SUCCESS, num_props, properties);
return BT_STATUS_SUCCESS;
@@ -651,7 +651,7 @@ static bt_status_t btif_in_get_remote_device_properties(bt_bdaddr_t *bd_addr)
&remote_properties[num_props]);
num_props++;
- CHECK_CALL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
+ HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
BT_STATUS_SUCCESS, bd_addr, num_props, remote_properties);
return BT_STATUS_SUCCESS;
@@ -664,16 +664,16 @@ static bt_status_t btif_in_get_remote_device_properties(bt_bdaddr_t *bd_addr)
**
** Description Executes adapter storage request in BTIF context
**
-** Returns bt_status_t
+** Returns bt_status_t
**
*******************************************************************************/
static void execute_storage_request(UINT16 event, char *p_param)
{
uint8_t is_local;
- int num_entries = 0;
+ int num_entries = 0;
bt_status_t status = BT_STATUS_SUCCESS;
-
+
BTIF_TRACE_EVENT1("execute storage request event : %d", event);
switch(event)
@@ -686,7 +686,7 @@ static void execute_storage_request(UINT16 event, char *p_param)
p_prop->len, p_prop->val);
status = btif_storage_set_adapter_property(p_prop);
- CHECK_CALL_CBACK(bt_hal_cbacks, adapter_properties_cb, status, 1, p_prop);
+ HAL_CBACK(bt_hal_cbacks, adapter_properties_cb, status, 1, p_prop);
} break;
case BTIF_CORE_STORAGE_ADAPTER_READ:
@@ -699,9 +699,9 @@ static void execute_storage_request(UINT16 event, char *p_param)
prop.len = sizeof(buf);
status = btif_storage_get_adapter_property(&prop);
- CHECK_CALL_CBACK(bt_hal_cbacks, adapter_properties_cb, status, 1, &prop);
+ HAL_CBACK(bt_hal_cbacks, adapter_properties_cb, status, 1, &prop);
} break;
-
+
case BTIF_CORE_STORAGE_ADAPTER_READ_ALL:
{
status = btif_in_get_adapter_properties();
@@ -709,7 +709,7 @@ static void execute_storage_request(UINT16 event, char *p_param)
case BTIF_CORE_STORAGE_NOTIFY_STATUS:
{
- CHECK_CALL_CBACK(bt_hal_cbacks, adapter_properties_cb, status, 0, NULL);
+ HAL_CBACK(bt_hal_cbacks, adapter_properties_cb, status, 0, NULL);
} break;
default:
@@ -737,7 +737,7 @@ static void execute_storage_remote_request(UINT16 event, char *p_param)
status = btif_storage_get_remote_device_property(&(p_req->read_req.bd_addr),
&prop);
- CHECK_CALL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
+ HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
status, &(p_req->read_req.bd_addr), 1, &prop);
}break;
case BTIF_CORE_STORAGE_REMOTE_WRITE:
@@ -757,14 +757,14 @@ static void execute_storage_remote_request(UINT16 event, char *p_param)
void btif_adapter_properties_evt(bt_status_t status, uint32_t num_props,
bt_property_t *p_props)
{
- CHECK_CALL_CBACK(bt_hal_cbacks, adapter_properties_cb,
+ HAL_CBACK(bt_hal_cbacks, adapter_properties_cb,
status, num_props, p_props);
}
void btif_remote_properties_evt(bt_status_t status, bt_bdaddr_t *remote_addr,
uint32_t num_props, bt_property_t *p_props)
{
- CHECK_CALL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
+ HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
status, remote_addr, num_props, p_props);
}
@@ -808,7 +808,7 @@ static void btif_in_storage_request_copy_cb(UINT16 event,
**
** Description Fetch all available properties (local & remote)
**
-** Returns bt_status_t
+** Returns bt_status_t
**
*******************************************************************************/
@@ -830,7 +830,7 @@ bt_status_t btif_get_adapter_properties(void)
**
** Description Fetches property value from local cache
**
-** Returns bt_status_t
+** Returns bt_status_t
**
*******************************************************************************/
@@ -855,10 +855,10 @@ bt_status_t btif_get_adapter_property(bt_property_type_t type)
**
** Function btif_set_adapter_property
**
-** Description Updates core stack with property value and stores it in
+** Description Updates core stack with property value and stores it in
** local cache
**
-** Returns bt_status_t
+** Returns bt_status_t
**
*******************************************************************************/
@@ -881,11 +881,11 @@ bt_status_t btif_set_adapter_property(const bt_property_t *property)
BTIF_TRACE_EVENT1("set property name : %s", (char *)property->val);
BTA_DmSetDeviceName((char *)property->val);
-
+
storage_req_id = BTIF_CORE_STORAGE_ADAPTER_WRITE;
}
break;
-
+
case BT_PROPERTY_ADAPTER_SCAN_MODE:
{
bt_scan_mode_t mode = *(bt_scan_mode_t*)property->val;
@@ -898,12 +898,12 @@ bt_status_t btif_set_adapter_property(const bt_property_t *property)
disc_mode = BTA_DM_NON_DISC;
conn_mode = BTA_DM_NON_CONN;
break;
-
+
case BT_SCAN_MODE_CONNECTABLE:
disc_mode = BTA_DM_NON_DISC;
conn_mode = BTA_DM_CONN;
break;
-
+
case BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE:
disc_mode = BTA_DM_GENERAL_DISC;
conn_mode = BTA_DM_CONN;
@@ -913,9 +913,9 @@ bt_status_t btif_set_adapter_property(const bt_property_t *property)
BTIF_TRACE_ERROR1("invalid scan mode (0x%x)", mode);
return BT_STATUS_PARM_INVALID;
}
-
+
BTIF_TRACE_EVENT1("set property scan mode : %x", mode);
-
+
BTA_DmSetVisibility(disc_mode, conn_mode, BTA_DM_IGNORE, BTA_DM_IGNORE);
storage_req_id = BTIF_CORE_STORAGE_ADAPTER_WRITE;
@@ -930,9 +930,9 @@ bt_status_t btif_set_adapter_property(const bt_property_t *property)
status = BT_STATUS_FAIL;
break;
default:
- BTIF_TRACE_ERROR1("btif_get_adapter_property : invalid type %d",
+ BTIF_TRACE_ERROR1("btif_get_adapter_property : invalid type %d",
property->type);
- status = BT_STATUS_FAIL;
+ status = BT_STATUS_FAIL;
break;
}
@@ -992,7 +992,7 @@ bt_status_t btif_get_remote_device_property(bt_bdaddr_t *remote_addr,
bt_status_t btif_get_remote_device_properties(bt_bdaddr_t *remote_addr)
{
btif_storage_req_t req;
-
+
if (btif_enabled == 0)
return BT_STATUS_FAIL;
@@ -1043,7 +1043,7 @@ bt_status_t btif_set_remote_device_property(bt_bdaddr_t *remote_addr,
** Returns bt_status_t
**
*******************************************************************************/
-bt_status_t btif_get_remote_service_record(bt_bdaddr_t *remote_addr,
+bt_status_t btif_get_remote_service_record(bt_bdaddr_t *remote_addr,
bt_uuid_t *uuid)
{
if (btif_enabled == 0)
diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c
index b5e7079..75a844f 100755..100644
--- a/btif/src/btif_dm.c
+++ b/btif/src/btif_dm.c
@@ -3,44 +3,44 @@
* Copyright (C) 2009-2012 Broadcom Corporation
*
* This program is the proprietary software of Broadcom Corporation and/or its
- * licensors, and may only be used, duplicated, modified or distributed
- * pursuant to the terms and conditions of a separate, written license
- * agreement executed between you and Broadcom (an "Authorized License").
- * Except as set forth in an Authorized License, Broadcom grants no license
- * (express or implied), right to use, or waiver of any kind with respect to
- * the Software, and Broadcom expressly reserves all rights in and to the
- * Software and all intellectual property rights therein.
- * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
- * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
- * ALL USE OF THE SOFTWARE.
+ * licensors, and may only be used, duplicated, modified or distributed
+ * pursuant to the terms and conditions of a separate, written license
+ * agreement executed between you and Broadcom (an "Authorized License").
+ * Except as set forth in an Authorized License, Broadcom grants no license
+ * (express or implied), right to use, or waiver of any kind with respect to
+ * the Software, and Broadcom expressly reserves all rights in and to the
+ * Software and all intellectual property rights therein.
+ * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
+ * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
+ * ALL USE OF THE SOFTWARE.
*
* Except as expressly set forth in the Authorized License,
*
- * 1. This program, including its structure, sequence and organization,
- * constitutes the valuable trade secrets of Broadcom, and you shall
- * use all reasonable efforts to protect the confidentiality thereof,
- * and to use this information only in connection with your use of
+ * 1. This program, including its structure, sequence and organization,
+ * constitutes the valuable trade secrets of Broadcom, and you shall
+ * use all reasonable efforts to protect the confidentiality thereof,
+ * and to use this information only in connection with your use of
* Broadcom integrated circuit products.
*
- * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
- * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
- * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
- * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
- * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
- * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
- * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
+ * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
+ * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
+ * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
+ * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
+ * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
+ * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
+ * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
* CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT
* OF USE OR PERFORMANCE OF THE SOFTWARE.
*
* 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR
- * ITS LICENSORS BE LIABLE FOR
- * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
- * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
- * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
- * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
- * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
- * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
- * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
+ * ITS LICENSORS BE LIABLE FOR
+ * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
+ * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
+ * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
+ * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
+ * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
+ * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
+ * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
* ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
*
************************************************************************************/
@@ -49,14 +49,14 @@
*
* Filename: btif_dm.c
*
- * Description: Contains Device Management (DM) related functionality
+ * Description: Contains Device Management (DM) related functionality
+ *
*
- *
***********************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-
+
#include <hardware/bluetooth.h>
#include <utils/Log.h>
@@ -64,7 +64,7 @@
#include "gki.h"
#include "btu.h"
#include "bd.h"
-#include "bta_api.h"
+#include "bta_api.h"
#include "btif_api.h"
#include "btif_util.h"
#include "btif_storage.h"
@@ -151,7 +151,7 @@ static BOOLEAN check_eir_remote_name(tBTA_DM_SEARCH *p_search_data,
p_eir_remote_name = BTA_CheckEirData(p_search_data->inq_res.p_eir,
BTM_EIR_SHORTENED_LOCAL_NAME_TYPE, &remote_name_len);
}
-
+
if (p_eir_remote_name)
{
if (remote_name_len > BD_NAME_LEN)
@@ -215,7 +215,7 @@ static void bond_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr, bt_bond
BTIF_TRACE_DEBUG3("%s: state=%d prev_state=%d", __FUNCTION__, state, pairing_cb.state);
- CHECK_CALL_CBACK(bt_hal_cbacks, bond_state_changed_cb, status, bd_addr, state);
+ HAL_CBACK(bt_hal_cbacks, bond_state_changed_cb, status, bd_addr, state);
if (state == BT_BOND_STATE_BONDING)
{
@@ -297,13 +297,13 @@ static void btif_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req)
bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING);
cod = devclass2uint(p_pin_req->dev_class);
-
- if ( cod == 0) {
+
+ if ( cod == 0) {
LOGD("cod is 0, set as unclassified");
cod = COD_UNCLASSIFIED;
}
- CHECK_CALL_CBACK(bt_hal_cbacks, pin_request_cb,
+ HAL_CBACK(bt_hal_cbacks, pin_request_cb,
&bd_addr, &bd_name, cod);
}
@@ -345,14 +345,14 @@ static void btif_dm_ssp_cfm_req_evt(tBTA_DM_SP_CFM_REQ *p_ssp_cfm_req)
}
cod = devclass2uint(p_ssp_cfm_req->dev_class);
-
+
if ( cod == 0) {
LOGD("cod is 0, set as unclassified");
cod = COD_UNCLASSIFIED;
}
/* TODO: pairing variant passkey_entry? */
- CHECK_CALL_CBACK(bt_hal_cbacks, ssp_request_cb, &bd_addr, &bd_name,
+ HAL_CBACK(bt_hal_cbacks, ssp_request_cb, &bd_addr, &bd_name,
cod, BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
p_ssp_cfm_req->num_val);
}
@@ -376,7 +376,7 @@ static void btif_dm_ssp_key_notif_evt(tBTA_DM_SP_KEY_NOTIF *p_ssp_key_notif)
cod = COD_UNCLASSIFIED;
}
- CHECK_CALL_CBACK(bt_hal_cbacks, ssp_request_cb, &bd_addr, &bd_name,
+ HAL_CBACK(bt_hal_cbacks, ssp_request_cb, &bd_addr, &bd_name,
cod, BT_SSP_VARIANT_PASSKEY_NOTIFICATION,
p_ssp_key_notif->passkey);
}
@@ -462,7 +462,7 @@ static void btif_dm_search_devices_evt (UINT16 event, char *p_param)
status = btif_storage_set_remote_device_property(&bdaddr, &properties[0]);
ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote device property", status);
- CHECK_CALL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
+ HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
status, &bdaddr, 1, properties);
}
/* TODO: Services? */
@@ -494,7 +494,7 @@ static void btif_dm_search_devices_evt (UINT16 event, char *p_param)
cod = devclass2uint (p_search_data->inq_res.dev_class);
- if ( cod == 0) {
+ if ( cod == 0) {
LOGD("cod is 0, set as unclassified");
cod = COD_UNCLASSIFIED;
}
@@ -530,7 +530,7 @@ static void btif_dm_search_devices_evt (UINT16 event, char *p_param)
strlen((char *)bdname.name)+1, &bdname);
num_properties++;
}
-
+
/* DEV_CLASS */
BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties],
BT_PROPERTY_CLASS_OF_DEVICE, sizeof(cod), &cod);
@@ -543,7 +543,7 @@ static void btif_dm_search_devices_evt (UINT16 event, char *p_param)
dev_type = BT_DEVICE_TYPE_BREDR;
#endif
BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties],
- BT_PROPERTY_TYPE_OF_DEVICE, sizeof(dev_type), &dev_type);
+ BT_PROPERTY_TYPE_OF_DEVICE, sizeof(dev_type), &dev_type);
num_properties++;
/* RSSI */
BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties],
@@ -555,7 +555,7 @@ static void btif_dm_search_devices_evt (UINT16 event, char *p_param)
ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote device (inquiry)", status);
/* Callback to notify upper layer of device */
- CHECK_CALL_CBACK(bt_hal_cbacks, device_found_cb,
+ HAL_CBACK(bt_hal_cbacks, device_found_cb,
num_properties, properties);
}
}
@@ -569,7 +569,7 @@ static void btif_dm_search_devices_evt (UINT16 event, char *p_param)
case BTA_DM_DISC_CMPL_EVT:
case BTA_DM_SEARCH_CANCEL_CMPL_EVT:
{
- CHECK_CALL_CBACK(bt_hal_cbacks, discovery_state_changed_cb, BT_DISCOVERY_STOPPED);
+ HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb, BT_DISCOVERY_STOPPED);
}
break;
}
@@ -612,7 +612,7 @@ static void btif_dm_search_services_evt(UINT16 event, char *p_param)
&(tBTA_SERVICE_MASK)(BTA_SERVICE_ID_TO_SERVICE_MASK(i)))
{
memset(&uuid_arr[j], 0, sizeof(bt_uuid_t));
- uuid16_to_uuid128(bta_service_id_to_uuid_lkup_tbl[i], &uuid_arr[j]);
+ uuid16_to_uuid128(bta_service_id_to_uuid_lkup_tbl[i], &uuid_arr[j]);
prop.len += sizeof(bt_uuid_t);
j++;
}
@@ -622,7 +622,7 @@ static void btif_dm_search_services_evt(UINT16 event, char *p_param)
ASSERTC(ret == BT_STATUS_SUCCESS, "storing remote services failed", ret);
/* Send the event to the BTIF */
- CHECK_CALL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
+ HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
BT_STATUS_SUCCESS, &bd_addr, 1, &prop);
}
break;
@@ -678,7 +678,7 @@ static void btif_dm_remote_service_record_evt(UINT16 event, char *p_param)
/* TODO: Need to get the service name using p_raw_data */
rec.name[0] = 0;
- CHECK_CALL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
+ HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
BT_STATUS_SUCCESS, &bd_addr, 1, &prop);
}
break;
@@ -795,12 +795,12 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param)
case BTA_DM_AUTHORIZE_EVT:
case BTA_DM_LINK_DOWN_EVT:
- case BTA_DM_SIG_STRENGTH_EVT:
+ case BTA_DM_SIG_STRENGTH_EVT:
case BTA_DM_BUSY_LEVEL_EVT:
case BTA_DM_BOND_CANCEL_CMPL_EVT:
case BTA_DM_SP_RMT_OOB_EVT:
case BTA_DM_SP_KEYPRESS_EVT:
- case BTA_DM_ROLE_CHG_EVT:
+ case BTA_DM_ROLE_CHG_EVT:
case BTA_DM_BLE_KEY_EVT:
case BTA_DM_BLE_SEC_REQ_EVT:
case BTA_DM_BLE_PASSKEY_NOTIF_EVT:
@@ -832,7 +832,7 @@ static void btif_dm_generic_evt(UINT16 event, char* p_param)
{
case BTIF_DM_CB_DISCOVERY_STARTED:
{
- CHECK_CALL_CBACK(bt_hal_cbacks, discovery_state_changed_cb, BT_DISCOVERY_STARTED);
+ HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb, BT_DISCOVERY_STARTED);
}
break;
@@ -863,7 +863,7 @@ static void btif_dm_generic_evt(UINT16 event, char* p_param)
void bte_dm_evt(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *p_data)
{
bt_status_t status;
-
+
/* switch context to btif task context (copy full union size for convenience) */
status = btif_transfer_context(btif_dm_upstreams_evt, (uint16_t)event, (void*)p_data, sizeof(tBTA_DM_SEC), NULL);
@@ -1019,7 +1019,7 @@ bt_status_t btif_dm_cancel_discovery(void)
bt_status_t btif_dm_create_bond(const bt_bdaddr_t *bd_addr)
{
bdstr_t bdstr;
-
+
BTIF_TRACE_EVENT2("%s: bd_addr=%s", __FUNCTION__, bd2str((bt_bdaddr_t *) bd_addr, &bdstr));
if (pairing_cb.state != BT_BOND_STATE_NONE)
@@ -1083,7 +1083,7 @@ bt_status_t btif_dm_remove_bond(const bt_bdaddr_t *bd_addr)
/* TODO: special handling for HID devices */
if (BTA_DmRemoveDevice((UINT8 *)bd_addr->address) == BTA_SUCCESS)
{
- BTIF_TRACE_DEBUG1("Successfully removed bonding with device: %s",
+ BTIF_TRACE_DEBUG1("Successfully removed bonding with device: %s",
bd2str((bt_bdaddr_t *)bd_addr, &bdstr));
}
@@ -1224,7 +1224,7 @@ bt_status_t btif_dm_get_remote_services(bt_bdaddr_t *remote_addr)
**
** Returns bt_status_t
*******************************************************************************/
-bt_status_t btif_dm_get_remote_service_record(bt_bdaddr_t *remote_addr,
+bt_status_t btif_dm_get_remote_service_record(bt_bdaddr_t *remote_addr,
bt_uuid_t *uuid)
{
tSDP_UUID sdp_uuid;
@@ -1258,7 +1258,7 @@ void btif_dm_execute_service_request(UINT16 event, char *p_param)
BTIF_STORAGE_FILL_PROPERTY(&property, BT_PROPERTY_UUIDS,
sizeof(local_uuids), local_uuids);
btif_storage_get_adapter_property(&property);
- CHECK_CALL_CBACK(bt_hal_cbacks, adapter_properties_cb,
+ HAL_CBACK(bt_hal_cbacks, adapter_properties_cb,
BT_STATUS_SUCCESS, 1, &property);
}
return;
diff --git a/btif/src/btif_hf.c b/btif/src/btif_hf.c
index ddc4a14..18939cb 100644
--- a/btif/src/btif_hf.c
+++ b/btif/src/btif_hf.c
@@ -3,44 +3,44 @@
* Copyright (C) 2009-2012 Broadcom Corporation
*
* This program is the proprietary software of Broadcom Corporation and/or its
- * licensors, and may only be used, duplicated, modified or distributed
- * pursuant to the terms and conditions of a separate, written license
- * agreement executed between you and Broadcom (an "Authorized License").
- * Except as set forth in an Authorized License, Broadcom grants no license
- * (express or implied), right to use, or waiver of any kind with respect to
- * the Software, and Broadcom expressly reserves all rights in and to the
- * Software and all intellectual property rights therein.
- * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
- * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
- * ALL USE OF THE SOFTWARE.
+ * licensors, and may only be used, duplicated, modified or distributed
+ * pursuant to the terms and conditions of a separate, written license
+ * agreement executed between you and Broadcom (an "Authorized License").
+ * Except as set forth in an Authorized License, Broadcom grants no license
+ * (express or implied), right to use, or waiver of any kind with respect to
+ * the Software, and Broadcom expressly reserves all rights in and to the
+ * Software and all intellectual property rights therein.
+ * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
+ * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
+ * ALL USE OF THE SOFTWARE.
*
* Except as expressly set forth in the Authorized License,
*
- * 1. This program, including its structure, sequence and organization,
- * constitutes the valuable trade secrets of Broadcom, and you shall
- * use all reasonable efforts to protect the confidentiality thereof,
- * and to use this information only in connection with your use of
+ * 1. This program, including its structure, sequence and organization,
+ * constitutes the valuable trade secrets of Broadcom, and you shall
+ * use all reasonable efforts to protect the confidentiality thereof,
+ * and to use this information only in connection with your use of
* Broadcom integrated circuit products.
*
- * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
- * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
- * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
- * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
- * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
- * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
- * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
+ * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
+ * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
+ * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
+ * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
+ * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
+ * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
+ * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
* CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT
* OF USE OR PERFORMANCE OF THE SOFTWARE.
*
* 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR
- * ITS LICENSORS BE LIABLE FOR
- * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
- * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
- * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
- * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
- * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
- * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
- * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
+ * ITS LICENSORS BE LIABLE FOR
+ * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
+ * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
+ * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
+ * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
+ * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
+ * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
+ * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
* ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
*
************************************************************************************/
@@ -50,8 +50,8 @@
* Filename: btif_hf.c
*
* Description: Handsfree Profile Bluetooth Interface
- *
- *
+ *
+ *
***********************************************************************************/
#include <hardware/bluetooth.h>
@@ -252,13 +252,13 @@ void clear_phone_state()
**
** Description Executes HF UPSTREAMS events in btif context
**
-** Returns void
+** Returns void
**
*******************************************************************************/
static void btif_hf_upstreams_evt(UINT16 event, char* p_param)
{
tBTA_AG *p_data = (tBTA_AG *)p_param;
- bdstr_t bdstr;
+ bdstr_t bdstr;
BTIF_TRACE_DEBUG2("%s: event=%s", __FUNCTION__, dump_hf_event(event));
@@ -291,7 +291,7 @@ static void btif_hf_upstreams_evt(UINT16 event, char* p_param)
break;
}
- CHECK_CALL_CBACK(bt_hf_callbacks, connection_state_cb, btif_hf_cb.state, &btif_hf_cb.connected_bda);
+ HAL_CBACK(bt_hf_callbacks, connection_state_cb, btif_hf_cb.state, &btif_hf_cb.connected_bda);
if (btif_hf_cb.state == BTHF_CONNECTION_STATE_DISCONNECTED)
bdsetany(btif_hf_cb.connected_bda.address);
@@ -299,8 +299,7 @@ static void btif_hf_upstreams_evt(UINT16 event, char* p_param)
case BTA_AG_CLOSE_EVT:
btif_hf_cb.state = BTHF_CONNECTION_STATE_DISCONNECTED;
- CHECK_CALL_CBACK(bt_hf_callbacks, connection_state_cb, btif_hf_cb.state, &btif_hf_cb.connected_bda);
-
+ HAL_CBACK(bt_hf_callbacks, connection_state_cb, btif_hf_cb.state, &btif_hf_cb.connected_bda);
bdsetany(btif_hf_cb.connected_bda.address);
btif_hf_cb.peer_feat = 0;
clear_phone_state();
@@ -311,56 +310,56 @@ static void btif_hf_upstreams_evt(UINT16 event, char* p_param)
btif_hf_cb.peer_feat = p_data->conn.peer_feat;
btif_hf_cb.state = BTHF_CONNECTION_STATE_SLC_CONNECTED;
- CHECK_CALL_CBACK(bt_hf_callbacks, connection_state_cb, btif_hf_cb.state,
+ HAL_CBACK(bt_hf_callbacks, connection_state_cb, btif_hf_cb.state,
&btif_hf_cb.connected_bda);
break;
case BTA_AG_AUDIO_OPEN_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, audio_state_cb, BTHF_AUDIO_STATE_CONNECTED, &btif_hf_cb.connected_bda);
+ HAL_CBACK(bt_hf_callbacks, audio_state_cb, BTHF_AUDIO_STATE_CONNECTED, &btif_hf_cb.connected_bda);
break;
case BTA_AG_AUDIO_CLOSE_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, audio_state_cb, BTHF_AUDIO_STATE_DISCONNECTED, &btif_hf_cb.connected_bda);
+ HAL_CBACK(bt_hf_callbacks, audio_state_cb, BTHF_AUDIO_STATE_DISCONNECTED, &btif_hf_cb.connected_bda);
break;
/* BTA auto-responds, silently discard */
case BTA_AG_SPK_EVT:
case BTA_AG_MIC_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, volume_cmd_cb,
+ HAL_CBACK(bt_hf_callbacks, volume_cmd_cb,
(event == BTA_AG_SPK_EVT) ? BTHF_VOLUME_TYPE_SPK : BTHF_VOLUME_TYPE_MIC, p_data->val.num);
break;
case BTA_AG_AT_A_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, answer_call_cmd_cb);
+ HAL_CBACK(bt_hf_callbacks, answer_call_cmd_cb);
break;
/* Java needs to send OK/ERROR for these commands */
case BTA_AG_AT_BLDN_EVT:
case BTA_AG_AT_D_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, dial_call_cmd_cb,
+ HAL_CBACK(bt_hf_callbacks, dial_call_cmd_cb,
(event == BTA_AG_AT_D_EVT) ? p_data->val.str : NULL);
break;
case BTA_AG_AT_CHUP_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, hangup_call_cmd_cb);
+ HAL_CBACK(bt_hf_callbacks, hangup_call_cmd_cb);
break;
case BTA_AG_AT_CIND_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, cind_cmd_cb);
+ HAL_CBACK(bt_hf_callbacks, cind_cmd_cb);
break;
case BTA_AG_AT_VTS_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, dtmf_cmd_cb, p_data->val.str[0]);
+ HAL_CBACK(bt_hf_callbacks, dtmf_cmd_cb, p_data->val.str[0]);
break;
case BTA_AG_AT_BVRA_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, vr_cmd_cb,
+ HAL_CBACK(bt_hf_callbacks, vr_cmd_cb,
(p_data->val.num == 1) ? BTHF_VR_STATE_STARTED : BTHF_VR_STATE_STOPPED);
break;
case BTA_AG_AT_NREC_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, nrec_cmd_cb,
+ HAL_CBACK(bt_hf_callbacks, nrec_cmd_cb,
(p_data->val.num == 1) ? BTHF_NREC_START : BTHF_NREC_STOP);
break;
@@ -369,29 +368,29 @@ static void btif_hf_upstreams_evt(UINT16 event, char* p_param)
break;
case BTA_AG_AT_CKPD_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, key_pressed_cmd_cb);
+ HAL_CBACK(bt_hf_callbacks, key_pressed_cmd_cb);
break;
/* Java needs to send OK/ERROR for these commands */
case BTA_AG_AT_CHLD_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, chld_cmd_cb, atoi(p_data->val.str));
+ HAL_CBACK(bt_hf_callbacks, chld_cmd_cb, atoi(p_data->val.str));
break;
case BTA_AG_AT_CLCC_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, clcc_cmd_cb, p_data->val.num);
+ HAL_CBACK(bt_hf_callbacks, clcc_cmd_cb, p_data->val.num);
break;
case BTA_AG_AT_COPS_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, cops_cmd_cb);
+ HAL_CBACK(bt_hf_callbacks, cops_cmd_cb);
break;
case BTA_AG_AT_UNAT_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, unknown_at_cmd_cb,
+ HAL_CBACK(bt_hf_callbacks, unknown_at_cmd_cb,
p_data->val.str);
break;
case BTA_AG_AT_CNUM_EVT:
- CHECK_CALL_CBACK(bt_hf_callbacks, cnum_cmd_cb);
+ HAL_CBACK(bt_hf_callbacks, cnum_cmd_cb);
break;
/* TODO: Some of these commands may need to be sent to app. For now respond with error */
@@ -413,7 +412,7 @@ static void btif_hf_upstreams_evt(UINT16 event, char* p_param)
**
** Description Switches context from BTE to BTIF for all HF events
**
-** Returns void
+** Returns void
**
*******************************************************************************/
@@ -433,7 +432,7 @@ static void bte_hf_evt(tBTA_AG_EVT event, tBTA_AG *p_data)
param_len = sizeof(tBTA_AG_HDR);
else if (p_data)
param_len = sizeof(tBTA_AG_VAL);
-
+
/* switch context to btif task context (copy full union size for convenience) */
status = btif_transfer_context(btif_hf_upstreams_evt, (uint16_t)event, (void*)p_data, param_len, NULL);
@@ -482,7 +481,7 @@ static bt_status_t connect( bt_bdaddr_t *bd_addr )
btif_hf_cb.state = BTHF_CONNECTION_STATE_CONNECTING;
bdcpy(btif_hf_cb.connected_bda.address, bd_addr->address);
- BTA_AgOpen(btif_hf_cb.handle, btif_hf_cb.connected_bda.address,
+ BTA_AgOpen(btif_hf_cb.handle, btif_hf_cb.connected_bda.address,
BTIF_HF_SECURITY, BTA_HSP_SERVICE_MASK | BTA_HFP_SERVICE_MASK);
return BT_STATUS_SUCCESS;
@@ -725,7 +724,7 @@ static bt_status_t cind_response(int svc, int num_active, int num_held,
if (is_connected(NULL))
{
tBTA_AG_RES_DATA ag_res;
-
+
memset (&ag_res, 0, sizeof (ag_res));
sprintf (ag_res.str, "%d,%d,%d,%d,%d,%d,%d",
(num_active ? 1 : 0), /* Call state */
@@ -735,7 +734,7 @@ static bt_status_t cind_response(int svc, int num_active, int num_held,
roam, /* Roaming indicator */
batt_chg, /* Battery level */
(num_held ? 1 : 0)); /* Call held */
-
+
BTA_AgResult (btif_hf_cb.handle, BTA_AG_CIND_RES, &ag_res);
return BT_STATUS_SUCCESS;
@@ -978,7 +977,7 @@ static bt_status_t phone_state_change(int num_active, int num_held, bthf_call_st
case BTHF_CALL_STATE_ALERTING:
/* if we went from idle->alert, force SCO setup here. dialing usually triggers it */
if (btif_hf_cb.call_setup_state == BTHF_CALL_STATE_IDLE)
- ag_res.audio_handle = btif_hf_cb.handle;
+ ag_res.audio_handle = btif_hf_cb.handle;
res = BTA_AG_OUT_CALL_ALERT_RES;
break;
default:
diff --git a/btif/src/btif_media_task.c b/btif/src/btif_media_task.c
index e11d307..22893c9 100644
--- a/btif/src/btif_media_task.c
+++ b/btif/src/btif_media_task.c
@@ -81,7 +81,7 @@
#include "l2c_api.h"
-#include "btif_av.h"
+#include "btif_av_co.h"
#include "btif_media.h"
@@ -89,7 +89,13 @@
#include "sbc_encoder.h"
#endif
+#define LOG_TAG "BTIF-MEDIA"
+#include <hardware/bluetooth.h>
+#include "audio_a2dp_hw.h"
+#include "btif_av.h"
+#include "btif_sm.h"
+#include "btif_util.h"
/*****************************************************************************
** Constants
@@ -166,6 +172,35 @@ enum
#define DEFAULT_SBC_BITRATE 220
+#ifndef A2DP_MEDIA_TASK_STACK_SIZE
+#define A2DP_MEDIA_TASK_STACK_SIZE 0x2000 /* In bytes */
+#endif
+
+#define A2DP_MEDIA_TASK_TASK_STR ((INT8 *) "A2DP-MEDIA")
+static UINT32 a2dp_media_task_stack[(A2DP_MEDIA_TASK_STACK_SIZE + 3) / 4];
+
+#define BT_MEDIA_TASK A2DP_MEDIA_TASK
+
+#define USEC_PER_SEC 1000000L
+#define TPUT_STATS_INTERVAL_US (1000*1000)
+
+/*
+ * CONGESTION COMPENSATION CTRL ::
+ *
+ * Thus setting controls how many buffers we will hold in media task
+ * during temp link congestion. Together with the stack buffer queues
+ * it controls much temporary a2dp link congestion we can
+ * compensate for. It however also depends on the default run level of sinks
+ * jitterbuffers. Depending on type of sink this would vary.
+ * Ideally the (SRC) max tx buffer capacity should equal the sinks
+ * jitterbuffer runlevel including any intermediate buffers on the way
+ * towards the sinks codec.
+ */
+
+/* fixme -- define this in pcm time instead of buffer count */
+/* fixme -- tune optimal value. For now set a large buffer capacity */
+#define MAX_OUTPUT_BUFFER_QUEUE_SZ 12
+
/*****************************************************************************
** Data types
*****************************************************************************/
@@ -196,6 +231,10 @@ typedef struct
tBTIF_AV_MEDIA_FEEDINGS_STATE media_feeding_state;
SBC_ENC_PARAMS encoder;
UINT8 busy_level;
+ void* av_sm_hdl;
+ UINT8 a2dp_cmd_pending; /* we can have max one command pending */
+ BOOLEAN tx_flush; /* discards any outgoing data when true */
+
#if ((defined(BTIF_MEDIA_OVERFEED_INCLUDED) && (BTIF_MEDIA_OVERFEED_INCLUDED == TRUE)) || \
(defined(BTIF_MEDIA_UNDERFEED_INCLUDED) && (BTIF_MEDIA_UNDERFEED_INCLUDED == TRUE)))
UINT8 tx_counter;
@@ -204,16 +243,34 @@ typedef struct
} tBTIF_MEDIA_CB;
+typedef struct {
+ int rx;
+ int rx_tot;
+ int tx;
+ int tx_tot;
+ int ts_prev_us;
+} t_stat;
+
/*****************************************************************************
** Local data
*****************************************************************************/
static tBTIF_MEDIA_CB btif_media_cb;
+static int media_task_running = 0;
+
/*****************************************************************************
** Local functions
*****************************************************************************/
+static void btif_a2dp_data_cb(tUIPC_CH_ID ch_id, tUIPC_EVENT event);
+static void btif_a2dp_ctrl_cb(tUIPC_CH_ID ch_id, tUIPC_EVENT event);
+static void btif_a2dp_encoder_update(void);
+
+/*****************************************************************************
+ ** Externs
+ *****************************************************************************/
+
static void btif_media_task_handle_cmd(BT_HDR *p_msg);
static void btif_media_task_handle_media(BT_HDR *p_msg);
@@ -231,41 +288,9 @@ static void btif_media_aa_prep_2_send(UINT8 nb_frame);
/*****************************************************************************
- **
+ ** Misc helper functions
*****************************************************************************/
-#define UIPC_CH_ID_AV_AUDIO 0
-
-/* Events generated */
-#define UIPC_OPEN_EVT 0x01
-#define UIPC_CLOSE_EVT 0x02
-#define UIPC_RX_DATA_EVT 0x03
-#define UIPC_RX_DATA_READY_EVT 0x04
-#define UIPC_TX_DATA_READY_EVT 0x05
-
-#ifndef A2DP_MEDIA_TASK_STACK_SIZE
-#define A2DP_MEDIA_TASK_STACK_SIZE 0x2000 /* In bytes */
-#endif
-
-#define A2DP_MEDIA_TASK_TASK_STR ((INT8 *) "A2DP-MEDIA")
-static UINT32 a2dp_media_task_stack[(A2DP_MEDIA_TASK_STACK_SIZE + 3) / 4];
-
-#define BT_MEDIA_TASK A2DP_MEDIA_TASK
-
-#define CASE_RETURN_STR(const) case const: return #const;
-
-
-#define USEC_PER_SEC 1000000L
-#define TPUT_STATS_INTERVAL_US (1000*1000)
-
-typedef struct {
- int rx;
- int rx_tot;
- int tx;
- int tx_tot;
- int ts_prev_us;
-} t_stat;
-
static void tput_mon(int is_rx, int len, int reset)
{
/* only monitor one connection at a time for now */
@@ -279,7 +304,7 @@ static void tput_mon(int is_rx, int len, int reset)
memset(&cur_stat, 0, sizeof(t_stat));
return;
}
-
+
if (is_rx)
{
cur_stat.rx+=len;
@@ -288,13 +313,13 @@ static void tput_mon(int is_rx, int len, int reset)
else
{
cur_stat.tx+=len;
- cur_stat.tx_tot+=len;
+ cur_stat.tx_tot+=len;
}
clock_gettime(CLOCK_MONOTONIC, &now);
-
+
now_us = now.tv_sec*USEC_PER_SEC + now.tv_nsec/1000;
- //APPL_TRACE_EVENT1("%d us", now_us - cur_stat.ts_prev_us);
+ //APPL_TRACE_DEBUG1("%d us", now_us - cur_stat.ts_prev_us);
if ((now_us - cur_stat.ts_prev_us) < TPUT_STATS_INTERVAL_US)
return;
@@ -311,7 +336,7 @@ static void tput_mon(int is_rx, int len, int reset)
}
-void log_tstamps_us(char *comment)
+static void log_tstamps_us(char *comment)
{
#define USEC_PER_SEC 1000000L
static struct timespec prev = {0, 0};
@@ -322,10 +347,11 @@ void log_tstamps_us(char *comment)
clock_gettime(CLOCK_MONOTONIC, &now);
now_us = now.tv_sec*USEC_PER_SEC + now.tv_nsec/1000;
diff_us = (now.tv_sec - prev.tv_sec) * USEC_PER_SEC + (now.tv_nsec - prev.tv_nsec)/1000;
-
- APPL_TRACE_EVENT3("[%s] ts %08d, diff : %08d", comment, now_us, diff_us);
- prev = now;
+ APPL_TRACE_DEBUG4("[%s] ts %08d, diff : %08d, queue sz %d", comment, now_us, diff_us,
+ btif_media_cb.TxAaQ.count);
+
+ prev = now;
}
const char* dump_media_event(UINT16 event)
@@ -350,7 +376,211 @@ const char* dump_media_event(UINT16 event)
}
}
-void btif_av_encoder_init(void)
+
+/*****************************************************************************
+ ** A2DP CTRL PATH
+ *****************************************************************************/
+
+static const char* dump_a2dp_ctrl_event(UINT8 event)
+{
+ switch(event)
+ {
+ CASE_RETURN_STR(A2DP_CTRL_CMD_NONE)
+ CASE_RETURN_STR(A2DP_CTRL_CMD_CHECK_READY)
+ CASE_RETURN_STR(A2DP_CTRL_CMD_START)
+ CASE_RETURN_STR(A2DP_CTRL_CMD_STOP)
+ CASE_RETURN_STR(A2DP_CTRL_CMD_SUSPEND)
+ default:
+ return "UNKNOWN MSG ID";
+ }
+}
+
+static void btif_audiopath_detached(void)
+{
+ APPL_TRACE_EVENT0("## AUDIO PATH DETACHED ##");
+
+ /* send stop request only if we are actively streaming and haven't received
+ a stop request. Potentially audioflinger detached abnormally */
+ if (btif_media_cb.is_tx_timer)
+ {
+ /* post stop event and wait for audio path to stop */
+ btif_dispatch_sm_event(BTIF_AV_STOP_STREAM_REQ_EVT, NULL, 0);
+ }
+}
+
+static void a2dp_cmd_acknowledge(int status)
+{
+ UINT8 ack = status;
+
+ APPL_TRACE_EVENT2("## a2dp ack : %s, status %d ##", dump_a2dp_ctrl_event(btif_media_cb.a2dp_cmd_pending), status);
+
+ /* sanity check */
+ if (btif_media_cb.a2dp_cmd_pending == A2DP_CTRL_CMD_NONE)
+ {
+ APPL_TRACE_ERROR0("warning : no command pending, ignore ack");
+ return;
+ }
+
+ /* clear pending */
+ btif_media_cb.a2dp_cmd_pending = A2DP_CTRL_CMD_NONE;
+
+ /* acknowledge start request */
+ UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, &ack, 1);
+}
+
+
+static void btif_recv_ctrl_data(void)
+{
+ UINT8 cmd = 0;
+ int n;
+
+ n = UIPC_Read(UIPC_CH_ID_AV_CTRL, NULL, &cmd, 1);
+
+ /* detach on ctrl channel means audioflinger process was terminated */
+ if (n == 0)
+ {
+ APPL_TRACE_EVENT0("CTRL CH DETACHED");
+ UIPC_Close(UIPC_CH_ID_AV_CTRL);
+ /* we can operate only on datachannel, if af client wants to
+ do send additional commands the ctrl channel would be reestablished */
+ //btif_audiopath_detached();
+ return;
+ }
+
+ APPL_TRACE_EVENT1("a2dp-ctrl-cmd : %s", dump_a2dp_ctrl_event(cmd));
+
+ btif_media_cb.a2dp_cmd_pending = cmd;
+
+ switch(cmd)
+ {
+ case A2DP_CTRL_CMD_CHECK_READY:
+
+ /* check whether avdtp is ready to start */
+ if (btif_av_stream_ready() == TRUE)
+ {
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_SUCCESS);
+ }
+ else
+ {
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_FAILURE);
+ }
+ break;
+
+ case A2DP_CTRL_CMD_START:
+
+ if (btif_av_stream_ready() == TRUE)
+ {
+ /* setup audio data channel listener */
+ UIPC_Open(UIPC_CH_ID_AV_AUDIO, btif_a2dp_data_cb);
+
+ /* post start event and wait for audio path to open */
+ btif_dispatch_sm_event(BTIF_AV_START_STREAM_REQ_EVT, NULL, 0);
+
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_SUCCESS);
+ }
+ else if (btif_av_stream_started())
+ {
+ /* setup audio data channel listener */
+ UIPC_Open(UIPC_CH_ID_AV_AUDIO, btif_a2dp_data_cb);
+
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_SUCCESS);
+ }
+ else
+ {
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_FAILURE);
+ break;
+ }
+ break;
+
+ case A2DP_CTRL_CMD_STOP:
+
+ if (btif_media_cb.is_tx_timer == FALSE)
+ {
+ /* we are already stopped, just ack back */
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_SUCCESS);
+ break;
+ }
+
+ btif_dispatch_sm_event(BTIF_AV_STOP_STREAM_REQ_EVT, NULL, 0);
+ break;
+
+ case A2DP_CTRL_CMD_SUSPEND:
+ /* local suspend */
+ btif_dispatch_sm_event(BTIF_AV_SUSPEND_STREAM_REQ_EVT, NULL, 0);
+ break;
+
+ default:
+ APPL_TRACE_ERROR1("UNSUPPORTED CMD (%d)", cmd);
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_FAILURE);
+ break;
+ }
+ APPL_TRACE_EVENT1("a2dp-ctrl-cmd : %s DONE", dump_a2dp_ctrl_event(cmd));
+}
+
+static void btif_a2dp_ctrl_cb(tUIPC_CH_ID ch_id, tUIPC_EVENT event)
+{
+ APPL_TRACE_DEBUG1("A2DP-CTRL-CHANNEL EVENT %s", dump_uipc_event(event));
+
+ switch(event)
+ {
+ case UIPC_OPEN_EVT:
+ /* fetch av statemachine handle */
+ btif_media_cb.av_sm_hdl = btif_av_get_sm_handle();
+ break;
+
+ case UIPC_CLOSE_EVT:
+ /* restart ctrl server */
+ UIPC_Open(UIPC_CH_ID_AV_CTRL , btif_a2dp_ctrl_cb);
+ break;
+
+ case UIPC_RX_DATA_READY_EVT:
+ btif_recv_ctrl_data();
+ break;
+
+ default :
+ APPL_TRACE_ERROR1("### A2DP-CTRL-CHANNEL EVENT %d NOT HANDLED ###", event);
+ break;
+ }
+}
+
+static void btif_a2dp_data_cb(tUIPC_CH_ID ch_id, tUIPC_EVENT event)
+{
+ APPL_TRACE_DEBUG1("BTIF MEDIA (A2DP-DATA) EVENT %s", dump_uipc_event(event));
+
+ switch(event)
+ {
+ case UIPC_OPEN_EVT:
+
+ /* read directly from media task from here on (keep callback for
+ connection events */
+ UIPC_Ioctl(UIPC_CH_ID_AV_AUDIO, UIPC_REG_REMOVE_ACTIVE_READSET, NULL);
+
+ /* make sure we update any changed sbc encoder params */
+ btif_a2dp_encoder_update();
+
+ /* Start the media task to encode SBC */
+ btif_media_task_start_aa_req();
+
+ /* ack back when media task is fully started */
+ break;
+
+ case UIPC_CLOSE_EVT:
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_SUCCESS);
+ btif_audiopath_detached();
+ break;
+
+ default :
+ APPL_TRACE_ERROR1("### A2DP-DATA EVENT %d NOT HANDLED ###", event);
+ break;
+ }
+}
+
+
+/*****************************************************************************
+ ** BTIF ADAPTATION
+ *****************************************************************************/
+
+static void btif_a2dp_encoder_init(void)
{
UINT16 minmtu;
tBTIF_MEDIA_INIT_AUDIO msg;
@@ -365,7 +595,7 @@ void btif_av_encoder_init(void)
/* lookup table to convert freq */
UINT16 freq_block_tbl[5] = { SBC_sf48000, SBC_sf44100, SBC_sf32000, 0, SBC_sf16000 };
- APPL_TRACE_DEBUG0("btif_av_encoder_init");
+ APPL_TRACE_DEBUG0("btif_a2dp_encoder_init");
/* Retrieve the current SBC configuration (default if currently not used) */
bta_av_co_audio_get_sbc_config(&sbc_config, &minmtu);
@@ -380,24 +610,24 @@ void btif_av_encoder_init(void)
btif_media_task_enc_init_req(&msg);
}
-static void btif_av_encoder_update(void)
+static void btif_a2dp_encoder_update(void)
{
UINT16 minmtu;
tA2D_SBC_CIE sbc_config;
tBTIF_MEDIA_UPDATE_AUDIO msg;
- APPL_TRACE_DEBUG0("btif_av_encoder_update");
+ APPL_TRACE_DEBUG0("btif_a2dp_encoder_update");
/* Retrieve the current SBC configuration (default if currently not used) */
bta_av_co_audio_get_sbc_config(&sbc_config, &minmtu);
- APPL_TRACE_DEBUG4("btif_av_encoder_update: Common min_bitpool:%d(0x%x) max_bitpool:%d(0x%x)",
+ APPL_TRACE_DEBUG4("btif_a2dp_encoder_update: Common min_bitpool:%d(0x%x) max_bitpool:%d(0x%x)",
sbc_config.min_bitpool, sbc_config.min_bitpool,
sbc_config.max_bitpool, sbc_config.max_bitpool);
if (sbc_config.min_bitpool > sbc_config.max_bitpool)
{
- APPL_TRACE_ERROR0("btif_av_encoder_update: ERROR btif_av_encoder_update min_bitpool > max_bitpool");
+ APPL_TRACE_ERROR0("btif_a2dp_encoder_update: ERROR btif_a2dp_encoder_update min_bitpool > max_bitpool");
}
msg.MinBitPool = sbc_config.min_bitpool;
@@ -408,42 +638,79 @@ static void btif_av_encoder_update(void)
}
-static int media_task_running = 0;
+/*****************************************************************************
+**
+** Function btif_a2dp_start_media_task
+**
+** Description
+**
+** Returns
+**
+*******************************************************************************/
int btif_a2dp_start_media_task(void)
{
if (media_task_running)
{
- APPL_TRACE_EVENT0("warning : media task already running");
+ APPL_TRACE_ERROR0("warning : media task already running");
return GKI_FAILURE;
}
+ APPL_TRACE_EVENT0("## A2DP START MEDIA TASK ##");
+
media_task_running = 1;
/* start a2dp media task */
- return GKI_create_task((TASKPTR)btif_media_task, A2DP_MEDIA_TASK,
+ return GKI_create_task((TASKPTR)btif_media_task, A2DP_MEDIA_TASK,
A2DP_MEDIA_TASK_TASK_STR,
(UINT16 *) ((UINT8 *)a2dp_media_task_stack + A2DP_MEDIA_TASK_STACK_SIZE),
- sizeof(a2dp_media_task_stack));
+ sizeof(a2dp_media_task_stack));
}
+/*****************************************************************************
+**
+** Function btif_a2dp_stop_media_task
+**
+** Description
+**
+** Returns
+**
+*******************************************************************************/
+
void btif_a2dp_stop_media_task(void)
{
- APPL_TRACE_EVENT1("%s", __FUNCTION__);
+ APPL_TRACE_EVENT0("## A2DP STOP MEDIA TASK ##");
GKI_send_msg(BT_MEDIA_TASK, BTIF_MEDIA_TASK_KILL, NULL);
}
-void btif_a2dp_upon_init(void)
+/*****************************************************************************
+**
+** Function btif_a2dp_on_init
+**
+** Description
+**
+** Returns
+**
+*******************************************************************************/
+
+void btif_a2dp_on_init(void)
{
- void btif_media_task_init(void);
- btif_media_task_init();
-
//tput_mon(1, 0, 1);
}
-void btif_a2dp_upon_idle(void)
+/*****************************************************************************
+**
+** Function btif_a2dp_on_idle
+**
+** Description
+**
+** Returns
+**
+*******************************************************************************/
+
+void btif_a2dp_on_idle(void)
{
- APPL_TRACE_EVENT1("%s", __FUNCTION__);
+ APPL_TRACE_EVENT0("## ON A2DP IDLE ##");
/* Make sure media task is stopped */
btif_media_task_stop_aa_req();
@@ -451,27 +718,55 @@ void btif_a2dp_upon_idle(void)
bta_av_co_init();
}
-void btif_a2dp_upon_start_req(void)
+/*****************************************************************************
+**
+** Function btif_a2dp_on_open
+**
+** Description
+**
+** Returns
+**
+*******************************************************************************/
+
+void btif_a2dp_on_open(void)
+{
+ APPL_TRACE_EVENT0("## ON A2DP OPEN ##");
+
+ /* always use callback to notify socket events */
+ UIPC_Open(UIPC_CH_ID_AV_AUDIO, btif_a2dp_data_cb);
+}
+
+/*****************************************************************************
+**
+** Function btif_a2dp_on_start_req
+**
+** Description
+**
+** Returns
+**
+*******************************************************************************/
+
+void btif_a2dp_on_start_req(void)
{
tBTIF_AV_MEDIA_FEEDINGS media_feeding;
tBTIF_STATUS status;
- APPL_TRACE_EVENT1("%s", __FUNCTION__);
+ APPL_TRACE_EVENT0("## ON A2DP START ##");
GKI_disable();
-
+
/* for now hardcode 44.1 khz 16 bit stereo */
media_feeding.cfg.pcm.sampling_freq = 44100;
media_feeding.cfg.pcm.bit_per_sample = 16;
media_feeding.cfg.pcm.num_channel = 2;
media_feeding.format = BTIF_AV_CODEC_PCM;
- if (bta_av_co_audio_set_codec(&media_feeding, &status))
- {
+ if (bta_av_co_audio_set_codec(&media_feeding, &status))
+ {
tBTIF_MEDIA_INIT_AUDIO_FEEDING mfeed;
/* Init the encoding task */
- btif_av_encoder_init();
+ btif_a2dp_encoder_init();
/* Build the media task configuration */
mfeed.feeding = media_feeding;
@@ -483,13 +778,117 @@ void btif_a2dp_upon_start_req(void)
GKI_enable();
}
-void btif_a2dp_upon_started(void)
+
+/*****************************************************************************
+**
+** Function btif_a2dp_on_started
+**
+** Description
+**
+** Returns
+**
+*******************************************************************************/
+
+void btif_a2dp_on_started(tBTA_AV_START *p_av)
+{
+ APPL_TRACE_EVENT0("## ON A2DP STARTED ##");
+
+ if (p_av->status == BTA_AV_SUCCESS)
+ {
+ if (p_av->suspending == FALSE)
+ {
+ if (p_av->initiator)
+ {
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_SUCCESS);
+ }
+ else
+ {
+ /* we were remotely started */
+ }
+
+ /* media task is autostarted upon a2dp audiopath connection */
+ }
+ }
+ else
+ {
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_FAILURE);
+ }
+}
+
+
+/*****************************************************************************
+**
+** Function btif_a2dp_on_stopped
+**
+** Description
+**
+** Returns
+**
+*******************************************************************************/
+
+void btif_a2dp_on_stopped(tBTA_AV_SUSPEND *p_av)
{
- APPL_TRACE_EVENT1("%s", __FUNCTION__);
- btif_av_encoder_update();
+ APPL_TRACE_EVENT0("## ON A2DP STOPPED ##");
+
+ /* allow using this api for other than suspend */
+ if (p_av != NULL)
+ {
+ if (p_av->status != BTA_AV_SUCCESS)
+ {
+ APPL_TRACE_EVENT1("AV STOP FAILED (%d)", p_av->status);
+
+ if (p_av->initiator)
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_FAILURE);
+ return;
+ }
+ }
+
+ /* ensure tx frames are immediately suspended */
+ btif_media_cb.tx_flush = 1;
- /* Start the media task to encode SBC */
- btif_media_task_start_aa_req();
+ /* request to stop media task */
+ btif_media_task_aa_tx_flush_req();
+ btif_media_task_stop_aa_req();
+
+ /* once stream is fully stopped we will ack back */
+}
+
+
+/*****************************************************************************
+**
+** Function btif_a2dp_on_suspended
+**
+** Description
+**
+** Returns
+**
+*******************************************************************************/
+
+void btif_a2dp_on_suspended(tBTA_AV_SUSPEND *p_av)
+{
+ APPL_TRACE_EVENT0("## ON A2DP SUSPENDED ##");
+
+ /* check for status failures */
+ if (p_av->status != BTA_AV_SUCCESS)
+ {
+ if (p_av->initiator == TRUE)
+ a2dp_cmd_acknowledge(A2DP_CTRL_ACK_FAILURE);
+ }
+
+ /* once stream is fully stopped we will ack back */
+
+ /* ensure tx frames are immediately flushed */
+ btif_media_cb.tx_flush = 1;
+
+ /* stop timer tick */
+ btif_media_task_stop_aa_req();
+}
+
+/* when true media task discards any tx frames */
+void btif_a2dp_set_tx_flush(BOOLEAN enable)
+{
+ APPL_TRACE_EVENT1("## DROP TX %d ##", enable);
+ btif_media_cb.tx_flush = enable;
}
/*******************************************************************************
@@ -502,7 +901,6 @@ void btif_a2dp_upon_started(void)
**
*******************************************************************************/
-
static void btif_media_task_aa_handle_timer(void)
{
#if (defined(DEBUG_MEDIA_AV_FLOW) && (DEBUG_MEDIA_AV_FLOW == TRUE))
@@ -510,7 +908,7 @@ static void btif_media_task_aa_handle_timer(void)
APPL_TRACE_DEBUG1("btif_media_task_aa_handle_timer: %d", Debug++);
#endif
- //log_tstamps_us("timer");
+ log_tstamps_us("media task tx timer");
#if (BTA_AV_INCLUDED == TRUE)
btif_media_send_aa_frame();
@@ -552,14 +950,16 @@ static void btif_media_task_aa_handle_uipc_rx_rdy(void)
** Returns void
**
*******************************************************************************/
+
void btif_media_task_init(void)
{
memset(&(btif_media_cb), 0, sizeof(btif_media_cb));
+ UIPC_Init(NULL);
+
#if (BTA_AV_INCLUDED == TRUE)
- UIPC_Open(UIPC_CH_ID_AV_AUDIO , NULL);
+ UIPC_Open(UIPC_CH_ID_AV_CTRL , btif_a2dp_ctrl_cb);
#endif
-
}
/*******************************************************************************
**
@@ -580,7 +980,7 @@ int btif_media_task(void *p)
UINT16 event;
BT_HDR *p_msg;
- APPL_TRACE_EVENT0("MEDIA TASK STARTING");
+ APPL_TRACE_DEBUG0("================ MEDIA TASK STARTING ================");
btif_media_task_init();
@@ -588,6 +988,8 @@ int btif_media_task(void *p)
{
event = GKI_wait(0xffff, 0);
+ APPL_TRACE_DEBUG1("================= MEDIA TASK EVENT %d ===============", event);
+
if (event & BTIF_MEDIA_TASK_CMD)
{
/* Process all messages in the queue */
@@ -613,13 +1015,17 @@ int btif_media_task(void *p)
}
+ APPL_TRACE_DEBUG1("=============== MEDIA TASK EVENT %d DONE ============", event);
+
/* When we get this event we exit the task - should only happen on GKI_shutdown */
if (event & BTIF_MEDIA_TASK_KILL)
+ {
+ UIPC_Close(UIPC_CH_ID_ALL);
break;
-
+ }
}
- APPL_TRACE_EVENT0("MEDIA TASK EXITING");
+ APPL_TRACE_DEBUG0("MEDIA TASK EXITING");
return 0;
}
@@ -677,7 +1083,7 @@ static void btif_media_flush_q(BUFFER_Q *p_q)
*******************************************************************************/
static void btif_media_task_handle_cmd(BT_HDR *p_msg)
{
- //APPL_TRACE_EVENT2("EVENT (%d) %s", p_msg->event, dump_media_event(p_msg->event));
+ APPL_TRACE_DEBUG2("btif_media_task_handle_cmd : %d %s", p_msg->event, dump_media_event(p_msg->event));
switch (p_msg->event)
{
@@ -708,7 +1114,7 @@ static void btif_media_task_handle_cmd(BT_HDR *p_msg)
APPL_TRACE_ERROR1("ERROR in btif_media_task_handle_cmd unknown event %d", p_msg->event);
}
GKI_freebuf(p_msg);
- //APPL_TRACE_EVENT1("MEDIA TASK RX EVENT PROCESSED %s", dump_media_event(p_msg->event));
+ APPL_TRACE_EVENT1("btif_media_task_handle_cmd : %s DONE", dump_media_event(p_msg->event));
}
/*******************************************************************************
@@ -722,7 +1128,7 @@ static void btif_media_task_handle_cmd(BT_HDR *p_msg)
*******************************************************************************/
static void btif_media_task_handle_media(BT_HDR *p_msg)
{
- APPL_TRACE_ERROR0("ERROR btif_media_task_handle_media: TODO");
+ APPL_TRACE_ERROR0("ERROR btif_media_task_handle_media: not in use");
GKI_freebuf(p_msg);
}
@@ -1166,7 +1572,7 @@ static void btif_media_task_audio_feeding_init(BT_HDR *p_msg)
btif_media_cb.TxTranscoding = BTIF_MEDIA_TRSCD_PCM_2_SBC;
btif_media_task_pcm2sbc_init(p_feeding);
break;
-
+
default :
APPL_TRACE_ERROR1("unknown feeding format %d", p_feeding->feeding.format);
break;
@@ -1233,7 +1639,7 @@ static void btif_media_task_aa_start_tx(void)
/* Use a timer to poll the UIPC, get rid of the UIPC call back */
- UIPC_Ioctl(UIPC_CH_ID_AV_AUDIO, UIPC_REG_CBACK, NULL);
+ // UIPC_Ioctl(UIPC_CH_ID_AV_AUDIO, UIPC_REG_CBACK, NULL);
btif_media_cb.is_tx_timer = TRUE;
@@ -1261,12 +1667,16 @@ static void btif_media_task_aa_start_tx(void)
static void btif_media_task_aa_stop_tx(void)
{
APPL_TRACE_DEBUG1("btif_media_task_aa_stop_tx is timer: %d", btif_media_cb.is_tx_timer);
+
/* Stop the timer first */
GKI_stop_timer(BTIF_MEDIA_AA_TASK_TIMER_ID);
btif_media_cb.is_tx_timer = FALSE;
UIPC_Close(UIPC_CH_ID_AV_AUDIO);
+ /* audio engine stopped, reset tx suspended flag */
+ btif_media_cb.tx_flush = 0;
+
/* Reset the media feeding state */
btif_media_task_feeding_state_reset();
}
@@ -1449,24 +1859,14 @@ BOOLEAN btif_media_aa_read_feeding(tUIPC_CH_ID channel_id)
//tput_mon(TRUE, nb_byte_read, FALSE);
- if (nb_byte_read == 0)
- {
- APPL_TRACE_EVENT0("REMOTE SOURCE DETACHED");
-
- /* temp workaround before full socket interface implented
- stop and restart media task as remote source disconnected
- read socket will again wait for an incoming a2dp source connection */
-
- btif_media_task_stop_aa_req();
- btif_a2dp_upon_started();
- return FALSE;
- }
-
if (nb_byte_read < read_size)
{
- APPL_TRACE_WARNING2("btif_media_aa_read_feeding UIPC empty UIPC_Read returns:%d asked:%d",
+ APPL_TRACE_WARNING2("### UNDERRUN :: ONLY READ %d BYTES OUT OF %d ###",
nb_byte_read, read_size);
+ if (nb_byte_read == 0)
+ return FALSE;
+
if(btif_media_cb.feeding_mode == BTIF_AV_FEEDING_ASYNCHRONOUS)
{
/* Fill the unfilled part of the read buffer with silence (0) */
@@ -1487,6 +1887,7 @@ BOOLEAN btif_media_aa_read_feeding(tUIPC_CH_ID channel_id)
nb_byte_read,
sizeof(up_sampled_buffer) - btif_media_cb.media_feeding_state.pcm.aa_feed_residue,
&src_size_used);
+
#if (defined(DEBUG_MEDIA_AV_FLOW) && (DEBUG_MEDIA_AV_FLOW == TRUE))
APPL_TRACE_DEBUG3("btif_media_aa_read_feeding read_size:%d src_size_used:%d dst_size_used:%d",
read_size, src_size_used, dst_size_used);
@@ -1560,6 +1961,7 @@ static void btif_media_aa_prep_sbc_2_send(UINT8 nb_frame)
/* coverity[SIGN_EXTENSION] False-positive: Parameter are always in range avoiding sign extension*/
memset(btif_media_cb.encoder.as16PcmBuffer, 0, blocm_x_subband
* btif_media_cb.encoder.s16NumOfChannels);
+
/* Read PCM data and upsample them if needed */
if (btif_media_aa_read_feeding(UIPC_CH_ID_AV_AUDIO))
{
@@ -1576,6 +1978,10 @@ static void btif_media_aa_prep_sbc_2_send(UINT8 nb_frame)
{
/* no more pcm to read */
nb_frame = 0;
+
+ /* break read loop if timer was stopped (media task stopped) */
+ if ( btif_media_cb.is_tx_timer == FALSE )
+ return;
}
} while (((p_buf->len + btif_media_cb.encoder.u16PacketLength) < btif_media_cb.TxAaMtuSize)
@@ -1587,6 +1993,19 @@ static void btif_media_aa_prep_sbc_2_send(UINT8 nb_frame)
/* store the time stamp in the buffer to send */
*((UINT32 *) (p_buf + 1)) = btif_media_cb.timestamp;
+ APPL_TRACE_EVENT1("TX QUEUE NOW %d", btif_media_cb.TxAaQ.count);
+
+ if (btif_media_cb.tx_flush)
+ {
+ APPL_TRACE_DEBUG0("### tx suspended, discarded frame ###");
+
+ if (btif_media_cb.TxAaQ.count > 0)
+ btif_media_flush_q(&(btif_media_cb.TxAaQ));
+
+ GKI_freebuf(p_buf);
+ return;
+ }
+
/* Enqueue the encoded SBC frame in AA Tx Queue */
GKI_enqueue(&(btif_media_cb.TxAaQ), p_buf);
}
@@ -1602,10 +2021,13 @@ static void btif_media_aa_prep_sbc_2_send(UINT8 nb_frame)
** Returns void
**
*******************************************************************************/
+
static void btif_media_aa_prep_2_send(UINT8 nb_frame)
{
+ APPL_TRACE_DEBUG1("btif_media_aa_prep_2_send : %d frames in queue", btif_media_cb.TxAaQ.count);
+
/* Remove all the buffers not sent until there are only 4 in the queue */
- while (btif_media_cb.TxAaQ.count > 4)
+ while (btif_media_cb.TxAaQ.count >= MAX_OUTPUT_BUFFER_QUEUE_SZ)
{
APPL_TRACE_WARNING1("btif_media_aa_prep_2_send congestion buf count %d",btif_media_cb.TxAaQ.count);
GKI_freebuf(GKI_dequeue(&(btif_media_cb.TxAaQ)));
diff --git a/btif/src/btif_rc.c b/btif/src/btif_rc.c
index 04d5681..7aab520 100644
--- a/btif/src/btif_rc.c
+++ b/btif/src/btif_rc.c
@@ -51,7 +51,7 @@
* Filename: btif_rc.c
*
* Description: Bluetooth AVRC implementation
- *
+ *
*****************************************************************************/
#include <hardware/bluetooth.h>
#include <fcntl.h>
@@ -265,12 +265,12 @@ const char *dump_rc_event_name(tBTA_AV_EVT event)
}
/***************************************************************************
- * Function handle_rc_connect
- *
- * - Argument: tBTA_AV_RC_OPEN RC open data structure
- *
- * - Description: RC connection event handler
- *
+ * Function handle_rc_connect
+ *
+ * - Argument: tBTA_AV_RC_OPEN RC open data structure
+ *
+ * - Description: RC connection event handler
+ *
***************************************************************************/
void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open)
{
@@ -286,12 +286,12 @@ void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open)
}
/***************************************************************************
- * Function handle_rc_disconnect
- *
- * - Argument: tBTA_AV_RC_CLOSE RC close data structure
- *
+ * Function handle_rc_disconnect
+ *
+ * - Argument: tBTA_AV_RC_CLOSE RC close data structure
+ *
* - Description: RC disconnection event handler
- *
+ *
***************************************************************************/
void handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close)
{
@@ -306,13 +306,13 @@ void handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close)
}
/***************************************************************************
- * Function handle_rc_passthrough_cmd
- *
- * - Argument: tBTA_AV_RC rc_id remote control command ID
- * tBTA_AV_STATE key_state status of key press
- *
- * - Description: Remote control command handler
- *
+ * Function handle_rc_passthrough_cmd
+ *
+ * - Argument: tBTA_AV_RC rc_id remote control command ID
+ * tBTA_AV_STATE key_state status of key press
+ *
+ * - Description: Remote control command handler
+ *
***************************************************************************/
void handle_rc_passthrough_cmd ( tBTA_AV_REMOTE_CMD *p_remote_cmd)
{
@@ -346,7 +346,7 @@ void handle_rc_passthrough_cmd ( tBTA_AV_REMOTE_CMD *p_remote_cmd)
}
#ifdef BTIF_RC_USE_UINPUT
send_key(uinput_fd, key_map[i].mapped_id, pressed);
-#endif
+#endif
if ((key_map[i].release_quirk == 1) && (pressed == 1))
{
GKI_delay(30); // 30ms
@@ -354,7 +354,7 @@ void handle_rc_passthrough_cmd ( tBTA_AV_REMOTE_CMD *p_remote_cmd)
__FUNCTION__, key_map[i].name);
#ifdef BTIF_RC_USE_UINPUT
send_key(uinput_fd, key_map[i].mapped_id, 0);
-#endif
+#endif
}
break;
}
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;
}
diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c
index e3ca7ef..9ed6e9e 100644
--- a/btif/src/btif_storage.c
+++ b/btif/src/btif_storage.c
@@ -3,44 +3,44 @@
* Copyright (C) 2009-2012 Broadcom Corporation
*
* This program is the proprietary software of Broadcom Corporation and/or its
- * licensors, and may only be used, duplicated, modified or distributed
- * pursuant to the terms and conditions of a separate, written license
- * agreement executed between you and Broadcom (an "Authorized License").
- * Except as set forth in an Authorized License, Broadcom grants no license
- * (express or implied), right to use, or waiver of any kind with respect to
- * the Software, and Broadcom expressly reserves all rights in and to the
- * Software and all intellectual property rights therein.
- * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
- * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
- * ALL USE OF THE SOFTWARE.
+ * licensors, and may only be used, duplicated, modified or distributed
+ * pursuant to the terms and conditions of a separate, written license
+ * agreement executed between you and Broadcom (an "Authorized License").
+ * Except as set forth in an Authorized License, Broadcom grants no license
+ * (express or implied), right to use, or waiver of any kind with respect to
+ * the Software, and Broadcom expressly reserves all rights in and to the
+ * Software and all intellectual property rights therein.
+ * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
+ * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
+ * ALL USE OF THE SOFTWARE.
*
* Except as expressly set forth in the Authorized License,
*
- * 1. This program, including its structure, sequence and organization,
- * constitutes the valuable trade secrets of Broadcom, and you shall
- * use all reasonable efforts to protect the confidentiality thereof,
- * and to use this information only in connection with your use of
+ * 1. This program, including its structure, sequence and organization,
+ * constitutes the valuable trade secrets of Broadcom, and you shall
+ * use all reasonable efforts to protect the confidentiality thereof,
+ * and to use this information only in connection with your use of
* Broadcom integrated circuit products.
*
- * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
- * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
- * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
- * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
- * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
- * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
- * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
+ * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
+ * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
+ * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
+ * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
+ * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
+ * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
+ * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
* CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT
* OF USE OR PERFORMANCE OF THE SOFTWARE.
*
* 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR
- * ITS LICENSORS BE LIABLE FOR
- * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
- * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
- * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
- * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
- * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
- * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
- * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
+ * ITS LICENSORS BE LIABLE FOR
+ * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
+ * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
+ * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
+ * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
+ * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
+ * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
+ * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
* ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
*
************************************************************************************/
@@ -49,11 +49,11 @@
*
* Filename: btif_storage.c
*
- * Description: Stores the local BT adapter and remote device properties in
- * NVRAM storage, typically as text files in the
+ * Description: Stores the local BT adapter and remote device properties in
+ * NVRAM storage, typically as text files in the
* mobile's filesystem
- *
- *
+ *
+ *
* Data storage directory structure
*
* data
@@ -67,7 +67,7 @@
* |-- remote_names - Remote devices' names
* |-- remote_aliases - Remote devices' Friendly names
* `-- remote_services - Remote devices' services
- *
+ *
*
* adapter_info - Key/Value
* name <space> <Name of Local Bluetooth device>
@@ -94,7 +94,7 @@
*
* remote_services - Key/Value
* <remote_device bd_addr> <space> <List of UUIDs separated by semicolons>
- *
+ *
***********************************************************************************/
#include <stdlib.h>
#include <time.h>
@@ -103,7 +103,7 @@
#define LOG_TAG "BTIF_STORAGE"
-#include "btif_api.h"
+#include "btif_api.h"
#include "btif_util.h"
#include "unv.h"
@@ -199,15 +199,15 @@ static char* btif_in_make_filename(bt_bdaddr_t *bd_addr, char *fname)
if (fname == NULL)return NULL;
if (bd_addr)
{
- sprintf(path, "%s/%s/%s", BTIF_STORAGE_PATH_BLUEDROID,
+ sprintf(path, "%s/%s/%s", BTIF_STORAGE_PATH_BLUEDROID,
bd2str(bd_addr, &bdstr), fname);
}
else
{
/* local adapter */
- sprintf(path, "%s/LOCAL/%s", BTIF_STORAGE_PATH_BLUEDROID, fname);
+ sprintf(path, "%s/LOCAL/%s", BTIF_STORAGE_PATH_BLUEDROID, fname);
}
-
+
return (char*)path;
}
@@ -227,9 +227,9 @@ static const char *btif_in_get_adapter_key_from_type(bt_property_type_t type)
{
case BT_PROPERTY_BDNAME:
return BTIF_STORAGE_KEY_ADAPTER_NAME;
- case BT_PROPERTY_ADAPTER_SCAN_MODE:
+ case BT_PROPERTY_ADAPTER_SCAN_MODE:
return BTIF_STORAGE_KEY_ADAPTER_SCANMODE;
- case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
+ case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
return BTIF_STORAGE_KEY_ADAPTER_DISC_TIMEOUT;
default:
/* return valid string to avoid passing NULL to NV RAM driver */
@@ -275,7 +275,7 @@ static void btif_in_split_uuids_string_to_list(char *str, bt_uuid_t *p_uuid,
** NVRAM into a property->val. Also sets the property->len.
** Assumption is that property->val has enough memory to
** store the string fetched from NVRAM
-**
+**
** Returns BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise
**
*******************************************************************************/
@@ -284,7 +284,7 @@ static bt_status_t btif_in_str_to_property(char *value, bt_property_t *property)
bt_status_t status = BT_STATUS_SUCCESS;
property->len = 0;
- /* if Value is NULL, then just set the property->len to 0 and return.
+ /* if Value is NULL, then just set the property->len to 0 and return.
This is possible if the entry does not exist */
if (value == NULL) {
status = BT_STATUS_FAIL;
@@ -301,7 +301,7 @@ static bt_status_t btif_in_str_to_property(char *value, bt_property_t *property)
strcpy((char*)property->val, value);
}
} break;
- case BT_PROPERTY_ADAPTER_SCAN_MODE:
+ case BT_PROPERTY_ADAPTER_SCAN_MODE:
case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
{
*((uint32_t *)property->val) = 0;
@@ -416,13 +416,13 @@ static char* btif_in_get_remote_device_path_from_property(bt_property_type_t typ
case BT_PROPERTY_BDADDR:
case BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP:
return BTIF_STORAGE_PATH_REMOTE_DEVICES;
- case BT_PROPERTY_BDNAME:
+ case BT_PROPERTY_BDNAME:
return BTIF_STORAGE_PATH_REMOTE_NAMES;
case BT_PROPERTY_CLASS_OF_DEVICE:
return BTIF_STORAGE_PATH_REMOTE_DEVCLASSES;
case BT_PROPERTY_TYPE_OF_DEVICE:
return BTIF_STORAGE_PATH_REMOTE_DEVTYPES;
- case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
+ case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
return BTIF_STORAGE_PATH_REMOTE_ALIASES;
case BT_PROPERTY_UUIDS:
return BTIF_STORAGE_PATH_REMOTE_SERVICES;
@@ -455,17 +455,17 @@ int btif_in_load_device_iter_cb(char *key, char *value, void *userdata)
uint32_t i;
memset(temp, 0, sizeof(temp));
-
+
BTIF_TRACE_DEBUG3("%s %s %s", __FUNCTION__, key, value);
-
+
/* convert 32 char linkkey (fixed size) */
- for (i = 0; i < LINK_KEY_LEN; i++)
+ for (i = 0; i < LINK_KEY_LEN; i++)
{
memcpy(temp, value + (i * 2), 2);
link_key[i] = (uint8_t) strtol((const char *)temp, NULL, 16);
offset+=2;
}
-
+
/* skip space */
offset++;
@@ -476,7 +476,7 @@ int btif_in_load_device_iter_cb(char *key, char *value, void *userdata)
/* value + space */
offset+=2;
-
+
/* convert decimal pinlen (max 2 ascii chars) */
memset(temp, 0, sizeof(temp));
memcpy(temp, value + offset, 2);
@@ -484,10 +484,10 @@ int btif_in_load_device_iter_cb(char *key, char *value, void *userdata)
/* convert bd address (keystring) */
str2bd(key, &bd_addr);
-
+
/* add extracted information to BTA security manager */
BTA_DmAddDevice(bd_addr.address, dev_class, link_key, 0, 0, key_type, 0);
-
+
/* Fill in the bonded devices */
memcpy(&p_bonded_devices->devices[p_bonded_devices->num_devices++], &bd_addr, sizeof(bt_bdaddr_t));
@@ -512,13 +512,13 @@ static bt_status_t btif_in_fetch_bonded_devices(btif_bonded_devices_t *p_bonded_
memset(p_bonded_devices, 0, sizeof(btif_bonded_devices_t));
fname = btif_in_make_filename(NULL, BTIF_STORAGE_PATH_REMOTE_LINKKEYS);
-
- if (fname == NULL)
+
+ if (fname == NULL)
return BT_STATUS_FAIL;
ret = unv_read_key_iter(fname, btif_in_load_device_iter_cb, p_bonded_devices);
- if (ret < 0)
+ if (ret < 0)
return BT_STATUS_FAIL;
return BT_STATUS_SUCCESS;
@@ -580,7 +580,7 @@ bt_status_t btif_storage_get_adapter_property(bt_property_t *property)
BTIF_TRACE_DEBUG2("%s: Number of bonded devices: %d", __FUNCTION__, bonded_devices.num_devices);
- if (bonded_devices.num_devices > 0)
+ if (bonded_devices.num_devices > 0)
{
property->len = bonded_devices.num_devices * sizeof(bt_bdaddr_t);
memcpy(property->val, bonded_devices.devices, property->len);
@@ -628,7 +628,7 @@ bt_status_t btif_storage_get_adapter_property(bt_property_t *property)
}
/* fall through for other properties */
-
+
/* create filepath */
fname = btif_in_make_filename(NULL, BTIF_STORAGE_PATH_ADAPTER_INFO);
@@ -644,8 +644,8 @@ bt_status_t btif_storage_get_adapter_property(bt_property_t *property)
return BT_STATUS_FAIL;
}
- value = unv_read_key( fname,
- btif_in_get_adapter_key_from_type(property->type),
+ value = unv_read_key( fname,
+ btif_in_get_adapter_key_from_type(property->type),
linebuf, UNV_MAXLINE_LENGTH);
if (value == NULL)
@@ -678,7 +678,7 @@ bt_status_t btif_storage_set_adapter_property(bt_property_t *property)
char *fname;
char value[1200];
int ret;
-
+
fname = btif_in_make_filename(NULL, BTIF_STORAGE_PATH_ADAPTER_INFO);
if (fname == NULL)
{
@@ -695,11 +695,11 @@ bt_status_t btif_storage_set_adapter_property(bt_property_t *property)
return BT_STATUS_FAIL;
}
ret = unv_write_key(fname, btif_in_get_adapter_key_from_type(property->type), value);
- if (ret < 0)
+ if (ret < 0)
{
return BT_STATUS_FAIL;
}
-
+
return BT_STATUS_SUCCESS;
}
@@ -716,7 +716,7 @@ bt_status_t btif_storage_set_adapter_property(bt_property_t *property)
** BT_STATUS_FAIL otherwise
**
*******************************************************************************/
-bt_status_t btif_storage_get_remote_device_property(bt_bdaddr_t *remote_bd_addr,
+bt_status_t btif_storage_get_remote_device_property(bt_bdaddr_t *remote_bd_addr,
bt_property_t *property)
{
char linebuf[BTIF_STORAGE_MAX_LINE_SZ];
@@ -737,7 +737,7 @@ bt_status_t btif_storage_get_remote_device_property(bt_bdaddr_t *remote_bd_addr,
{
return BT_STATUS_FAIL;
}
-
+
value = unv_read_key(fname, bd2str(remote_bd_addr, &bdstr), linebuf, BTIF_STORAGE_MAX_LINE_SZ);
return btif_in_str_to_property(value, property);
@@ -754,7 +754,7 @@ bt_status_t btif_storage_get_remote_device_property(bt_bdaddr_t *remote_bd_addr,
** BT_STATUS_FAIL otherwise
**
*******************************************************************************/
-bt_status_t btif_storage_set_remote_device_property(bt_bdaddr_t *remote_bd_addr,
+bt_status_t btif_storage_set_remote_device_property(bt_bdaddr_t *remote_bd_addr,
bt_property_t *property)
{
char value[1200];
@@ -779,13 +779,13 @@ bt_status_t btif_storage_set_remote_device_property(bt_bdaddr_t *remote_bd_addr,
{
return BT_STATUS_FAIL;
}
-
+
ret = unv_write_key(fname, bd2str(remote_bd_addr, &bdstr), value);
- if (ret < 0)
+ if (ret < 0)
{
return BT_STATUS_FAIL;
}
-
+
return BT_STATUS_SUCCESS;
}
@@ -811,19 +811,19 @@ bt_status_t btif_storage_add_remote_device(bt_bdaddr_t *remote_bdaddr,
for (i=0; i < num_properties; i++)
{
/* Ignore the RSSI as this is not stored in DB */
- if (properties[i].type == BT_PROPERTY_REMOTE_RSSI)
+ if (properties[i].type == BT_PROPERTY_REMOTE_RSSI)
continue;
/* BD_ADDR for remote device needs special handling as we also store timestamp */
- if (properties[i].type == BT_PROPERTY_BDADDR)
+ if (properties[i].type == BT_PROPERTY_BDADDR)
{
bt_property_t addr_prop;
- memcpy(&addr_prop, &properties[i], sizeof(bt_property_t));
+ memcpy(&addr_prop, &properties[i], sizeof(bt_property_t));
addr_prop.type = BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP;
btif_storage_set_remote_device_property(remote_bdaddr,
&addr_prop);
- }
- else
+ }
+ else
{
btif_storage_set_remote_device_property(remote_bdaddr,
&properties[i]);
@@ -877,7 +877,7 @@ bt_status_t btif_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
return BT_STATUS_FAIL;
memset(value, 0, sizeof(value));
-
+
for (i = 0; i < LINK_KEY_LEN; i++)
sprintf(value + (i * 2), "%2.2X", link_key[i]);
@@ -891,7 +891,7 @@ bt_status_t btif_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
}
return BT_STATUS_SUCCESS;
-}
+}
/*******************************************************************************
**
@@ -908,7 +908,7 @@ bt_status_t btif_storage_remove_bonded_device(bt_bdaddr_t *remote_bd_addr)
char *fname;
int ret;
bdstr_t bdstr;
-
+
fname = btif_in_make_filename(NULL,
BTIF_STORAGE_PATH_REMOTE_LINKKEYS);
if (fname == NULL)
diff --git a/btif/src/btif_util.c b/btif/src/btif_util.c
index 453d470..a1a5d97 100644
--- a/btif/src/btif_util.c
+++ b/btif/src/btif_util.c
@@ -3,44 +3,44 @@
* Copyright (C) 2009-2012 Broadcom Corporation
*
* This program is the proprietary software of Broadcom Corporation and/or its
- * licensors, and may only be used, duplicated, modified or distributed
- * pursuant to the terms and conditions of a separate, written license
- * agreement executed between you and Broadcom (an "Authorized License").
- * Except as set forth in an Authorized License, Broadcom grants no license
- * (express or implied), right to use, or waiver of any kind with respect to
- * the Software, and Broadcom expressly reserves all rights in and to the
- * Software and all intellectual property rights therein.
- * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
- * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
- * ALL USE OF THE SOFTWARE.
+ * licensors, and may only be used, duplicated, modified or distributed
+ * pursuant to the terms and conditions of a separate, written license
+ * agreement executed between you and Broadcom (an "Authorized License").
+ * Except as set forth in an Authorized License, Broadcom grants no license
+ * (express or implied), right to use, or waiver of any kind with respect to
+ * the Software, and Broadcom expressly reserves all rights in and to the
+ * Software and all intellectual property rights therein.
+ * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
+ * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
+ * ALL USE OF THE SOFTWARE.
*
* Except as expressly set forth in the Authorized License,
*
- * 1. This program, including its structure, sequence and organization,
- * constitutes the valuable trade secrets of Broadcom, and you shall
- * use all reasonable efforts to protect the confidentiality thereof,
- * and to use this information only in connection with your use of
+ * 1. This program, including its structure, sequence and organization,
+ * constitutes the valuable trade secrets of Broadcom, and you shall
+ * use all reasonable efforts to protect the confidentiality thereof,
+ * and to use this information only in connection with your use of
* Broadcom integrated circuit products.
*
- * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
- * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
- * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
- * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
- * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
- * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
- * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
+ * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
+ * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
+ * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
+ * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
+ * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
+ * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
+ * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
* CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT
* OF USE OR PERFORMANCE OF THE SOFTWARE.
*
* 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR
- * ITS LICENSORS BE LIABLE FOR
- * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
- * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
- * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
- * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
- * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
- * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
- * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
+ * ITS LICENSORS BE LIABLE FOR
+ * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
+ * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
+ * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
+ * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
+ * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
+ * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
+ * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
* ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
*
************************************************************************************/
@@ -50,12 +50,13 @@
* Filename: btif_util.c
*
* Description: Miscellaneous helper functions
- *
- *
+ *
+ *
***********************************************************************************/
#include <hardware/bluetooth.h>
#include <hardware/bt_hf.h>
+#include <hardware/bt_av.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
@@ -200,7 +201,7 @@ const char* dump_dm_search_event(UINT16 event)
CASE_RETURN_STR(BTA_DM_DISC_CMPL_EVT)
CASE_RETURN_STR(BTA_DM_DI_DISC_CMPL_EVT)
CASE_RETURN_STR(BTA_DM_SEARCH_CANCEL_CMPL_EVT)
-
+
default:
return "UNKNOWN MSG ID";
}
@@ -221,11 +222,11 @@ const char* dump_property_type(bt_property_type_t type)
CASE_RETURN_STR(BT_PROPERTY_ADAPTER_BONDED_DEVICES)
CASE_RETURN_STR(BT_PROPERTY_ADAPTER_SCAN_MODE)
CASE_RETURN_STR(BT_PROPERTY_REMOTE_FRIENDLY_NAME)
-
+
default:
return "UNKNOWN PROPERTY ID";
- }
-}
+ }
+}
const char* dump_hf_event(UINT16 event)
@@ -279,7 +280,7 @@ const char* dump_hf_conn_state(UINT16 event)
CASE_RETURN_STR(BTHF_CONNECTION_STATE_SLC_CONNECTED)
CASE_RETURN_STR(BTHF_CONNECTION_STATE_DISCONNECTING)
default:
- return "UNKNOWN MSG ID";
+ return "UNKNOWN MSG ID";
}
}
@@ -305,11 +306,11 @@ const char* dump_thread_evt(bt_cb_thread_evt evt)
{
CASE_RETURN_STR(ASSOCIATE_JVM)
CASE_RETURN_STR(DISASSOCIATE_JVM)
-
+
default:
return "unknown thread evt";
- }
-}
+ }
+}
const char* dump_hf_audio_state(UINT16 event)
@@ -326,6 +327,30 @@ const char* dump_hf_audio_state(UINT16 event)
}
}
+const char* dump_av_conn_state(UINT16 event)
+{
+ switch(event)
+ {
+ CASE_RETURN_STR(BTAV_CONNECTION_STATE_DISCONNECTED)
+ CASE_RETURN_STR(BTAV_CONNECTION_STATE_CONNECTING)
+ CASE_RETURN_STR(BTAV_CONNECTION_STATE_CONNECTED)
+ CASE_RETURN_STR(BTAV_CONNECTION_STATE_DISCONNECTING)
+ default:
+ return "UNKNOWN MSG ID";
+ }
+}
+
+const char* dump_av_audio_state(UINT16 event)
+{
+ switch(event)
+ {
+ CASE_RETURN_STR(BTAV_AUDIO_STATE_REMOTE_SUSPEND)
+ CASE_RETURN_STR(BTAV_AUDIO_STATE_STOPPED)
+ CASE_RETURN_STR(BTAV_AUDIO_STATE_STARTED)
+ default:
+ return "UNKNOWN MSG ID";
+ }
+}
const char* dump_adapter_scan_mode(bt_scan_mode_t mode)
{