* Ensure all a2dp audiopath threads are configured to high
priority when actively streaming.
* For now set bt hc worker thread always to URGENT_AUDIO
until new thread api can adjust thread priority dynamically.
Bug:
17520043
Change-Id: I10e314085329278bcfcc4e8bc5ce899b03d22e2b
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;
}
#include "l2c_int.h"
#include "btu.h"
#include "bt_utils.h"
+#include <sys/prctl.h>
#include "sdpint.h"
/* 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 */
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;
TASK_HIGH_BTU,
TASK_HIGH_HCI_WORKER,
TASK_HIGH_USERIAL_READ,
+ TASK_UIPC_READ,
TASK_HIGH_MAX
} tHIGH_PRIORITY_TASK;
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;
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);
}
}
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)