summaryrefslogtreecommitdiffstats
path: root/btif
diff options
context:
space:
mode:
authorMattias Agren <magren@broadcom.com>2012-03-26 08:25:00 -0700
committerMatthew Xie <mattx@google.com>2012-07-14 11:19:13 -0700
commit254588bfe6c3e70625b0f725b908598f30f476c8 (patch)
tree259c87422e70b74abeab96b3e3155c88791e5b6d /btif
parent3e6f399bdbaca7f8ab0a8b1c6eab7cc1088ab74a (diff)
downloadexternal_bluetooth_bluedroid-254588bfe6c3e70625b0f725b908598f30f476c8.zip
external_bluetooth_bluedroid-254588bfe6c3e70625b0f725b908598f30f476c8.tar.gz
external_bluetooth_bluedroid-254588bfe6c3e70625b0f725b908598f30f476c8.tar.bz2
Added new control and data path interface between audioflinger a2dp HAL
and stack. Added support for suspend and a dedicated HAL callback notifying framework on audiopath events. Cleanup. Change-Id: I3b738611bc8e1d84794f7207413fd9e7dd1fc668
Diffstat (limited to 'btif')
-rw-r--r--btif/co/bta_ag_co.c68
-rw-r--r--btif/co/bta_av_co.c30
-rw-r--r--btif/co/bta_dm_co.c108
-rw-r--r--btif/co/bta_fs_co.c190
-rw-r--r--btif/co/bta_sys_co.c68
-rw-r--r--btif/include/btif_api.h116
-rw-r--r--btif/include/btif_av.h208
-rw-r--r--btif/include/btif_av_co.h189
-rw-r--r--[-rwxr-xr-x]btif/include/btif_common.h75
-rw-r--r--btif/include/btif_dm.h62
-rw-r--r--btif/include/btif_media.h46
-rw-r--r--btif/include/btif_sm.h2
-rw-r--r--btif/include/btif_storage.h62
-rw-r--r--btif/include/btif_util.h63
-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
24 files changed, 2086 insertions, 1208 deletions
diff --git a/btif/co/bta_ag_co.c b/btif/co/bta_ag_co.c
index ec1d5bb..92c96c3 100644
--- a/btif/co/bta_ag_co.c
+++ b/btif/co/bta_ag_co.c
@@ -3,44 +3,44 @@
* Copyright (C) 2009-2011 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.
*
************************************************************************************/
@@ -72,8 +72,8 @@
** Description This callout function is executed by AG when it is
** started by calling BTA_AgEnable(). This function can be
** used by the phone to initialize audio paths or for other
-** initialization purposes.
-**
+** initialization purposes.
+**
**
** Returns Void.
**
@@ -90,7 +90,7 @@ void bta_ag_co_init(void)
**
** Description This function is called by the AG before the audio connection
** is brought up, after it comes up, and after it goes down.
-**
+**
** Parameters handle - handle of the AG instance
** state - Audio state
** BTA_AG_CO_AUD_STATE_OFF - Audio has been turned off
@@ -115,7 +115,7 @@ void bta_ag_co_audio_state(UINT16 handle, UINT8 app_id, UINT8 state)
** is opened. The phone can use this function to set
** up data paths or perform any required initialization or
** set up particular to the connected service.
-**
+**
**
** Returns void
**
@@ -131,7 +131,7 @@ void bta_ag_co_data_open(UINT16 handle, tBTA_SERVICE_ID service)
**
** Description This function is called by AG when a service level
** connection is closed
-**
+**
**
** Returns void
**
diff --git a/btif/co/bta_av_co.c b/btif/co/bta_av_co.c
index 1dbd940..bddde54 100644
--- a/btif/co/bta_av_co.c
+++ b/btif/co/bta_av_co.c
@@ -21,7 +21,7 @@
#include "btif_media.h"
#include "sbc_encoder.h"
-#include "btif_av.h"
+#include "btif_av_co.h"
/*****************************************************************************
@@ -216,7 +216,7 @@ static tBTA_AV_CO_PEER *bta_av_co_get_peer(tBTA_AV_HNDL hndl)
FUNC_TRACE();
index = BTA_AV_CO_AUDIO_HNDL_TO_INDX(hndl);
- APPL_TRACE_ERROR2("%s index:%d", __FUNCTION__, index);
+
/* Sanity check */
if (index >= BTA_AV_CO_NUM_ELEMENTS(bta_av_co_cb.peers))
{
@@ -504,7 +504,7 @@ BTA_API void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_ty
APPL_TRACE_DEBUG6("bta_av_co_audio_setconfig p_codec_info[%x:%x:%x:%x:%x:%x]",
p_codec_info[1], p_codec_info[2], p_codec_info[3],
p_codec_info[4], p_codec_info[5], p_codec_info[6]);
- APPL_TRACE_DEBUG4("num_protect:0x%02x protect_info:0x%02x%02x%02x",
+ APPL_TRACE_DEBUG4("num_protect:0x%02x protect_info:0x%02x%02x%02x",
num_protect, p_protect_info[0], p_protect_info[1], p_protect_info[2]);
/* Retrieve the peer info */
@@ -813,11 +813,15 @@ static BOOLEAN bta_av_co_audio_codec_build_config(const UINT8 *p_codec_caps, UIN
{
FUNC_TRACE();
- /* By default, just copy the current codec configuration */
- memcpy(p_codec_cfg, bta_av_co_cb.codec_cfg.info, AVDT_CODEC_SIZE);
+ memset(p_codec_cfg, 0, AVDT_CODEC_SIZE);
+
switch (bta_av_co_cb.codec_cfg.id)
{
case BTIF_AV_CODEC_SBC:
+ /* only copy the relevant portions for this codec to avoid issues when
+ comparing codec configs covering larger codec sets than SBC (7 bytes) */
+ memcpy(p_codec_cfg, bta_av_co_cb.codec_cfg.info, BTA_AV_CO_SBC_MAX_BITPOOL_OFF+1);
+
/* Update the bit pool boundaries with the codec capabilities */
p_codec_cfg[BTA_AV_CO_SBC_MIN_BITPOOL_OFF] = p_codec_caps[BTA_AV_CO_SBC_MIN_BITPOOL_OFF];
p_codec_cfg[BTA_AV_CO_SBC_MAX_BITPOOL_OFF] = p_codec_caps[BTA_AV_CO_SBC_MAX_BITPOOL_OFF];
@@ -850,10 +854,10 @@ static BOOLEAN bta_av_co_audio_codec_cfg_matches_caps(UINT8 codec_id, const UINT
if (!((p_codec_caps[BTA_AV_CO_SBC_FREQ_CHAN_OFF] & p_codec_cfg[BTA_AV_CO_SBC_FREQ_CHAN_OFF]) &&
(p_codec_caps[BTA_AV_CO_SBC_BLOCK_BAND_OFF] & p_codec_cfg[BTA_AV_CO_SBC_BLOCK_BAND_OFF])))
{
- APPL_TRACE_EVENT4("FALSE %x %x %x %x",
- p_codec_caps[BTA_AV_CO_SBC_FREQ_CHAN_OFF],
- p_codec_cfg[BTA_AV_CO_SBC_FREQ_CHAN_OFF],
- p_codec_caps[BTA_AV_CO_SBC_BLOCK_BAND_OFF],
+ APPL_TRACE_EVENT4("FALSE %x %x %x %x",
+ p_codec_caps[BTA_AV_CO_SBC_FREQ_CHAN_OFF],
+ p_codec_cfg[BTA_AV_CO_SBC_FREQ_CHAN_OFF],
+ p_codec_caps[BTA_AV_CO_SBC_BLOCK_BAND_OFF],
p_codec_cfg[BTA_AV_CO_SBC_BLOCK_BAND_OFF]);
return FALSE;
}
@@ -927,7 +931,7 @@ static BOOLEAN bta_av_co_cp_is_scmst(const UINT8 *p_protectinfo)
return TRUE;
}
}
-
+
return FALSE;
}
@@ -1008,6 +1012,7 @@ static BOOLEAN bta_av_co_audio_peer_supports_codec(tBTA_AV_CO_PEER *p_peer, UINT
/* Configure the codec type to look for */
codec_type = bta_av_co_cb.codec_cfg.id;
+
for (index = 0; index < p_peer->num_sup_snks; index++)
{
if (p_peer->snks[index].codec_type == codec_type)
@@ -1173,6 +1178,7 @@ void bta_av_co_audio_codec_reset(void)
/* Reset the current configuration to SBC */
bta_av_co_cb.codec_cfg.id = BTIF_AV_CODEC_SBC;
+
if (A2D_BldSbcInfo(A2D_MEDIA_TYPE_AUDIO, (tA2D_SBC_CIE *)&btif_av_sbc_default_config, bta_av_co_cb.codec_cfg.info) != A2D_SUCCESS)
{
APPL_TRACE_ERROR0("bta_av_co_audio_codec_reset A2D_BldSbcInfo failed");
@@ -1311,10 +1317,10 @@ BOOLEAN bta_av_co_audio_get_sbc_config(tA2D_SBC_CIE *p_sbc_config, UINT16 *p_min
{
/* Update the bitpool boundaries of the current config */
p_sbc_config->min_bitpool =
- BTA_AV_CO_MAX(p_sink->codec_caps[BTA_AV_CO_SBC_MIN_BITPOOL_OFF],
+ BTA_AV_CO_MAX(p_sink->codec_caps[BTA_AV_CO_SBC_MIN_BITPOOL_OFF],
p_sbc_config->min_bitpool);
p_sbc_config->max_bitpool =
- BTA_AV_CO_MIN(p_sink->codec_caps[BTA_AV_CO_SBC_MAX_BITPOOL_OFF],
+ BTA_AV_CO_MIN(p_sink->codec_caps[BTA_AV_CO_SBC_MAX_BITPOOL_OFF],
p_sbc_config->max_bitpool);
break;
}
diff --git a/btif/co/bta_dm_co.c b/btif/co/bta_dm_co.c
index b4c893c..da9a5ce 100644
--- a/btif/co/bta_dm_co.c
+++ b/btif/co/bta_dm_co.c
@@ -3,44 +3,44 @@
* Copyright (C) 2009-2011 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.
*
************************************************************************************/
@@ -81,7 +81,7 @@ BOOLEAN bta_dm_co_get_compress_memory(tBTA_SYS_ID id, UINT8 **memory_p, UINT32 *
** Parameters bd_addr - The peer device
** *p_io_cap - The local Input/Output capabilities
** *p_oob_data - TRUE, if OOB data is available for the peer device.
-** *p_auth_req - TRUE, if MITM protection is required.
+** *p_auth_req - TRUE, if MITM protection is required.
**
** Returns void.
**
@@ -101,7 +101,7 @@ void bta_dm_co_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap, tBTA_OOB_DATA *p_o
** Parameters bd_addr - The peer device
** io_cap - The remote Input/Output capabilities
** oob_data - TRUE, if OOB data is available for the peer device.
-** auth_req - TRUE, if MITM protection is required.
+** auth_req - TRUE, if MITM protection is required.
**
** Returns void.
**
@@ -119,7 +119,7 @@ void bta_dm_co_io_rsp(BD_ADDR bd_addr, tBTA_IO_CAP io_cap,
** platform wants allow link key upgrade
**
** Parameters bd_addr - The peer device
-** *p_upgrade - TRUE, if link key upgrade is desired.
+** *p_upgrade - TRUE, if link key upgrade is desired.
**
** Returns void.
**
@@ -175,8 +175,8 @@ void bta_dm_co_rmt_oob(BD_ADDR bd_addr)
**
** Function btui_sco_codec_callback
**
-** Description Callback for btui codec.
-**
+** Description Callback for btui codec.
+**
**
** Returns void
**
@@ -189,15 +189,15 @@ static void btui_sco_codec_callback(UINT16 event, UINT16 sco_handle)
**
** Function bta_dm_sco_co_init
**
-** Description This function can be used by the phone to initialize audio
+** Description This function can be used by the phone to initialize audio
** codec or for other initialization purposes before SCO connection
-** is opened.
-**
+** is opened.
+**
**
** Returns tBTA_DM_SCO_ROUTE_TYPE: SCO routing configuration type.
**
*******************************************************************************/
-tBTA_DM_SCO_ROUTE_TYPE bta_dm_sco_co_init(UINT32 rx_bw, UINT32 tx_bw,
+tBTA_DM_SCO_ROUTE_TYPE bta_dm_sco_co_init(UINT32 rx_bw, UINT32 tx_bw,
tBTA_CODEC_INFO * p_codec_type, UINT8 app_id)
{
tBTM_SCO_ROUTE_TYPE route = BTA_DM_SCO_ROUTE_PCM;
@@ -236,7 +236,7 @@ tBTA_DM_SCO_ROUTE_TYPE bta_dm_sco_co_init(UINT32 rx_bw, UINT32 tx_bw,
** Function bta_dm_sco_co_open
**
** Description This function is executed when a SCO connection is open.
-**
+**
**
** Returns void
**
@@ -264,7 +264,7 @@ void bta_dm_sco_co_open(UINT16 handle, UINT8 pkt_size, UINT16 event)
** Function bta_dm_sco_co_close
**
** Description This function is called when a SCO connection is closed
-**
+**
**
** Returns void
**
@@ -285,7 +285,7 @@ void bta_dm_sco_co_close(void)
**
** Function bta_dm_sco_co_in_data
**
-** Description This function is called to send incoming SCO data to application.
+** Description This function is called to send incoming SCO data to application.
**
** Returns void
**
@@ -302,13 +302,13 @@ void bta_dm_sco_co_in_data(BT_HDR *p_buf)
**
** Function bta_dm_sco_co_out_data
**
-** Description This function is called to send SCO data over HCI.
+** Description This function is called to send SCO data over HCI.
**
** Returns void
**
*******************************************************************************/
void bta_dm_sco_co_out_data(BT_HDR **p_buf)
-{
+{
btui_sco_codec_readbuf(p_buf);
}
@@ -326,20 +326,20 @@ void bta_dm_sco_co_out_data(BT_HDR **p_buf)
** Parameters bd_addr - The peer device
** *p_max_key_size - max key size local device supported.
** *p_init_key - initiator keys.
-** *p_resp_key - responder keys.
+** *p_resp_key - responder keys.
**
** Returns void.
**
*******************************************************************************/
-void bta_dm_co_le_io_key_req(BD_ADDR bd_addr, UINT8 *p_max_key_size,
- tBTA_LE_KEY_TYPE *p_init_key,
+void bta_dm_co_le_io_key_req(BD_ADDR bd_addr, UINT8 *p_max_key_size,
+ tBTA_LE_KEY_TYPE *p_init_key,
tBTA_LE_KEY_TYPE *p_resp_key )
{
BTIF_TRACE_ERROR0("##################################");
BTIF_TRACE_ERROR0("bta_dm_co_le_io_key_req: only setting max size to 16");
BTIF_TRACE_ERROR0("##################################");
*p_max_key_size = 16;
- *p_init_key = *p_resp_key =
+ *p_init_key = *p_resp_key =
(BTA_LE_KEY_PENC|BTA_LE_KEY_PID|BTA_LE_KEY_PCSRK|BTA_LE_KEY_LENC|BTA_LE_KEY_LID|BTA_LE_KEY_LCSRK);
}
@@ -351,7 +351,7 @@ void bta_dm_co_le_io_key_req(BD_ADDR bd_addr, UINT8 *p_max_key_size,
** Description This callout function is to load the local BLE keys if available
** on the device.
**
-** Parameters none
+** Parameters none
**
** Returns void.
**
@@ -374,22 +374,22 @@ void bta_dm_co_ble_load_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OC
** Parameters bd_addr - The peer device
** *p_io_cap - The local Input/Output capabilities
** *p_oob_data - TRUE, if OOB data is available for the peer device.
-** *p_auth_req - Auth request setting (Bonding and MITM required or not)
+** *p_auth_req - Auth request setting (Bonding and MITM required or not)
** *p_max_key_size - max key size local device supported.
** *p_init_key - initiator keys.
-** *p_resp_key - responder keys.
+** *p_resp_key - responder keys.
**
** Returns void.
**
*******************************************************************************/
-void bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
+void bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
tBTA_OOB_DATA *p_oob_data,
tBTA_LE_AUTH_REQ *p_auth_req,
- UINT8 *p_max_key_size,
- tBTA_LE_KEY_TYPE *p_init_key,
+ UINT8 *p_max_key_size,
+ tBTA_LE_KEY_TYPE *p_init_key,
tBTA_LE_KEY_TYPE *p_resp_key )
{
- /* if OOB is not supported, this call-out function does not need to do anything
+ /* if OOB is not supported, this call-out function does not need to do anything
* otherwise, look for the OOB data associated with the address and set *p_oob_data accordingly
* If the answer can not be obtained right away,
* set *p_oob_data to BTA_OOB_UNKNOWN and call bta_dm_ci_io_req() when the answer is available */
diff --git a/btif/co/bta_fs_co.c b/btif/co/bta_fs_co.c
index 9b0ab0a..0ba35bd 100644
--- a/btif/co/bta_fs_co.c
+++ b/btif/co/bta_fs_co.c
@@ -3,44 +3,44 @@
* Copyright (C) 2009-2011 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.
*
************************************************************************************/
@@ -86,7 +86,7 @@ extern const tBTA_PBS_CFG bta_pbs_cfg;
-static int del_path (const char *path)
+static int del_path (const char *path)
{
DIR *dir;
struct dirent *de;
@@ -107,7 +107,7 @@ static int del_path (const char *path)
strcat(nameBuffer, "/");
int nameLen = strlen(nameBuffer);
filenameOffset = nameBuffer + nameLen;
-
+
for (;;) {
de = readdir(dir);
@@ -117,15 +117,15 @@ static int del_path (const char *path)
break;
}
- if (0 == strcmp(de->d_name, ".") || 0 == strcmp(de->d_name, ".."))
+ if (0 == strcmp(de->d_name, ".") || 0 == strcmp(de->d_name, ".."))
continue;
-
+
if((int)strlen(de->d_name) > PATH_MAX - nameLen) {
BTIF_TRACE_DEBUG1("d_name len:%d is too big", strlen(de->d_name));
ret = -1;
break;
}
-
+
strcpy(filenameOffset, de->d_name);
ret = lstat (nameBuffer, &statBuffer);
@@ -154,18 +154,18 @@ static int del_path (const char *path)
ret = rmdir(path);
BTIF_TRACE_DEBUG2("rmdir return:%d for path:%s", ret, path);
}
-
+
return ret;
}
-inline int getAccess(int accType, struct stat *buffer, char *p_path)
+inline int getAccess(int accType, struct stat *buffer, char *p_path)
{
struct statfs fsbuffer;
int idType;
- if(! buffer)
+ if(! buffer)
return BTA_FS_CO_FAIL;
//idType= (buffer->st_uid== BT_UID) ? 1 : (buffer->st_uid== BT_GID) ? 2 : 3;
@@ -178,7 +178,7 @@ inline int getAccess(int accType, struct stat *buffer, char *p_path)
idType = 2;
else idType = 3;
- if(statfs(p_path, &fsbuffer)==0)
+ if(statfs(p_path, &fsbuffer)==0)
{
if(fsbuffer.f_type == FAT_FS)
return BTA_FS_CO_OK;
@@ -186,43 +186,43 @@ inline int getAccess(int accType, struct stat *buffer, char *p_path)
else {
return BTA_FS_CO_FAIL;
}
-
+
switch(accType) {
case 4:
if(idType== 1) { //Id is User Id
- if(buffer-> st_mode & S_IRUSR)
+ if(buffer-> st_mode & S_IRUSR)
return BTA_FS_CO_OK;
}
else if(idType==2) { //Id is Group Id
- if(buffer-> st_mode & S_IRGRP)
+ if(buffer-> st_mode & S_IRGRP)
return BTA_FS_CO_OK;
}
else { //Id is Others
- if(buffer-> st_mode & S_IROTH)
+ if(buffer-> st_mode & S_IROTH)
return BTA_FS_CO_OK;
}
break;
case 6:
if(idType== 1) { //Id is User Id
- if((buffer-> st_mode & S_IRUSR) && (buffer-> st_mode & S_IWUSR))
+ if((buffer-> st_mode & S_IRUSR) && (buffer-> st_mode & S_IWUSR))
return BTA_FS_CO_OK;
}
else if(idType==2) { //Id is Group Id
- if((buffer-> st_mode & S_IRGRP) && (buffer-> st_mode & S_IWGRP))
+ if((buffer-> st_mode & S_IRGRP) && (buffer-> st_mode & S_IWGRP))
return BTA_FS_CO_OK;
}
else { //Id is Others
- if((buffer-> st_mode & S_IROTH) && (buffer-> st_mode & S_IWOTH))
+ if((buffer-> st_mode & S_IROTH) && (buffer-> st_mode & S_IWOTH))
return BTA_FS_CO_OK;
}
break;
-
+
default:
return BTA_FS_CO_OK;
- }
+ }
BTIF_TRACE_DEBUG0("*************FTP- Access Failed **********");
- return BTA_FS_CO_EACCES;
+ return BTA_FS_CO_EACCES;
}
@@ -347,7 +347,7 @@ static int btapp_fs_check_space( const char *p_path, const UINT32 size, const UI
** of the call-out function.
**
** Returns void
-**
+**
** Note: Upon completion of the request, a file descriptor (int),
** if successful, and an error code (tBTA_FS_CO_STATUS)
** are returned in the call-in function, bta_fs_ci_open().
@@ -366,7 +366,7 @@ void bta_fs_co_open(const char *p_path, int oflags, UINT32 size, UINT16 evt,
/* Convert BTA oflags into os specific flags */
oflags = bta_fs_convert_bta_oflags(oflags);
-
+
/* check available space in case of write access. oflags are in OS format! */
if (oflags & (O_RDWR|O_WRONLY))
{
@@ -472,7 +472,7 @@ tBTA_FS_CO_STATUS bta_fs_co_close(int fd, UINT8 app_id)
** of the call-out function.
**
** Returns void
-**
+**
** Note: Upon completion of the request, bta_fs_ci_read() is
** called with the buffer of data, along with the number
** of bytes read into the buffer, and a status. The
@@ -518,7 +518,7 @@ void bta_fs_co_read(int fd, UINT8 *p_buf, UINT16 nbytes, UINT16 evt, UINT8 ssn,
** of the call-out function.
**
** Returns void
-**
+**
** Note: Upon completion of the request, bta_fs_ci_write() is
** called with the file descriptor and the status. The
** call-in function should only be called when ALL requested
@@ -547,7 +547,7 @@ void bta_fs_co_write(int fd, const UINT8 *p_buf, UINT16 nbytes, UINT16 evt,
** Function bta_fs_co_seek
**
** Description This function is called by io to move the file pointer
-** of a previously opened file to the specified location for
+** of a previously opened file to the specified location for
** the next read or write operation.
**
** Parameters fd - file descriptor of file.
@@ -555,7 +555,7 @@ void bta_fs_co_write(int fd, const UINT8 *p_buf, UINT16 nbytes, UINT16 evt,
** origin - Initial position.
**
** Returns void
-**
+**
*******************************************************************************/
void bta_fs_co_seek (int fd, INT32 offset, INT16 origin, UINT8 app_id)
{
@@ -592,28 +592,28 @@ tBTA_FS_CO_STATUS bta_fs_co_access(const char *p_path, int mode, BOOLEAN *p_is_d
struct stat buffer;
#if (TRUE==BTA_FS_DEBUG)
- LOGI("***********CHECKING ACCESS TO = %s", p_path);
+ LOGI("***********CHECKING ACCESS TO = %s", p_path);
#endif
- #if (defined BTA_PBS_INCLUDED) && (BTA_PBS_INCLUDED == TRUE)
+ #if (defined BTA_PBS_INCLUDED) && (BTA_PBS_INCLUDED == TRUE)
if (app_id == UI_PBS_ID)
{
-
+
*p_is_dir = TRUE;
#if (TRUE==BTA_FS_DEBUG)
- LOGI("***********SUPPORTED REPO = %d", bta_pbs_cfg.supported_repositories);
+ LOGI("***********SUPPORTED REPO = %d", bta_pbs_cfg.supported_repositories);
#endif
- //Check if SIM contact requested, and if so if it's supported.
+ //Check if SIM contact requested, and if so if it's supported.
//If not, return error!
if (strstr(p_path,"SIM1") && !(bta_pbs_cfg.supported_repositories & 0x2)) {
- LOGI("***********RETURNING FAIL!");
+ LOGI("***********RETURNING FAIL!");
return BTA_FS_CO_FAIL;
}
#if (TRUE==BTA_FS_DEBUG)
- LOGI("***********RETURNING success!");
+ LOGI("***********RETURNING success!");
#endif
return (status);
}
@@ -621,24 +621,24 @@ tBTA_FS_CO_STATUS bta_fs_co_access(const char *p_path, int mode, BOOLEAN *p_is_d
*p_is_dir = FALSE;
-
+
if (mode == BTA_FS_ACC_RDWR)
os_mode = 6;
else if (mode == BTA_FS_ACC_READ)
os_mode = 4;
-
- if (stat(p_path, &buffer) == 0)
+
+ if (stat(p_path, &buffer) == 0)
{
/* Determine if the object is a file or directory */
if (S_ISDIR(buffer.st_mode))
*p_is_dir = TRUE;
}
- else
+ else
{
BTIF_TRACE_DEBUG0("stat() failed! ");
return BTA_FS_CO_FAIL;
}
-
+
status=getAccess (os_mode, &buffer, (char*)p_path);
return (status);
}
@@ -701,14 +701,14 @@ tBTA_FS_CO_STATUS bta_fs_co_rmdir(const char *p_path, UINT8 app_id)
tBTA_FS_CO_STATUS status = BTA_FS_CO_OK;
struct stat buffer;
char *dirName, *tmp = NULL;
-
+
path_len = strlen( p_path )+1;
BTIF_TRACE_DEBUG2( "bta_fs_co_rmdir( app_id: %d ): path_len: %d", app_id, path_len );
#if (TRUE==BTA_FS_DEBUG)
BTIF_TRACE_DEBUG1( "bta_fs_co_rmdir():path_len: %d, p_path", app_id );
BTIF_TRACE_DEBUG0( p_path );
#endif
-
+
/* allocate a temp buffer for path with 0 char. make sure not to crash if path is too big! */
dirName = (char*) calloc(1, path_len+1);
if ( NULL != dirName )
@@ -721,7 +721,7 @@ tBTA_FS_CO_STATUS bta_fs_co_rmdir(const char *p_path, UINT8 app_id)
app_id, path_len );
return BTA_FS_CO_FAIL;
}
-
+
if (NULL!= (tmp = strrchr(dirName, '/')))
{
*tmp = '\0';
@@ -738,7 +738,7 @@ tBTA_FS_CO_STATUS bta_fs_co_rmdir(const char *p_path, UINT8 app_id)
#endif
return BTA_FS_CO_FAIL;
}
-
+
free(dirName);
if (status != BTA_FS_CO_OK)
{
@@ -747,7 +747,7 @@ tBTA_FS_CO_STATUS bta_fs_co_rmdir(const char *p_path, UINT8 app_id)
#endif
return status;
}
-
+
if (stat(p_path, &buffer) == 0)
{
status = getAccess(6, &buffer, (char*)p_path);
@@ -759,7 +759,7 @@ tBTA_FS_CO_STATUS bta_fs_co_rmdir(const char *p_path, UINT8 app_id)
#endif
return BTA_FS_CO_FAIL;
}
-
+
if (status != BTA_FS_CO_OK)
{
#if (TRUE==BTA_FS_DEBUG)
@@ -807,37 +807,37 @@ tBTA_FS_CO_STATUS bta_fs_co_unlink(const char *p_path, UINT8 app_id)
tBTA_FS_CO_STATUS status = BTA_FS_CO_OK;
char *dirName, *tmp=NULL;
struct stat buffer;
-
+
if(! p_path)
return BTA_FS_CO_FAIL;
/* buffer needs to be NULL terminated - so add one more byte to be zero'd out */
-#if 0
+#if 0
dirName= (char*) calloc(1, strlen(p_path)); /* <--- this can cause problems */
-#else
+#else
dirName= (char*) calloc(1, strlen(p_path) + 1);
-#endif
-
+#endif
+
strncpy(dirName, p_path, strlen(p_path));
- if((tmp=strrchr(dirName, '/')))
+ if((tmp=strrchr(dirName, '/')))
{
*tmp='\0';
- }
- if (stat(dirName, &buffer) == 0)
+ }
+ if (stat(dirName, &buffer) == 0)
{
status=getAccess (6, &buffer, dirName);
free(dirName);
}
- else
+ else
{
BTIF_TRACE_DEBUG0("stat() failed! ");
free(dirName);
return BTA_FS_CO_FAIL;
}
-
+
if(status!= BTA_FS_CO_OK)
return status;
-
+
if ((unlink (p_path)) != 0)
{
err = errno;
@@ -869,7 +869,7 @@ tBTA_FS_CO_STATUS bta_fs_co_unlink(const char *p_path, UINT8 app_id)
** of the call-out function.
**
** Returns void
-**
+**
** Note: Upon completion of the request, the status is passed
** in the bta_fs_ci_direntry() call-in function.
** BTA_FS_CO_OK is returned when p_entry is valid,
@@ -996,7 +996,7 @@ void bta_fs_co_getdirentry(const char *p_path, BOOLEAN first_item,
**
** Function bta_fs_co_setdir
**
-** Description This function is executed by BTA when the server changes the
+** Description This function is executed by BTA when the server changes the
** local path
**
** Parameters p_path - the new path.
@@ -1005,7 +1005,7 @@ void bta_fs_co_getdirentry(const char *p_path, BOOLEAN first_item,
** of the call-out function.
**
** Returns void
-**
+**
*******************************************************************************/
void bta_fs_co_setdir(const char *p_path, UINT8 app_id)
{
@@ -1013,7 +1013,7 @@ void bta_fs_co_setdir(const char *p_path, UINT8 app_id)
}
/*******************************************************************************
-** OBEX14 Reliable Session not supported. Stub associated callouts.
+** OBEX14 Reliable Session not supported. Stub associated callouts.
******************************************************************************/
/*******************************************************************************
@@ -1029,7 +1029,7 @@ void bta_fs_co_setdir(const char *p_path, UINT8 app_id)
** of the call-out function.
**
** Returns void
-**
+**
** Note: Upon completion of the request, the related session information,
** if successful, and an error code (tBTA_FS_CO_STATUS)
** are returned in the call-in function, bta_fs_ci_resume().
@@ -1055,7 +1055,7 @@ void bta_fs_co_resume(UINT16 evt, UINT8 app_id)
**
** Returns (tBTA_FS_CO_STATUS) status of the call.
** [BTA_FS_CO_OK if successful]
-** [BTA_FS_CO_EACCES if p_dest_path already exists or could not be created (invalid path);
+** [BTA_FS_CO_EACCES if p_dest_path already exists or could not be created (invalid path);
** or p_src_path is a directory and p_dest_path specifies a different path. ]
** [BTA_FS_CO_FAIL otherwise]
**
@@ -1081,7 +1081,7 @@ void bta_fs_co_set_perms(const char *p_src_path, UINT8 *p_perms, UINT16 evt, UI
**
** Returns (tBTA_FS_CO_STATUS) status of the call.
** [BTA_FS_CO_OK if successful]
-** [BTA_FS_CO_EACCES if p_dest_path already exists or could not be created (invalid path);
+** [BTA_FS_CO_EACCES if p_dest_path already exists or could not be created (invalid path);
** or p_src_path is a directory and p_dest_path specifies a different path. ]
** [BTA_FS_CO_FAIL otherwise]
**
@@ -1109,7 +1109,7 @@ void bta_fs_co_rename(const char *p_src_path, const char *p_dest_path, UINT8 *p_
** Returns (tBTA_FS_CO_STATUS) status of the call.
** [BTA_FS_CO_OK if successful]
** [BTA_FS_CO_EIS_DIR if p_src_path is a folder]
-** [BTA_FS_CO_EACCES if p_dest_path already exists or could not be created (invalid path);
+** [BTA_FS_CO_EACCES if p_dest_path already exists or could not be created (invalid path);
** or p_src_path is a directory and p_dest_path specifies a different path. ]
** [BTA_FS_CO_FAIL otherwise]
**
@@ -1133,7 +1133,7 @@ void bta_fs_co_copy(const char *p_src_path, const char *p_dest_path, UINT8 *p_pe
** of the call-out function.
**
** Returns void
-**
+**
*******************************************************************************/
void bta_fs_co_resume_op(UINT32 offset, UINT16 evt, UINT8 app_id)
{
@@ -1155,7 +1155,7 @@ void bta_fs_co_resume_op(UINT32 offset, UINT16 evt, UINT8 app_id)
** of the call-out function.
**
** Returns void
-**
+**
*******************************************************************************/
void bta_fs_co_session_info(BD_ADDR bd_addr, UINT8 *p_sess_info, UINT8 ssn,
tBTA_FS_CO_SESS_ST new_st, char *p_path, UINT8 *p_info, UINT8 app_id)
@@ -1180,7 +1180,7 @@ void bta_fs_co_session_info(BD_ADDR bd_addr, UINT8 *p_sess_info, UINT8 ssn,
** of the call-out function.
**
** Returns void
-**
+**
*******************************************************************************/
void bta_fs_co_suspend(BD_ADDR bd_addr, UINT8 *p_sess_info, UINT8 ssn,
UINT32 *p_timeout, UINT32 *p_offset, UINT8 info, UINT8 app_id)
@@ -1203,7 +1203,7 @@ void bta_fs_co_suspend(BD_ADDR bd_addr, UINT8 *p_sess_info, UINT8 ssn,
** of the call-out function.
**
** Returns void
-**
+**
*******************************************************************************/
void bta_fs_co_sess_ssn(int fd, UINT8 ssn, UINT8 app_id)
{
diff --git a/btif/co/bta_sys_co.c b/btif/co/bta_sys_co.c
index 66643bf..a2d0d44 100644
--- a/btif/co/bta_sys_co.c
+++ b/btif/co/bta_sys_co.c
@@ -3,44 +3,44 @@
* Copyright (C) 2009-2011 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 @@
**
** Function bta_sys_hw_co_enable
**
-** Description This function is called by the stack to power up the HW
+** Description This function is called by the stack to power up the HW
**
** Returns void
**
@@ -59,7 +59,7 @@
void bta_sys_hw_co_enable( tBTA_SYS_HW_MODULE module )
{
/* platform specific implementation to power-up the HW */
-
+
/* if no client/server asynchronous system like linux-based OS, directly call the ci here */
bta_sys_hw_ci_enabled( module );
@@ -70,7 +70,7 @@ void bta_sys_hw_co_enable( tBTA_SYS_HW_MODULE module )
**
** Function bta_sys_hw_co_disable
**
-** Description This function is called by the stack to power down the HW
+** Description This function is called by the stack to power down the HW
**
** Returns void
**
@@ -78,9 +78,9 @@ void bta_sys_hw_co_enable( tBTA_SYS_HW_MODULE module )
void bta_sys_hw_co_disable( tBTA_SYS_HW_MODULE module )
{
/* platform specific implementation to power-down the HW */
-
+
/* if no client/server asynchronous system like linux-based OS, directly call the ci here */
bta_sys_hw_ci_disabled( module );
-
+
}
diff --git a/btif/include/btif_api.h b/btif/include/btif_api.h
index b5157de..087add5 100644
--- a/btif/include/btif_api.h
+++ b/btif/include/btif_api.h
@@ -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
+ * 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.
+ * 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.
*
*****************************************************************************/
@@ -50,10 +50,10 @@
* Filename: btif_api.h
*
* Description: Main API header file for all BTIF functions accessed
- * from main bluetooth HAL. All HAL extensions will not
+ * from main bluetooth HAL. All HAL extensions will not
* require headerfiles as they would be accessed through
* callout/callins.
- *
+ *
*****************************************************************************/
#ifndef BTIF_API_H
@@ -81,7 +81,7 @@
/*****************************************************************************
** Functions
******************************************************************************/
-
+
/*****************************************************************************
** BTIF CORE API
@@ -93,8 +93,8 @@
** Function btif_init_bluetooth
**
** Description Creates BTIF task and prepares BT scheduler for startup
-**
-** Returns bt_status_t
+**
+** Returns bt_status_t
**
*******************************************************************************/
@@ -105,8 +105,8 @@ bt_status_t btif_init_bluetooth(void);
** Function btif_enable_bluetooth
**
** Description Performs chip power on and kickstarts OS scheduler
-**
-** Returns bt_status_t
+**
+** Returns bt_status_t
**
*******************************************************************************/
@@ -119,8 +119,8 @@ bt_status_t btif_enable_bluetooth(void);
** Description Inititates shutdown of Bluetooth system.
** Any active links will be dropped and device entering
** non connectable/discoverable mode
-**
-** Returns void
+**
+** Returns void
**
*******************************************************************************/
@@ -132,9 +132,9 @@ bt_status_t btif_disable_bluetooth(void);
**
** Description Finalizes BT scheduler shutdown and terminates BTIF
** task.
-**
-**
-** Returns void
+**
+**
+** Returns void
**
*******************************************************************************/
@@ -146,8 +146,8 @@ bt_status_t btif_shutdown_bluetooth(void);
** Function btif_get_adapter_properties
**
** Description Fetches all local adapter properties
-**
-** Returns bt_status_t
+**
+** Returns bt_status_t
**
*******************************************************************************/
@@ -159,7 +159,7 @@ bt_status_t btif_get_adapter_properties(void);
**
** Description Fetches property value from local cache
**
-** Returns bt_status_t
+** Returns bt_status_t
**
*******************************************************************************/
@@ -169,10 +169,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
**
*******************************************************************************/
@@ -187,8 +187,8 @@ bt_status_t btif_set_adapter_property( const bt_property_t *property);
** Returns bt_status_t
**
*******************************************************************************/
-
-bt_status_t btif_get_remote_device_property( bt_bdaddr_t *remote_addr,
+
+bt_status_t btif_get_remote_device_property( bt_bdaddr_t *remote_addr,
bt_property_type_t type);
@@ -215,11 +215,11 @@ bt_status_t btif_get_remote_device_properties( bt_bdaddr_t *remote_addr);
**
** Returns bt_status_t
**
-*******************************************************************************/
+*******************************************************************************/
-bt_status_t btif_set_remote_device_property( bt_bdaddr_t *remote_addr,
+bt_status_t btif_set_remote_device_property( bt_bdaddr_t *remote_addr,
const bt_property_t *property);
-
+
/*******************************************************************************
**
@@ -230,9 +230,9 @@ 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);
/*****************************************************************************
@@ -247,9 +247,9 @@ bt_status_t btif_get_remote_service_record( bt_bdaddr_t *remote_addr,
**
**
** Returns bt_status_t
-**
+**
*******************************************************************************/
-
+
bt_status_t btif_dm_start_discovery(void);
/*******************************************************************************
@@ -322,8 +322,8 @@ bt_status_t btif_dm_pin_reply( const bt_bdaddr_t *bd_addr, uint8_t accept,
** Returns bt_status_t
**
*******************************************************************************/
-
-bt_status_t btif_dm_passkey_reply( const bt_bdaddr_t *bd_addr,
+
+bt_status_t btif_dm_passkey_reply( const bt_bdaddr_t *bd_addr,
uint8_t accept, uint32_t passkey);
/*******************************************************************************
@@ -336,7 +336,7 @@ bt_status_t btif_dm_passkey_reply( const bt_bdaddr_t *bd_addr,
**
*******************************************************************************/
-bt_status_t btif_dm_ssp_reply( const bt_bdaddr_t *bd_addr,
+bt_status_t btif_dm_ssp_reply( const bt_bdaddr_t *bd_addr,
bt_ssp_variant_t variant, uint8_t accept,
uint32_t passkey);
@@ -350,7 +350,7 @@ bt_status_t btif_dm_ssp_reply( const bt_bdaddr_t *bd_addr,
**
*******************************************************************************/
-bt_status_t btif_dm_get_adapter_property(bt_property_t *prop);
+bt_status_t btif_dm_get_adapter_property(bt_property_t *prop);
/*******************************************************************************
**
@@ -362,7 +362,7 @@ bt_status_t btif_dm_get_adapter_property(bt_property_t *prop);
**
*******************************************************************************/
-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);
#endif /* BTIF_API_H */
diff --git a/btif/include/btif_av.h b/btif/include/btif_av.h
index 720fa87..8d67f66 100644
--- a/btif/include/btif_av.h
+++ b/btif/include/btif_av.h
@@ -46,145 +46,111 @@
*****************************************************************************/
/*****************************************************************************
-**
-** Name: btif_av.h
-**
-** Description:
-**
-******************************************************************************/
-
+ *
+ * Filename: btif_av.h
+ *
+ * Description: Main API header file for all BTIF AV functions accessed
+ * from internal stack.
+ *
+ *****************************************************************************/
#ifndef BTIF_AV_H
#define BTIF_AV_H
-#include "btif_media.h"
+#include "btif_common.h"
+#include "btif_sm.h"
+#include "bta_av_api.h"
-enum
-{
- BTIF_SV_AV_AA_SBC_INDEX = 0,
- BTIF_SV_AV_AA_SEP_INDEX /* Last index */
-};
+/*****************************************************************************
+** Constants & Macros
+******************************************************************************/
-/*******************************************************************************
- **
- ** Function bta_av_co_cp_is_active
- **
- ** Description Get the current configuration of content protection
- **
- ** Returns TRUE if the current streaming has CP, FALSE otherwise
- **
- *******************************************************************************/
-BOOLEAN bta_av_co_cp_is_active(void);
+/*****************************************************************************
+** Type definitions for callback functions
+******************************************************************************/
-/*******************************************************************************
- **
- ** Function bta_av_co_cp_get_flag
- **
- ** Description Get content protection flag
- ** BTA_AV_CP_SCMS_COPY_NEVER
- ** BTA_AV_CP_SCMS_COPY_ONCE
- ** BTA_AV_CP_SCMS_COPY_FREE
- **
- ** Returns The current flag value
- **
- *******************************************************************************/
-UINT8 bta_av_co_cp_get_flag(void);
-/*******************************************************************************
- **
- ** Function bta_av_co_cp_set_flag
- **
- ** Description Set content protection flag
- ** BTA_AV_CP_SCMS_COPY_NEVER
- ** BTA_AV_CP_SCMS_COPY_ONCE
- ** BTA_AV_CP_SCMS_COPY_FREE
- **
- ** Returns TRUE if setting the SCMS flag is supported else FALSE
- **
- *******************************************************************************/
-BOOLEAN bta_av_co_cp_set_flag(UINT8 cp_flag);
+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;
-/*******************************************************************************
- **
- ** Function bta_av_co_audio_codec_reset
- **
- ** Description Reset the current codec configuration
- **
- ** Returns void
- **
- *******************************************************************************/
-void bta_av_co_audio_codec_reset(void);
+/*****************************************************************************
+** Type definitions and return values
+******************************************************************************/
-/*******************************************************************************
- **
- ** Function bta_av_co_audio_codec_supported
- **
- ** Description Check if all opened connections are compatible with a codec
- ** configuration
- **
- ** Returns TRUE if all opened devices support this codec, FALSE otherwise
- **
- *******************************************************************************/
-BOOLEAN bta_av_co_audio_codec_supported(tBTIF_STATUS *p_status);
+/*****************************************************************************
+** Extern variables and functions
+******************************************************************************/
-/*******************************************************************************
- **
- ** Function bta_av_co_audio_set_codec
- **
- ** Description Set the current codec configuration from the feeding type.
- ** This function is starting to modify the configuration, it
- ** should be protected.
- **
- ** Returns TRUE if successful, FALSE otherwise
- **
- *******************************************************************************/
-BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTIF_STATUS *p_status);
+/*****************************************************************************
+** Functions
+******************************************************************************/
+
+
+/*****************************************************************************
+** BTIF CORE API
+******************************************************************************/
+
+/*****************************************************************************
+** BTIF AV API
+******************************************************************************/
/*******************************************************************************
- **
- ** Function bta_av_co_audio_get_sbc_config
- **
- ** Description Retrieves the SBC codec configuration. If the codec in use
- ** is not SBC, return the default SBC codec configuration.
- **
- ** Returns TRUE if codec is SBC, FALSE otherwise
- **
- *******************************************************************************/
-BOOLEAN bta_av_co_audio_get_sbc_config(tA2D_SBC_CIE *p_sbc_config, UINT16 *p_minmtu);
+**
+** Function btif_av_get_sm_handle
+**
+** Description Fetches current av SM handle
+**
+** Returns None
+**
+*******************************************************************************/
+
+btif_sm_handle_t btif_av_get_sm_handle(void);
/*******************************************************************************
- **
- ** Function bta_av_co_audio_discard_config
- **
- ** Description Discard the codec configuration of a connection
- **
- ** Returns Nothing
- **
- *******************************************************************************/
-void bta_av_co_audio_discard_config(tBTA_AV_HNDL hndl);
+**
+** Function btif_av_stream_ready
+**
+** Description Checks whether AV is ready for starting a stream
+**
+** Returns None
+**
+*******************************************************************************/
+
+BOOLEAN btif_av_stream_ready(void);
/*******************************************************************************
- **
- ** Function bta_av_co_init
- **
- ** Description Initialization
- **
- ** Returns Nothing
- **
- *******************************************************************************/
-void bta_av_co_init(void);
+**
+** Function btif_av_stream_started
+**
+** Description Checks whether AV is already started (remotely)
+**
+** Returns None
+**
+*******************************************************************************/
+BOOLEAN btif_av_stream_started(void);
/*******************************************************************************
- **
- ** Function bta_av_co_peer_cp_supported
- **
- ** Description Checks if the peer supports CP
- **
- ** Returns TRUE if the peer supports CP
- **
- *******************************************************************************/
-BOOLEAN bta_av_co_peer_cp_supported(tBTA_AV_HNDL hndl);
-
-#endif
+**
+** 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);
+
+
+#endif /* BTIF_AV_H */
+
diff --git a/btif/include/btif_av_co.h b/btif/include/btif_av_co.h
new file mode 100644
index 0000000..fd108d1
--- /dev/null
+++ b/btif/include/btif_av_co.h
@@ -0,0 +1,189 @@
+/******************************************************************************
+ *
+ * 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.
+ *
+ * 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
+ * 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
+ * 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
+ * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
+ *
+ *****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename: btif_av_co.h
+ *
+ * Description:
+ *
+ *****************************************************************************/
+
+#ifndef BTIF_AV_CO_H
+#define BTIF_AV_CO_H
+
+#include "btif_media.h"
+
+enum
+{
+ BTIF_SV_AV_AA_SBC_INDEX = 0,
+ BTIF_SV_AV_AA_SEP_INDEX /* Last index */
+};
+
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_cp_is_active
+ **
+ ** Description Get the current configuration of content protection
+ **
+ ** Returns TRUE if the current streaming has CP, FALSE otherwise
+ **
+ *******************************************************************************/
+BOOLEAN bta_av_co_cp_is_active(void);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_cp_get_flag
+ **
+ ** Description Get content protection flag
+ ** BTA_AV_CP_SCMS_COPY_NEVER
+ ** BTA_AV_CP_SCMS_COPY_ONCE
+ ** BTA_AV_CP_SCMS_COPY_FREE
+ **
+ ** Returns The current flag value
+ **
+ *******************************************************************************/
+UINT8 bta_av_co_cp_get_flag(void);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_cp_set_flag
+ **
+ ** Description Set content protection flag
+ ** BTA_AV_CP_SCMS_COPY_NEVER
+ ** BTA_AV_CP_SCMS_COPY_ONCE
+ ** BTA_AV_CP_SCMS_COPY_FREE
+ **
+ ** Returns TRUE if setting the SCMS flag is supported else FALSE
+ **
+ *******************************************************************************/
+BOOLEAN bta_av_co_cp_set_flag(UINT8 cp_flag);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_audio_codec_reset
+ **
+ ** Description Reset the current codec configuration
+ **
+ ** Returns void
+ **
+ *******************************************************************************/
+void bta_av_co_audio_codec_reset(void);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_audio_codec_supported
+ **
+ ** Description Check if all opened connections are compatible with a codec
+ ** configuration
+ **
+ ** Returns TRUE if all opened devices support this codec, FALSE otherwise
+ **
+ *******************************************************************************/
+BOOLEAN bta_av_co_audio_codec_supported(tBTIF_STATUS *p_status);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_audio_set_codec
+ **
+ ** Description Set the current codec configuration from the feeding type.
+ ** This function is starting to modify the configuration, it
+ ** should be protected.
+ **
+ ** Returns TRUE if successful, FALSE otherwise
+ **
+ *******************************************************************************/
+BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTIF_STATUS *p_status);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_audio_get_sbc_config
+ **
+ ** Description Retrieves the SBC codec configuration. If the codec in use
+ ** is not SBC, return the default SBC codec configuration.
+ **
+ ** Returns TRUE if codec is SBC, FALSE otherwise
+ **
+ *******************************************************************************/
+BOOLEAN bta_av_co_audio_get_sbc_config(tA2D_SBC_CIE *p_sbc_config, UINT16 *p_minmtu);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_audio_discard_config
+ **
+ ** Description Discard the codec configuration of a connection
+ **
+ ** Returns Nothing
+ **
+ *******************************************************************************/
+void bta_av_co_audio_discard_config(tBTA_AV_HNDL hndl);
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_init
+ **
+ ** Description Initialization
+ **
+ ** Returns Nothing
+ **
+ *******************************************************************************/
+void bta_av_co_init(void);
+
+
+/*******************************************************************************
+ **
+ ** Function bta_av_co_peer_cp_supported
+ **
+ ** Description Checks if the peer supports CP
+ **
+ ** Returns TRUE if the peer supports CP
+ **
+ *******************************************************************************/
+BOOLEAN bta_av_co_peer_cp_supported(tBTA_AV_HNDL hndl);
+
+#endif
diff --git a/btif/include/btif_common.h b/btif/include/btif_common.h
index a440802..48ed00f 100755..100644
--- a/btif/include/btif_common.h
+++ b/btif/include/btif_common.h
@@ -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,8 +49,8 @@
*
* Filename: btif_common.h
*
- * Description:
- *
+ * Description:
+ *
***********************************************************************************/
#ifndef BTIF_COMMON_H
@@ -87,15 +87,16 @@
extern bt_callbacks_t *bt_hal_cbacks;
-#define CHECK_CALL_CBACK(P_CB, P_CBACK, ...)\
+#define HAL_CBACK(P_CB, P_CBACK, ...)\
if (P_CB && P_CB->P_CBACK) { \
+ LOGD("HAL %s->%s", #P_CB, #P_CBACK); \
P_CB->P_CBACK(__VA_ARGS__); \
} \
else { \
ASSERTC(0, "Callback is NULL", 0); \
}
-/* btif events for requests that require context switch to btif task
+/* btif events for requests that require context switch to btif task
on downstreams path */
enum
{
@@ -107,7 +108,7 @@ enum
BTIF_CORE_STORAGE_REMOTE_WRITE,
BTIF_CORE_STORAGE_REMOTE_READ,
BTIF_CORE_STORAGE_REMOTE_READ_ALL,
- BTIF_CORE_STORAGE_READ_ALL,
+ BTIF_CORE_STORAGE_READ_ALL,
BTIF_CORE_STORAGE_NOTIFY_STATUS,
/* add here */
@@ -121,7 +122,7 @@ enum
BTIF_AV_API_START = BTIF_SIG_START(BTIF_AV),
/* add here */
-
+
};
/* btif events for callbacks that require context switch to btif task
@@ -168,8 +169,8 @@ tBTA_SERVICE_MASK btif_get_enabled_services_mask(void);
bt_status_t btif_enable_service(tBTA_SERVICE_ID service_id);
bt_status_t btif_disable_service(tBTA_SERVICE_ID service_id);
-/*
- * BTIF_Events
+/*
+ * BTIF_Events
*/
void btif_enable_bluetooth_evt(tBTA_STATUS status, BD_ADDR local_bd);
diff --git a/btif/include/btif_dm.h b/btif/include/btif_dm.h
index 766f4ee..45e3e98 100644
--- a/btif/include/btif_dm.h
+++ b/btif/include/btif_dm.h
@@ -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,8 +49,8 @@
*
* Filename: btif_dm.h
*
- * Description:
- *
+ * Description:
+ *
***********************************************************************************/
#ifndef BTIF_DM_H
diff --git a/btif/include/btif_media.h b/btif/include/btif_media.h
index 0280d5c..5985580 100644
--- a/btif/include/btif_media.h
+++ b/btif/include/btif_media.h
@@ -43,16 +43,16 @@
* LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
* ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
*
- *****************************************************************************/
+ ************************************************************************************/
+
+/************************************************************************************
+ *
+ * Filename: btif_media.h
+ *
+ * Description: This is the audio module for the BTIF system.
+ *
+ ***********************************************************************************/
-/****************************************************************************
- **
- ** Name: btif_media.h
- **
- ** Description: This is the audio module for the BTIF system. It contains
- ** task implementations of A2DP
- **
- ******************************************************************************/
#ifndef BTIF_MEDIA_H
#define BTIF_MEDIA_H
@@ -61,6 +61,11 @@
#include "bd.h"
#include "gki.h"
#include "btif_av_api.h"
+#include "audio_a2dp_hw.h"
+
+/*****************************************************************************
+ ** Constants
+ *****************************************************************************/
/* Generic part */
#define BTIF_SUCCESS 0
@@ -75,11 +80,6 @@
#define BTIF_ERROR_SRV_AV_NOT_STARTED 704 /* AV is not started */
#define BTIF_ERROR_SRV_AV_CP_NOT_SUPPORTED 705 /* Content protection is not supported by all headsets */
-/*****************************************************************************
- ** Constants
- *****************************************************************************/
-
-
/* transcoding definition for TxTranscoding and RxTranscoding */
#define BTIF_MEDIA_TRSCD_OFF 0
#define BTIF_MEDIA_TRSCD_PCM_2_SBC 1 /* Tx */
@@ -261,5 +261,23 @@ extern BOOLEAN btif_media_task_audio_feeding_init_req(tBTIF_MEDIA_INIT_AUDIO_FEE
*******************************************************************************/
extern void dump_codec_info(unsigned char *p_codec);
+/*
+ * local adaptation helper functions between btif and media task
+ */
+
+int btif_a2dp_start_media_task(void);
+void btif_a2dp_stop_media_task(void);
+
+void btif_a2dp_on_init(void);
+void btif_a2dp_on_idle(void);
+void btif_a2dp_on_open(void);
+void btif_a2dp_on_start_req(void);
+void btif_a2dp_on_started(tBTA_AV_START *p_av);
+void btif_a2dp_on_stop_req(void);
+void btif_a2dp_on_stopped(tBTA_AV_SUSPEND *p_av);
+void btif_a2dp_on_suspend(void);
+void btif_a2dp_on_suspended(tBTA_AV_SUSPEND *p_av);
+void btif_a2dp_set_tx_flush(BOOLEAN enable);
+
#endif
diff --git a/btif/include/btif_sm.h b/btif/include/btif_sm.h
index f4d5ede..fb8ddc7 100644
--- a/btif/include/btif_sm.h
+++ b/btif/include/btif_sm.h
@@ -50,7 +50,7 @@
* Filename: btif_sm.h
*
* Description: Generic BTIF state machine API
- *
+ *
*****************************************************************************/
#ifndef BTIF_SM_H
diff --git a/btif/include/btif_storage.h b/btif/include/btif_storage.h
index c1b5bcf..c57f7df 100644
--- a/btif/include/btif_storage.h
+++ b/btif/include/btif_storage.h
@@ -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,8 +49,8 @@
*
* Filename: btif_storage.h
*
- * Description:
- *
+ * Description:
+ *
***********************************************************************************/
#ifndef BTIF_STORAGE_H
diff --git a/btif/include/btif_util.h b/btif/include/btif_util.h
index d455e9e..2688b09 100644
--- a/btif/include/btif_util.h
+++ b/btif/include/btif_util.h
@@ -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,8 +49,8 @@
*
* Filename: btif_util.h
*
- * Description:
- *
+ * Description:
+ *
***********************************************************************************/
#ifndef BTIF_UTIL_H
@@ -95,6 +95,7 @@ const char* dump_adapter_scan_mode(bt_scan_mode_t mode);
const char* dump_thread_evt(bt_cb_thread_evt evt);
const char* dump_av_conn_state(UINT16 event);
+const char* dump_av_audio_state(UINT16 event);
int str2bd(char *str, bt_bdaddr_t *addr);
char *bd2str(bt_bdaddr_t *addr, bdstr_t *bdstr);
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)
{