diff options
Diffstat (limited to 'btif/src/btif_config.c')
-rw-r--r-- | btif/src/btif_config.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/btif/src/btif_config.c b/btif/src/btif_config.c index dfd308e90..5fa6fbb40 100644 --- a/btif/src/btif_config.c +++ b/btif/src/btif_config.c @@ -27,9 +27,11 @@ #include "osi/include/alarm.h" #include "osi/include/allocator.h" #include "btcore/include/bdaddr.h" +#include "btif_common.h" #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" @@ -43,7 +45,7 @@ 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_cb(void *data); -static void btif_config_write(void); +static void btif_config_write(UINT16 event, char *p_param); static void btif_config_devcache_cleanup(void); // TODO(zachoverflow): Move these two functions out, because they are too specific for this file @@ -359,7 +361,10 @@ void btif_config_flush(void) { alarm_cancel(alarm_timer); - btif_config_write(); + btif_config_write(0, NULL); + pthread_mutex_lock(&lock); + config_flush(CONFIG_FILE_PATH); + pthread_mutex_unlock(&lock); } int btif_config_clear(void){ @@ -383,10 +388,13 @@ int btif_config_clear(void){ } static void timer_config_save_cb(UNUSED_ATTR void *data) { - btif_config_write(); + // 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(btif_config_write, 0, NULL, 0, NULL); } -static void btif_config_write(void) { +static void btif_config_write(UNUSED_ATTR UINT16 event, UNUSED_ATTR char *p_param) { assert(config != NULL); assert(alarm_timer != NULL); |