Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b508bf8 authored by Andre Eisenbach's avatar Andre Eisenbach Committed by Android (Google) Code Review
Browse files

Merge "Raise A2DP threat priority to avoid music breaks" into lmp-dev

parents cfbef47a dc12c061
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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;
}

+3 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include "l2c_int.h"
#include "btu.h"
#include "bt_utils.h"
#include <sys/prctl.h>

#include "sdpint.h"

@@ -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 */
+2 −0
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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;

+11 −3
Original line number Diff line number Diff line
@@ -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;
@@ -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);
    }
}

@@ -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)