OSDN Git Service

am 4927e67f: am 3576c564: Fix compiler/linker errors when BTA_PAN_INCLUDED is FALSE
authorMike J. Chen <mjchen@google.com>
Wed, 2 Apr 2014 01:09:07 +0000 (01:09 +0000)
committerAndroid Git Automerger <android-git-automerger@android.com>
Wed, 2 Apr 2014 01:09:07 +0000 (01:09 +0000)
* commit '4927e67fb8cd3cd09b2607241c3da875f85ed852':
  Fix compiler/linker errors when BTA_PAN_INCLUDED is FALSE

audio_a2dp_hw/audio_a2dp_hw.c
bta/gatt/bta_gattc_act.c
btif/src/btif_av.c
gki/ulinux/gki_ulinux.c
include/bt_target.h
main/bte_main.c
stack/btm/btm_ble_gap.c
stack/sdp/sdp_server.c
utils/include/bt_utils.h
utils/src/bt_utils.c

index 2fee588..607de34 100644 (file)
@@ -583,7 +583,8 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
     struct a2dp_stream_out *out = (struct a2dp_stream_out *)stream;
     struct str_parms *parms;
     char keyval[16];
-    int retval = 0;
+    int retval;
+    int status = 0;
 
     INFO("state %d", out->state);
 
@@ -612,7 +613,7 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
         if (strcmp(keyval, "true") == 0)
         {
             if (out->state == AUDIO_A2DP_STATE_STARTED)
-                retval = suspend_audio_datapath(out, false);
+                status = suspend_audio_datapath(out, false);
         }
         else
         {
@@ -622,14 +623,13 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
             if (out->state == AUDIO_A2DP_STATE_SUSPENDED)
                 out->state = AUDIO_A2DP_STATE_STANDBY;
             /* Irrespective of the state, return 0 */
-            retval = 0;
         }
     }
 
     pthread_mutex_unlock(&out->lock);
     str_parms_destroy(parms);
 
-    return retval;
+    return status;
 }
 
 static char * out_get_parameters(const struct audio_stream *stream, const char *keys)
@@ -1146,7 +1146,7 @@ static int adev_open(const hw_module_t* module, const char* name,
         return -ENOMEM;
 
     adev->device.common.tag = HARDWARE_DEVICE_TAG;
-    adev->device.common.version = AUDIO_DEVICE_API_VERSION_CURRENT;
+    adev->device.common.version = AUDIO_DEVICE_API_VERSION_2_0;
     adev->device.common.module = (struct hw_module_t *) module;
     adev->device.common.close = adev_close;
 
index 44f88e4..00e486f 100644 (file)
@@ -786,7 +786,13 @@ void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
     bta_gattc_clcb_dealloc(p_clcb);
 
     if (p_data->hdr.event == BTA_GATTC_API_CLOSE_EVT)
+    {
         cb_data.close.status = GATT_Disconnect(p_data->hdr.layer_specific);
+    }
+    else if (p_data->hdr.event == BTA_GATTC_INT_DISCONN_EVT)
+    {
+        cb_data.close.status = p_data->int_conn.reason;
+    }
 
     if(p_cback)
         (* p_cback)(BTA_GATTC_CLOSE_EVT,   (tBTA_GATTC *)&cb_data);
@@ -2238,7 +2244,7 @@ void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg)
 {
     tBTA_GATTC_RCB      *p_clreg = bta_gattc_cl_get_regcb(p_msg->api_listen.client_if);
     tBTA_GATTC          cb_data;
-    (void)(p_cb);
+    UNUSED(p_cb);
 
     cb_data.reg_oper.client_if = p_msg->api_listen.client_if;
     cb_data.reg_oper.status = BTM_BleBroadcast(p_msg->api_listen.start);
index 3c0c293..f893c9e 100755 (executable)
@@ -39,6 +39,7 @@
 #include "gki.h"
 #include "bd.h"
 #include "btu.h"
+#include "bt_utils.h"
 
 /*****************************************************************************
 **  Constants & Macros
@@ -587,9 +588,17 @@ static BOOLEAN btif_av_state_started_handler(btif_sm_event_t event, void *p_data
 
             HAL_CBACK(bt_av_callbacks, audio_state_cb,
                 BTAV_AUDIO_STATE_STARTED, &(btif_av_cb.peer_bda));
+
+            /* increase the a2dp consumer task priority temporarily when start
+            ** audio playing, to avoid overflow the audio packet queue. */
+            adjust_priority_a2dp(TRUE);
+
             break;
 
         case BTIF_SM_EXIT_EVT:
+            /* restore the a2dp consumer task priority when stop audio playing. */
+            adjust_priority_a2dp(FALSE);
+
             break;
 
         case BTIF_AV_START_STREAM_REQ_EVT:
index d03eb05..e6f45f4 100755 (executable)
@@ -97,8 +97,6 @@ static int                  shutdown_timer = 0;
 **  Local type definitions
 ******************************************************************************/
 
-#define pthread_cond_timedwait_monotonic pthread_cond_timedwait
-
 typedef struct
 {
     UINT8 task_id;          /* GKI task id */
@@ -266,8 +264,12 @@ UINT8 GKI_create_task (TASKPTR task_entry, UINT8 task_id, INT8 *taskname, UINT16
     gki_cb.com.OSWaitEvt[task_id]   = 0;
 
     /* Initialize mutex and condition variable objects for events and timeouts */
+    pthread_condattr_t cond_attr;
+    pthread_condattr_init(&cond_attr);
+    pthread_condattr_setclock(&cond_attr, CLOCK_MONOTONIC);
+
     pthread_mutex_init(&gki_cb.os.thread_evt_mutex[task_id], NULL);
-    pthread_cond_init (&gki_cb.os.thread_evt_cond[task_id], NULL);
+    pthread_cond_init (&gki_cb.os.thread_evt_cond[task_id], &cond_attr);
     pthread_mutex_init(&gki_cb.os.thread_timeout_mutex[task_id], NULL);
     pthread_cond_init (&gki_cb.os.thread_timeout_cond[task_id], NULL);
 
@@ -944,9 +946,8 @@ UINT16 GKI_wait (UINT16 flag, UINT32 timeout)
             }
             abstime.tv_sec += sec;
 
-            pthread_cond_timedwait_monotonic(&gki_cb.os.thread_evt_cond[rtask],
+            pthread_cond_timedwait(&gki_cb.os.thread_evt_cond[rtask],
                     &gki_cb.os.thread_evt_mutex[rtask], &abstime);
-
         }
         else
         {
index 48f226c..799ee3a 100644 (file)
@@ -1603,7 +1603,7 @@ and USER_HW_DISABLE_API macros */
 
 /* The MTU size for the L2CAP configuration. */
 #ifndef SDP_MTU_SIZE
-#define SDP_MTU_SIZE                256
+#define SDP_MTU_SIZE                672
 #endif
 
 /* The flush timeout for the L2CAP configuration. */
index cf21456..b9cbf91 100644 (file)
@@ -198,12 +198,12 @@ void bte_main_enable()
 
     lpm_enabled = FALSE;
 
-    bte_hci_enable();
-
     GKI_create_task((TASKPTR)btu_task, BTU_TASK, BTE_BTU_TASK_STR,
                     (UINT16 *) ((UINT8 *)bte_btu_stack + BTE_BTU_STACK_SIZE),
                     sizeof(bte_btu_stack));
 
+    bte_hci_enable();
+
     GKI_run(0);
 }
 
index 54f1b55..608fa7e 100644 (file)
@@ -1215,6 +1215,10 @@ void btm_ble_read_remote_name_cmpl(BOOLEAN status, BD_ADDR bda, UINT16 length, c
     BD_NAME bd_name;
 
     memset(bd_name, 0, (BD_NAME_LEN + 1));
+    if (length > BD_NAME_LEN)
+    {
+        length = BD_NAME_LEN;
+    }
     memcpy((UINT8*)bd_name, p_name, length);
 
     if ((!status) || (length==0))
index 5d11cb4..84dd957 100644 (file)
@@ -380,8 +380,14 @@ static void process_service_attr_req (tCONN_CB *p_ccb, UINT16 trans_num,
     else
     {
         /* Get a scratch buffer to store response */
-        if (!p_ccb->rsp_list)
+        if (!p_ccb->rsp_list || (GKI_get_buf_size(p_ccb->rsp_list) < max_list_len))
         {
+            /* Free and reallocate if the earlier allocated buffer is small */
+            if (p_ccb->rsp_list)
+            {
+                GKI_freebuf (p_ccb->rsp_list);
+            }
+
             p_ccb->rsp_list = (UINT8 *)GKI_getbuf (max_list_len);
             if (p_ccb->rsp_list == NULL)
             {
@@ -624,8 +630,14 @@ static void process_service_search_attr_req (tCONN_CB *p_ccb, UINT16 trans_num,
     else
     {
         /* Get a scratch buffer to store response */
-        if (!p_ccb->rsp_list)
+        if (!p_ccb->rsp_list || (GKI_get_buf_size(p_ccb->rsp_list) < max_list_len))
         {
+            /* Free and reallocate if the earlier allocated buffer is small */
+            if (p_ccb->rsp_list)
+            {
+                GKI_freebuf (p_ccb->rsp_list);
+            }
+
             p_ccb->rsp_list = (UINT8 *)GKI_getbuf (max_list_len);
             if (p_ccb->rsp_list == NULL)
             {
index d601f2e..ee21861 100644 (file)
@@ -39,6 +39,7 @@ typedef enum {
 void bt_utils_init();
 void bt_utils_cleanup();
 void raise_priority_a2dp(tHIGH_PRIORITY_TASK high_task);
+void adjust_priority_a2dp(int start);
 
 #define UNUSED(x) (void)(x)
 
index aeb9292..6decacf 100644 (file)
@@ -50,6 +50,8 @@ static pthread_once_t g_DoSchedulingGroupOnce[TASK_HIGH_MAX];
 static BOOLEAN g_DoSchedulingGroup[TASK_HIGH_MAX];
 static pthread_mutex_t         gIdxLock;
 static int g_TaskIdx;
+static int g_TaskIDs[TASK_HIGH_MAX];
+#define INVALID_TASK_ID  (-1)
 
 /*****************************************************************************
 **
@@ -67,6 +69,7 @@ void bt_utils_init() {
     for(i = 0; i < TASK_HIGH_MAX; i++) {
         g_DoSchedulingGroupOnce[i] = PTHREAD_ONCE_INIT;
         g_DoSchedulingGroup[i] = TRUE;
+        g_TaskIDs[i] = INVALID_TASK_ID;
     }
     pthread_mutexattr_init(&lock_attr);
     pthread_mutex_init(&gIdxLock, &lock_attr);
@@ -126,6 +129,7 @@ void raise_priority_a2dp(tHIGH_PRIORITY_TASK high_task) {
         // set_sched_policy does not support tid == 0
         rc = set_sched_policy(tid, SP_FOREGROUND);
     }
+    g_TaskIDs[high_task] = tid;
     pthread_mutex_unlock(&gIdxLock);
 
     if (rc) {
@@ -137,3 +141,31 @@ void raise_priority_a2dp(tHIGH_PRIORITY_TASK high_task) {
     }
 }
 
+/*****************************************************************************
+**
+** Function        adjust_priority_a2dp
+**
+** Description     increase the a2dp consumer task priority temporarily when start
+**                 audio playing, to avoid overflow the audio packet queue, restore
+**                 the a2dp consumer task priority when stop audio playing.
+**
+** Returns         void
+**
+*******************************************************************************/
+void adjust_priority_a2dp(int start) {
+    int priority = start ? ANDROID_PRIORITY_URGENT_AUDIO : ANDROID_PRIORITY_AUDIO;
+    int tid;
+    int i;
+
+    for (i = TASK_HIGH_GKI_TIMER; i < TASK_HIGH_MAX; i++)
+    {
+        tid = g_TaskIDs[i];
+        if (tid != INVALID_TASK_ID)
+        {
+            if (setpriority(PRIO_PROCESS, tid, priority) < 0)
+            {
+                ALOGW("failed to change priority tid: %d to %d", tid, priority);
+            }
+        }
+    }
+}