15738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 25738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 35738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Copyright (C) 2003-2012 Broadcom Corporation 45738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 55738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 65738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * you may not use this file except in compliance with the License. 75738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * You may obtain a copy of the License at: 85738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 95738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * See the License for the specific language governing permissions and 155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * limitations under the License. 165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/ 185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * This is the implementation of the API for the audio gateway (AG) 225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * subsystem of BTA, Broadcom's Bluetooth application layer for mobile 235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * phones. 245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/ 265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_api.h" 285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bd.h" 295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_sys.h" 305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_ag_api.h" 315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_ag_int.h" 325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "gki.h" 335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <string.h> 345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Constants 375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*****************************************************************************/ 385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic const tBTA_SYS_REG bta_ag_reg = 405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_ag_hdl_event, 425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_AgDisable 435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}; 445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function BTA_AgEnable 485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Enable the audio gateway service. When the enable 505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** operation is complete the callback function will be 515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** called with a BTA_AG_ENABLE_EVT. This function must 525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** be called before other function in the AG API are 535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** called. 545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns BTA_SUCCESS if OK, BTA_FAILURE otherwise. 565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjecttBTA_STATUS BTA_AgEnable(tBTA_AG_PARSE_MODE parse_mode, tBTA_AG_CBACK *p_cback) 595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AG_API_ENABLE *p_buf; 615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 idx; 625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Error if AG is already enabled, or AG is in the middle of disabling. */ 645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (idx = 0; idx < BTA_AG_NUM_SCB; idx++) 655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (bta_ag_cb.scb[idx].in_use) 675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_ERROR0 ("BTA_AgEnable: FAILED, AG already enabled."); 695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BTA_FAILURE; 705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* register with BTA system manager */ 745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_sched_lock(); 755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_register(BTA_ID_AG, &bta_ag_reg); 765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_sched_unlock(); 775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (tBTA_AG_API_ENABLE *) GKI_getbuf(sizeof(tBTA_AG_API_ENABLE))) != NULL) 795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->hdr.event = BTA_AG_API_ENABLE_EVT; 815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->parse_mode = parse_mode; 825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->p_cback = p_cback; 835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_sendmsg(p_buf); 845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BTA_SUCCESS; 875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function BTA_AgDisable 935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Disable the audio gateway service 955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid BTA_AgDisable(void) 1015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf; 1035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) 1055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->event = BTA_AG_API_DISABLE_EVT; 1075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_sendmsg(p_buf); 1085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function BTA_AgRegister 1145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Register an Audio Gateway service. 1165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 1195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid BTA_AgRegister(tBTA_SERVICE_MASK services, tBTA_SEC sec_mask,tBTA_AG_FEAT features, 1225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project char * p_service_names[], UINT8 app_id) 1235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AG_API_REGISTER *p_buf; 1255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int i; 1265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (tBTA_AG_API_REGISTER *) GKI_getbuf(sizeof(tBTA_AG_API_REGISTER))) != NULL) 1285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->hdr.event = BTA_AG_API_REGISTER_EVT; 1305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->features = features; 1315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->sec_mask = sec_mask; 1325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->services = services; 1335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->app_id = app_id; 1345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i = 0; i < BTA_AG_NUM_IDX; i++) 1355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_service_names[i]) 1375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BCM_STRNCPY_S(p_buf->p_name[i], BTA_SERVICE_NAME_LEN+1, p_service_names[i], BTA_SERVICE_NAME_LEN); 1395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->p_name[i][BTA_SERVICE_NAME_LEN] = 0; 1405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 1425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->p_name[i][0] = 0; 1445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_sendmsg(p_buf); 1475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function BTA_AgDeregister 1535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Deregister an audio gateway service. 1555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 1585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid BTA_AgDeregister(UINT16 handle) 1615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf; 1635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) 1655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->event = BTA_AG_API_DEREGISTER_EVT; 1675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->layer_specific = handle; 1685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_sendmsg(p_buf); 1695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function BTA_AgOpen 1755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Opens a connection to a headset or hands-free device. 1775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** When connection is open callback function is called 1785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** with a BTA_AG_OPEN_EVT. Only the data connection is 1795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** opened. The audio connection is not opened. 1805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 1835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid BTA_AgOpen(UINT16 handle, BD_ADDR bd_addr, tBTA_SEC sec_mask, tBTA_SERVICE_MASK services) 1865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AG_API_OPEN *p_buf; 1885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (tBTA_AG_API_OPEN *) GKI_getbuf(sizeof(tBTA_AG_API_OPEN))) != NULL) 1905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->hdr.event = BTA_AG_API_OPEN_EVT; 1925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->hdr.layer_specific = handle; 1935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(p_buf->bd_addr, bd_addr); 1945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->services = services; 1955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->sec_mask = sec_mask; 1965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_sendmsg(p_buf); 1975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function BTA_AgClose 2035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Close the current connection to a headset or a handsfree 2055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Any current audio connection will also be closed. 2065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 2095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid BTA_AgClose(UINT16 handle) 2125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf; 2145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) 2165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->event = BTA_AG_API_CLOSE_EVT; 2185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->layer_specific = handle; 2195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_sendmsg(p_buf); 2205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function BTA_AgAudioOpen 2265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Opens an audio connection to the currently connected 2285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** headset or hnadsfree. 2295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 2325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid BTA_AgAudioOpen(UINT16 handle) 2355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf; 2375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) 2395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->event = BTA_AG_API_AUDIO_OPEN_EVT; 2415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->layer_specific = handle; 2425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_sendmsg(p_buf); 2435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function BTA_AgAudioClose 2495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Close the currently active audio connection to a headset 2515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** or hnadsfree. The data connection remains open 2525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 2555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid BTA_AgAudioClose(UINT16 handle) 2585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf; 2605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) 2625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->event = BTA_AG_API_AUDIO_CLOSE_EVT; 2645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->layer_specific = handle; 2655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_sendmsg(p_buf); 2665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function BTA_AgResult 2735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Send an AT result code to a headset or hands-free device. 2755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** This function is only used when the AG parse mode is set 2765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** to BTA_AG_PARSE. 2775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 2805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid BTA_AgResult(UINT16 handle, tBTA_AG_RES result, tBTA_AG_RES_DATA *p_data) 2835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AG_API_RESULT *p_buf; 2855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (tBTA_AG_API_RESULT *) GKI_getbuf(sizeof(tBTA_AG_API_RESULT))) != NULL) 2875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->hdr.event = BTA_AG_API_RESULT_EVT; 2895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->hdr.layer_specific = handle; 2905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->result = result; 2915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_data) 2925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(&p_buf->data, p_data, sizeof(p_buf->data)); 2945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_sendmsg(p_buf); 2965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function BTA_AgSetCodec 3025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Specify the codec type to be used for the subsequent 3045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** audio connection. 3055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 3095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 3115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid BTA_AgSetCodec(UINT16 handle, tBTA_AG_PEER_CODEC codec) 3125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AG_API_SETCODEC *p_buf; 3145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (tBTA_AG_API_SETCODEC *) GKI_getbuf(sizeof(tBTA_AG_API_SETCODEC))) != NULL) 3165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->hdr.event = BTA_AG_API_SETCODEC_EVT; 3185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->hdr.layer_specific = handle; 3195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->codec = codec; 3205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_sendmsg(p_buf); 3215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 324