diff options
author | Srinu Jella <sjella@codeaurora.org> | 2015-11-12 17:31:41 +0530 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-12-18 02:25:37 -0800 |
commit | 23f46f8f92be22ca728fb487de8506722de14b67 (patch) | |
tree | cce85a467227349c126ace6f622dc4e69dab2212 | |
parent | cb2450e7e002a1383d594e02bd97058b6e96cf1b (diff) | |
download | android_system_bt-23f46f8f92be22ca728fb487de8506722de14b67.tar.gz android_system_bt-23f46f8f92be22ca728fb487de8506722de14b67.tar.bz2 android_system_bt-23f46f8f92be22ca728fb487de8506722de14b67.zip |
Bluetooth: Offload config save functionality to btif thread
- Offload config save functionality to btif thread from
timer thread as timer callback thread is critical in
a2dp playback case.
- If the timer callback thread is busy in config save due
to IO operations, it may lead to a2dp audio choppy.
CRs-Fixed: 937048
Change-Id: I5f185f3d610a581a734a2a7ae7f20b8a8a806e72
-rw-r--r-- | btif/src/btif_config.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/btif/src/btif_config.c b/btif/src/btif_config.c index 241c7710d..c94e449f8 100644 --- a/btif/src/btif_config.c +++ b/btif/src/btif_config.c @@ -30,6 +30,7 @@ #include "btif_config.h" #include "btif_config_transcode.h" #include "btif_util.h" +#include "btif_common.h" #include "osi/include/compat.h" #include "osi/include/config.h" #include "btcore/include/module.h" @@ -42,7 +43,8 @@ static const char *CONFIG_FILE_PATH = "/data/misc/bluedroid/bt_config.conf"; static const char *LEGACY_CONFIG_FILE_PATH = "/data/misc/bluedroid/bt_config.xml"; static const period_ms_t CONFIG_SETTLE_PERIOD_MS = 3000; -static void timer_config_save(void *data); +static void timer_config_saving(void* data); +static void timer_config_save(UINT16 event, char* p_param); // TODO(zachoverflow): Move these two functions out, because they are too specific for this file // {grumpy-cat/no, monty-python/you-make-me-sad} @@ -346,7 +348,7 @@ void btif_config_save(void) { assert(alarm_timer != NULL); assert(config != NULL); - alarm_set(alarm_timer, CONFIG_SETTLE_PERIOD_MS, timer_config_save, NULL); + alarm_set(alarm_timer, CONFIG_SETTLE_PERIOD_MS, timer_config_saving, NULL); } void btif_config_flush(void) { @@ -381,7 +383,14 @@ int btif_config_clear(void){ return ret; } -static void timer_config_save(UNUSED_ATTR void *data) { +static void timer_config_saving(UNUSED_ATTR void* data) { + // calling file IO onto btif context instead of timer callback because + // it usually takes lots of time to be completed timer callback has big + // delayed during a2dp playback causing blip or choppiness. + btif_transfer_context(timer_config_save, 0, NULL, 0, NULL); +} + +static void timer_config_save(UNUSED_ATTR UINT16 event, UNUSED_ATTR char* p_param) { assert(config != NULL); assert(alarm_timer != NULL); |