summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMattias Agren <magren@broadcom.com>2014-10-09 01:16:12 +0200
committerAndre Eisenbach <eisenbach@google.com>2014-10-10 17:12:22 +0000
commitf061e74b81863771b174d1717a6165034dbad8e5 (patch)
treeca3bab459d814d89180c61905727756648ac0c4e
parentebc38ac1acf8629d5a641c4687dd97ff1cf768e0 (diff)
downloadbluedroid-f061e74b81863771b174d1717a6165034dbad8e5.tar.gz
Added missing A2DP priority on java alarm service
Running GKI timer engine via JAVA alarm service was causing severe timer preemption at times which affects A2DP media task timer. This in turn was stressing the compensation logic towards UIPC resulting in very bursty reads of up to 40 UIPC frames at a time. This led to instabilities on the UIPC pipe and trickled upwards in audio framework. Inclusion of java alarm thread in A2DP high priority thread list results in a much smoother data flow for entire A2DP data path and improved audio quality. Bug: 17520043 Change-Id: I7cea6ec64aa5b973b5fff767389a8827e681619e
-rw-r--r--btif/src/btif_media_task.c7
-rw-r--r--gki/ulinux/gki_ulinux.c1
-rw-r--r--utils/include/bt_utils.h1
3 files changed, 8 insertions, 1 deletions
diff --git a/btif/src/btif_media_task.c b/btif/src/btif_media_task.c
index 7338946..77399f4 100644
--- a/btif/src/btif_media_task.c
+++ b/btif/src/btif_media_task.c
@@ -209,7 +209,7 @@ static UINT32 a2dp_media_task_stack[(A2DP_MEDIA_TASK_STACK_SIZE + 3) / 4];
/* 18 frames is equivalent to 6.89*18*2.9 ~= 360 ms @ 44.1 khz, 20 ms mediatick */
#define MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ 18
#define A2DP_PACKET_COUNT_LOW_WATERMARK 5
-#define MAX_PCM_FRAME_NUM_PER_TICK 40
+#define MAX_PCM_FRAME_NUM_PER_TICK 20
#define RESET_RATE_COUNTER_THRESHOLD_MS 2000
//#define BTIF_MEDIA_VERBOSE_ENABLED
@@ -2481,6 +2481,11 @@ static UINT8 btif_get_num_aa_frame(void)
} else {
result = 0;
}
+
+ /* smooth out the compensation over time to minimize burstiness towards UIPC */
+ if (result > MAX_PCM_FRAME_NUM_PER_TICK)
+ result = MAX_PCM_FRAME_NUM_PER_TICK;
+
VERBOSE("WRITE %d FRAMES", result);
}
break;
diff --git a/gki/ulinux/gki_ulinux.c b/gki/ulinux/gki_ulinux.c
index 5747c08..0c22d23 100644
--- a/gki/ulinux/gki_ulinux.c
+++ b/gki/ulinux/gki_ulinux.c
@@ -170,6 +170,7 @@ static void alarm_service_init()
alarm_service.timer_started_us = 0;
alarm_service.timer_last_expired_us = 0;
alarm_service.wakelock = FALSE;
+ raise_priority_a2dp(TASK_JAVA_ALARM);
}
/** Requests an alarm from AlarmService to fire when the next
diff --git a/utils/include/bt_utils.h b/utils/include/bt_utils.h
index 47f0e30..f2bd2ed 100644
--- a/utils/include/bt_utils.h
+++ b/utils/include/bt_utils.h
@@ -30,6 +30,7 @@ typedef enum {
TASK_HIGH_HCI_WORKER,
TASK_HIGH_USERIAL_READ,
TASK_UIPC_READ,
+ TASK_JAVA_ALARM,
TASK_HIGH_MAX
} tHIGH_PRIORITY_TASK;