Loading system/hci/src/bt_hci_bdroid.c +5 −2 Original line number Diff line number Diff line Loading @@ -357,14 +357,17 @@ static int init(const bt_hc_callbacks_t* p_cb, unsigned char *local_bdaddr) ALOGW("init has been called repeatedly without calling cleanup ?"); } // Set prio here and let hci worker thread inherit prio // remove once new thread api (thread_set_priority() ?) // can switch prio raise_priority_a2dp(TASK_HIGH_HCI_WORKER); hc_cb.worker_thread = thread_new("bt_hc_worker"); if (!hc_cb.worker_thread) { ALOGE("%s unable to create worker thread.", __func__); return BT_HC_STATUS_FAIL; } // TODO(sharvil): increase thread priority (raise_priority_a2dp) return BT_HC_STATUS_SUCCESS; } Loading system/stack/btu/btu_task.c +3 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ #include "l2c_int.h" #include "btu.h" #include "bt_utils.h" #include <sys/prctl.h> #include "sdpint.h" Loading Loading @@ -221,6 +222,8 @@ BTU_API UINT32 btu_task (UINT32 param) /* Send a startup evt message to BTIF_TASK to kickstart the init procedure */ GKI_send_event(BTIF_TASK, BT_EVT_TRIGGER_STACK_INIT); prctl(PR_SET_NAME, (unsigned long)"BTU TASK", 0, 0, 0); raise_priority_a2dp(TASK_HIGH_BTU); /* Wait for, and process, events */ Loading system/udrv/ulinux/uipc.c +2 −0 Original line number Diff line number Diff line Loading @@ -480,6 +480,8 @@ static void uipc_read_task(void *arg) prctl(PR_SET_NAME, (unsigned long)"uipc-main", 0, 0, 0); raise_priority_a2dp(TASK_UIPC_READ); while (uipc_main.running) { uipc_main.read_set = uipc_main.active_set; Loading system/utils/include/bt_utils.h +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ typedef enum { TASK_HIGH_BTU, TASK_HIGH_HCI_WORKER, TASK_HIGH_USERIAL_READ, TASK_UIPC_READ, TASK_HIGH_MAX } tHIGH_PRIORITY_TASK; Loading system/utils/src/bt_utils.c +11 −3 Original line number Diff line number Diff line Loading @@ -120,6 +120,7 @@ static void check_do_scheduling_group(void) { void raise_priority_a2dp(tHIGH_PRIORITY_TASK high_task) { int rc = 0; int tid = gettid(); int priority = ANDROID_PRIORITY_AUDIO; pthread_mutex_lock(&gIdxLock); g_TaskIdx = high_task; Loading @@ -136,8 +137,15 @@ void raise_priority_a2dp(tHIGH_PRIORITY_TASK high_task) { ALOGW("failed to change sched policy, tid %d, err: %d", tid, errno); } if (setpriority(PRIO_PROCESS, tid, ANDROID_PRIORITY_AUDIO) < 0) { ALOGW("failed to change priority tid: %d to %d", tid, ANDROID_PRIORITY_AUDIO); // always use urgent priority for HCI worker thread until we can adjust // its prio individually. All other threads can be dynamically adjusted voa // adjust_priority_a2dp() if (high_task == TASK_HIGH_HCI_WORKER) priority = ANDROID_PRIORITY_URGENT_AUDIO; if (setpriority(PRIO_PROCESS, tid, priority) < 0) { ALOGW("failed to change priority tid: %d to %d", tid, priority); } } Loading @@ -157,7 +165,7 @@ void adjust_priority_a2dp(int start) { int tid; int i; for (i = TASK_HIGH_GKI_TIMER; i < TASK_HIGH_MAX; i++) for (i = 0; i < TASK_HIGH_MAX; i++) { tid = g_TaskIDs[i]; if (tid != INVALID_TASK_ID) Loading Loading
system/hci/src/bt_hci_bdroid.c +5 −2 Original line number Diff line number Diff line Loading @@ -357,14 +357,17 @@ static int init(const bt_hc_callbacks_t* p_cb, unsigned char *local_bdaddr) ALOGW("init has been called repeatedly without calling cleanup ?"); } // Set prio here and let hci worker thread inherit prio // remove once new thread api (thread_set_priority() ?) // can switch prio raise_priority_a2dp(TASK_HIGH_HCI_WORKER); hc_cb.worker_thread = thread_new("bt_hc_worker"); if (!hc_cb.worker_thread) { ALOGE("%s unable to create worker thread.", __func__); return BT_HC_STATUS_FAIL; } // TODO(sharvil): increase thread priority (raise_priority_a2dp) return BT_HC_STATUS_SUCCESS; } Loading
system/stack/btu/btu_task.c +3 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ #include "l2c_int.h" #include "btu.h" #include "bt_utils.h" #include <sys/prctl.h> #include "sdpint.h" Loading Loading @@ -221,6 +222,8 @@ BTU_API UINT32 btu_task (UINT32 param) /* Send a startup evt message to BTIF_TASK to kickstart the init procedure */ GKI_send_event(BTIF_TASK, BT_EVT_TRIGGER_STACK_INIT); prctl(PR_SET_NAME, (unsigned long)"BTU TASK", 0, 0, 0); raise_priority_a2dp(TASK_HIGH_BTU); /* Wait for, and process, events */ Loading
system/udrv/ulinux/uipc.c +2 −0 Original line number Diff line number Diff line Loading @@ -480,6 +480,8 @@ static void uipc_read_task(void *arg) prctl(PR_SET_NAME, (unsigned long)"uipc-main", 0, 0, 0); raise_priority_a2dp(TASK_UIPC_READ); while (uipc_main.running) { uipc_main.read_set = uipc_main.active_set; Loading
system/utils/include/bt_utils.h +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ typedef enum { TASK_HIGH_BTU, TASK_HIGH_HCI_WORKER, TASK_HIGH_USERIAL_READ, TASK_UIPC_READ, TASK_HIGH_MAX } tHIGH_PRIORITY_TASK; Loading
system/utils/src/bt_utils.c +11 −3 Original line number Diff line number Diff line Loading @@ -120,6 +120,7 @@ static void check_do_scheduling_group(void) { void raise_priority_a2dp(tHIGH_PRIORITY_TASK high_task) { int rc = 0; int tid = gettid(); int priority = ANDROID_PRIORITY_AUDIO; pthread_mutex_lock(&gIdxLock); g_TaskIdx = high_task; Loading @@ -136,8 +137,15 @@ void raise_priority_a2dp(tHIGH_PRIORITY_TASK high_task) { ALOGW("failed to change sched policy, tid %d, err: %d", tid, errno); } if (setpriority(PRIO_PROCESS, tid, ANDROID_PRIORITY_AUDIO) < 0) { ALOGW("failed to change priority tid: %d to %d", tid, ANDROID_PRIORITY_AUDIO); // always use urgent priority for HCI worker thread until we can adjust // its prio individually. All other threads can be dynamically adjusted voa // adjust_priority_a2dp() if (high_task == TASK_HIGH_HCI_WORKER) priority = ANDROID_PRIORITY_URGENT_AUDIO; if (setpriority(PRIO_PROCESS, tid, priority) < 0) { ALOGW("failed to change priority tid: %d to %d", tid, priority); } } Loading @@ -157,7 +165,7 @@ void adjust_priority_a2dp(int start) { int tid; int i; for (i = TASK_HIGH_GKI_TIMER; i < TASK_HIGH_MAX; i++) for (i = 0; i < TASK_HIGH_MAX; i++) { tid = g_TaskIDs[i]; if (tid != INVALID_TASK_ID) Loading