diff options
author | Christopher R. Palmer <crpalmer@gmail.com> | 2016-06-11 06:51:39 -0400 |
---|---|---|
committer | Christopher R. Palmer <crpalmer@gmail.com> | 2016-06-11 06:51:39 -0400 |
commit | 5365992252898f1653a2977ae89702c992d4858f (patch) | |
tree | eee12361a2ad41cc0f1c2eda83b986264377e77a | |
parent | c71852721a6c97c020c554639ddea0d0c5b7410c (diff) | |
download | android_system_bt-5365992252898f1653a2977ae89702c992d4858f.tar.gz android_system_bt-5365992252898f1653a2977ae89702c992d4858f.tar.bz2 android_system_bt-5365992252898f1653a2977ae89702c992d4858f.zip |
bt: Use the clock functions from libutils instead of clock_gettime
This uses the android wide best code for getting the current time.
Change-Id: Ie810a8ed7dd8045c437c27d608b97c2db2e7105d
-rw-r--r-- | audio_a2dp_hw/Android.mk | 2 | ||||
-rw-r--r-- | utils/include/bt_utils.h | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/audio_a2dp_hw/Android.mk b/audio_a2dp_hw/Android.mk index 39253bca8..6cec0cfd7 100644 --- a/audio_a2dp_hw/Android.mk +++ b/audio_a2dp_hw/Android.mk @@ -19,7 +19,7 @@ LOCAL_CFLAGS += -std=c99 $(bdroid_CFLAGS) LOCAL_MODULE := audio.a2dp.default LOCAL_MODULE_RELATIVE_PATH := hw -LOCAL_SHARED_LIBRARIES := libcutils liblog +LOCAL_SHARED_LIBRARIES := libcutils liblog libutils LOCAL_MODULE_TAGS := optional diff --git a/utils/include/bt_utils.h b/utils/include/bt_utils.h index 623b7da40..dd0d0462f 100644 --- a/utils/include/bt_utils.h +++ b/utils/include/bt_utils.h @@ -72,15 +72,30 @@ bool remove_iot_device(const char *filename, char* header, #define USEC_PER_SEC 1000000L +static inline uint64_t time_now_us(); + static inline void time_now_timespec(struct timespec *ts) { +#ifdef HAVE_ANDROID_OS + uint64_t now_us; + + now_us = time_now_us(); + ts->tv_sec = now_us / USEC_PER_SEC; + ts->tv_nsec = (now_us % USEC_PER_SEC) * 1000; +#else clock_gettime(CLOCK_BOOTTIME, ts); +#endif } static inline uint64_t time_now_us() { +#ifdef HAVE_ANDROID_OS + extern int64_t _ZN7android19elapsedRealtimeNanoEv(); + return (uint64_t) _ZN7android19elapsedRealtimeNanoEv() / 1000; +#else struct timespec ts_now; time_now_timespec(&ts_now); return ((uint64_t)ts_now.tv_sec * USEC_PER_SEC) + ((uint64_t)ts_now.tv_nsec / 1000); +#endif } #endif /* BT_UTILS_H */ |