diff --git a/system/bta/dm/bta_dm_pm.cc b/system/bta/dm/bta_dm_pm.cc index 03b1801a19711df4924308406a6205a84a6d6a5c..20ccaef07244dda187eba102f1523503c0d5ac8a 100644 --- a/system/bta/dm/bta_dm_pm.cc +++ b/system/bta/dm/bta_dm_pm.cc @@ -273,7 +273,7 @@ static void bta_dm_pm_stop_timer_by_srvc_id(const RawAddress& peer_addr, * ******************************************************************************/ static void bta_dm_pm_start_timer(tBTA_PM_TIMER* p_timer, uint8_t timer_idx, - period_ms_t timeout_ms, uint8_t srvc_id, + uint64_t timeout_ms, uint8_t srvc_id, uint8_t pm_action) { std::unique_lock<std::recursive_mutex> schedule_lock(pm_timer_schedule_mutex); std::unique_lock<std::recursive_mutex> state_lock(pm_timer_state_mutex); @@ -501,7 +501,7 @@ static void bta_dm_pm_set_mode(const RawAddress& peer_addr, tBTA_DM_PM_ACTION pm_request, tBTA_DM_PM_REQ pm_req) { tBTA_DM_PM_ACTION pm_action = BTA_DM_PM_NO_ACTION; - period_ms_t timeout_ms = 0; + uint64_t timeout_ms = 0; uint8_t i, j; tBTA_DM_PM_ACTION failed_pm = 0; tBTA_DM_PEER_DEVICE* p_peer_device = NULL; @@ -514,7 +514,7 @@ static void bta_dm_pm_set_mode(const RawAddress& peer_addr, tBTA_DM_SRVCS* p_srvcs = NULL; bool timer_started = false; uint8_t timer_idx, available_timer = BTA_DM_PM_MODE_TIMER_MAX; - period_ms_t remaining_ms = 0; + uint64_t remaining_ms = 0; if (!bta_dm_cb.device_list.count) return; diff --git a/system/bta/sys/bta_sys.h b/system/bta/sys/bta_sys.h index ff1d0626570442c94409279225ddfedf873d24b9..29e9a3fda4e6e958723ac6683609c13c96a2b4b2 100644 --- a/system/bta/sys/bta_sys.h +++ b/system/bta/sys/bta_sys.h @@ -222,7 +222,7 @@ extern void bta_sys_deregister(uint8_t id); extern bool bta_sys_is_register(uint8_t id); extern uint16_t bta_sys_get_sys_features(void); extern void bta_sys_sendmsg(void* p_msg); -extern void bta_sys_start_timer(alarm_t* alarm, period_ms_t interval, +extern void bta_sys_start_timer(alarm_t* alarm, uint64_t interval_ms, uint16_t event, uint16_t layer_specific); extern void bta_sys_disable(tBTA_SYS_HW_MODULE module); diff --git a/system/bta/sys/bta_sys_main.cc b/system/bta/sys/bta_sys_main.cc index 7088214432fa3be8d0e50b129122de469e48b101..3f687535f0e0db3345453979b66b0b257c6bfb7b 100644 --- a/system/bta/sys/bta_sys_main.cc +++ b/system/bta/sys/bta_sys_main.cc @@ -546,14 +546,14 @@ void bta_sys_sendmsg(void* p_msg) { * Returns void * ******************************************************************************/ -void bta_sys_start_timer(alarm_t* alarm, period_ms_t interval, uint16_t event, +void bta_sys_start_timer(alarm_t* alarm, uint64_t interval_ms, uint16_t event, uint16_t layer_specific) { BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); p_buf->event = event; p_buf->layer_specific = layer_specific; - alarm_set_on_mloop(alarm, interval, bta_sys_sendmsg, p_buf); + alarm_set_on_mloop(alarm, interval_ms, bta_sys_sendmsg, p_buf); } /******************************************************************************* diff --git a/system/btif/src/btif_a2dp_source.cc b/system/btif/src/btif_a2dp_source.cc index a385c6a531427a70398ed5168edf77d004f48552..4fc8d0ff950c4dfd98a062a58e5643d81123cf89 100644 --- a/system/btif/src/btif_a2dp_source.cc +++ b/system/btif/src/btif_a2dp_source.cc @@ -212,7 +212,7 @@ class BtifA2dpSource { bool tx_flush; /* Discards any outgoing data when true */ alarm_t* media_alarm; const tA2DP_ENCODER_INTERFACE* encoder_interface; - period_ms_t encoder_interval_ms; /* Local copy of the encoder interval */ + uint64_t encoder_interval_ms; /* Local copy of the encoder interval */ BtifMediaStats stats; BtifMediaStats accumulated_stats; diff --git a/system/btif/src/btif_av.cc b/system/btif/src/btif_av.cc index 92abb220b422514e511af09c708a6b4998b386eb..4795d1964a28a9d80594b783cf30c0453af01c39 100644 --- a/system/btif/src/btif_av.cc +++ b/system/btif/src/btif_av.cc @@ -218,7 +218,7 @@ class BtifAvPeer { kFlagPendingStart = 0x4, kFlagPendingStop = 0x8, }; - static constexpr period_ms_t kTimeoutAvOpenOnRcMs = 2 * 1000; // 2s + static constexpr uint64_t kTimeoutAvOpenOnRcMs = 2 * 1000; // 2s BtifAvPeer(const RawAddress& peer_address, uint8_t peer_sep, tBTA_AV_HNDL bta_handle, uint8_t peer_id); diff --git a/system/btif/src/btif_config.cc b/system/btif/src/btif_config.cc index 3155dc663da6acf681d44cb432dccc9ade370ea7..35a80d8015d77af357b600785770b470e9ddced8 100644 --- a/system/btif/src/btif_config.cc +++ b/system/btif/src/btif_config.cc @@ -63,7 +63,7 @@ static const char* CONFIG_BACKUP_PATH = "/data/misc/bluedroid/bt_config.bak"; static const char* CONFIG_LEGACY_FILE_PATH = "/data/misc/bluedroid/bt_config.xml"; #endif // defined(OS_GENERIC) -static const period_ms_t CONFIG_SETTLE_PERIOD_MS = 3000; +static const uint64_t CONFIG_SETTLE_PERIOD_MS = 3000; static void timer_config_save_cb(void* data); static void btif_config_write(uint16_t event, char* p_param); diff --git a/system/btif/src/btif_rc.cc b/system/btif/src/btif_rc.cc index d49cded5eaa76f20f7a326ddc8f2e145fa3b3de1..529f2cd3be198f7b21027e806df8a3c12ce84263 100644 --- a/system/btif/src/btif_rc.cc +++ b/system/btif/src/btif_rc.cc @@ -216,7 +216,7 @@ typedef struct { uint8_t handle; } btif_rc_handle_t; rc_device_t device; -static void sleep_ms(period_ms_t timeout_ms); +static void sleep_ms(uint64_t timeout_ms); /* Response status code - Unknown Error - this is changed to "reserved" */ #define BTIF_STS_GEN_ERROR 0x06 @@ -5345,7 +5345,7 @@ void release_transaction(uint8_t lbl) { * * Returns void ******************************************************************************/ -static void sleep_ms(period_ms_t timeout_ms) { +static void sleep_ms(uint64_t timeout_ms) { struct timespec delay; delay.tv_sec = timeout_ms / 1000; delay.tv_nsec = 1000 * 1000 * (timeout_ms % 1000); diff --git a/system/hci/src/hci_layer.cc b/system/hci/src/hci_layer.cc index 00348c2c901435b9ee91840b46f219b890376f54..6ffd58cd962d81b4e3d00fe289627380f9df7cfe 100644 --- a/system/hci/src/hci_layer.cc +++ b/system/hci/src/hci_layer.cc @@ -171,7 +171,7 @@ static future_t* hci_module_start_up(void) { command_credits = 1; // For now, always use the default timeout on non-Android builds. - period_ms_t startup_timeout_ms = DEFAULT_STARTUP_TIMEOUT_MS; + uint64_t startup_timeout_ms = DEFAULT_STARTUP_TIMEOUT_MS; // Grab the override startup timeout ms, if present. char timeout_prop[PROPERTY_VALUE_MAX]; diff --git a/system/osi/include/alarm.h b/system/osi/include/alarm.h index b7395cab0c5b8c1d5c786c1b22a99fba3fed40c3..2d07b9aeb697f1a97e9e9afa067b65970ca6644f 100644 --- a/system/osi/include/alarm.h +++ b/system/osi/include/alarm.h @@ -71,13 +71,13 @@ void alarm_free(alarm_t* alarm); // thread is not same as the caller’s thread. If two (or more) // alarms are set back-to-back with the same |interval_ms|, the // callbacks will be called in the order the alarms are set. -void alarm_set(alarm_t* alarm, period_ms_t interval_ms, alarm_callback_t cb, +void alarm_set(alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb, void* data); // Sets an |alarm| to execute a callback in the main message loop. This function // is same as |alarm_set| except that the |cb| callback is scheduled for // execution in the context of the main message loop. -void alarm_set_on_mloop(alarm_t* alarm, period_ms_t interval_ms, +void alarm_set_on_mloop(alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb, void* data); // This function cancels the |alarm| if it was previously set. @@ -94,7 +94,7 @@ bool alarm_is_scheduled(const alarm_t* alarm); // Figure out how much time until next expiration. // Returns 0 if not armed. |alarm| may not be NULL. // TODO: Remove this function once PM timers can be re-factored -period_ms_t alarm_get_remaining_ms(const alarm_t* alarm); +uint64_t alarm_get_remaining_ms(const alarm_t* alarm); // Cleanup the alarm internal state. // This function should be called by the OSI module cleanup during diff --git a/system/osi/include/time.h b/system/osi/include/time.h index 8f533d0128fe8a7e3d8f9cc631fa35ad97f2f45c..f3f233c6aa1ce64db09ca5c2b51f1dbcb61d1aeb 100644 --- a/system/osi/include/time.h +++ b/system/osi/include/time.h @@ -20,8 +20,6 @@ #include <stdint.h> -typedef uint64_t period_ms_t; - // Get the OS boot time in milliseconds. // // NOTE: The return value will rollover every 49.7 days, @@ -30,7 +28,7 @@ typedef uint64_t period_ms_t; // as (t2_u32 - t1_u32 < delta_u32) should work as expected as long // as there is no multiple rollover between t2_u32 and t1_u32. // -// TODO: This function's return type should be modified to |period_ms_t|. +// TODO: This function's return type should be modified to |uint64_t|. // Be careful: some of the code that is using it assumes the return type // is uint32_t. uint32_t time_get_os_boottime_ms(void); diff --git a/system/osi/src/alarm.cc b/system/osi/src/alarm.cc index 83a661df7a8ccfbe9e2e46334ed929754251a22c..25b14580a24b364109c875e4a0140ad2d8ba0c16 100644 --- a/system/osi/src/alarm.cc +++ b/system/osi/src/alarm.cc @@ -59,8 +59,8 @@ static const int THREAD_RT_PRIORITY = 1; typedef struct { size_t count; - period_ms_t total_ms; - period_ms_t max_ms; + uint64_t total_ms; + uint64_t max_ms; } stat_t; // Alarm-related information and statistics @@ -70,7 +70,7 @@ typedef struct { size_t canceled_count; size_t rescheduled_count; size_t total_updates; - period_ms_t last_update_ms; + uint64_t last_update_ms; stat_t overdue_scheduling; stat_t premature_scheduling; } alarm_stats_t; @@ -93,10 +93,10 @@ struct alarm_t { // mutex to provide a guarantee to its caller that the callback will not be // in progress when it returns. std::recursive_mutex* callback_mutex; - period_ms_t creation_time; - period_ms_t period; - period_ms_t deadline; - period_ms_t prev_deadline; // Previous deadline - used for accounting of + uint64_t creation_time_ms; + uint64_t period_ms; + uint64_t deadline_ms; + uint64_t prev_deadline_ms; // Previous deadline - used for accounting of // periodic timers bool is_periodic; fixed_queue_t* queue; // The processing queue to add this alarm to @@ -141,8 +141,8 @@ static fixed_queue_t* default_callback_queue; static alarm_t* alarm_new_internal(const char* name, bool is_periodic); static bool lazy_initialize(void); -static period_ms_t now(void); -static void alarm_set_internal(alarm_t* alarm, period_ms_t period, +static uint64_t now_ms(void); +static void alarm_set_internal(alarm_t* alarm, uint64_t period_ms, alarm_callback_t cb, void* data, fixed_queue_t* queue, bool for_msg_loop); static void alarm_cancel_internal(alarm_t* alarm); @@ -153,16 +153,16 @@ static void alarm_queue_ready(fixed_queue_t* queue, void* context); static void timer_callback(void* data); static void callback_dispatch(void* context); static bool timer_create_internal(const clockid_t clock_id, timer_t* timer); -static void update_scheduling_stats(alarm_stats_t* stats, period_ms_t now_ms, - period_ms_t deadline_ms); +static void update_scheduling_stats(alarm_stats_t* stats, uint64_t now_ms, + uint64_t deadline_ms); // Registers |queue| for processing alarm callbacks on |thread|. // |queue| may not be NULL. |thread| may not be NULL. static void alarm_register_processing_queue(fixed_queue_t* queue, thread_t* thread); -static void update_stat(stat_t* stat, period_ms_t delta) { - if (stat->max_ms < delta) stat->max_ms = delta; - stat->total_ms += delta; +static void update_stat(stat_t* stat, uint64_t delta_ms) { + if (stat->max_ms < delta_ms) stat->max_ms = delta_ms; + stat->total_ms += delta_ms; stat->count++; } @@ -204,30 +204,31 @@ void alarm_free(alarm_t* alarm) { osi_free(alarm); } -period_ms_t alarm_get_remaining_ms(const alarm_t* alarm) { +uint64_t alarm_get_remaining_ms(const alarm_t* alarm) { CHECK(alarm != NULL); - period_ms_t remaining_ms = 0; - period_ms_t just_now = now(); + uint64_t remaining_ms = 0; + uint64_t just_now_ms = now_ms(); std::lock_guard<std::mutex> lock(alarms_mutex); - if (alarm->deadline > just_now) remaining_ms = alarm->deadline - just_now; + if (alarm->deadline_ms > just_now_ms) + remaining_ms = alarm->deadline_ms - just_now_ms; return remaining_ms; } -void alarm_set(alarm_t* alarm, period_ms_t interval_ms, alarm_callback_t cb, +void alarm_set(alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb, void* data) { alarm_set_internal(alarm, interval_ms, cb, data, default_callback_queue, false); } -void alarm_set_on_mloop(alarm_t* alarm, period_ms_t interval_ms, +void alarm_set_on_mloop(alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb, void* data) { alarm_set_internal(alarm, interval_ms, cb, data, NULL, true); } // Runs in exclusion with alarm_cancel and timer_callback. -static void alarm_set_internal(alarm_t* alarm, period_ms_t period, +static void alarm_set_internal(alarm_t* alarm, uint64_t period_ms, alarm_callback_t cb, void* data, fixed_queue_t* queue, bool for_msg_loop) { CHECK(alarms != NULL); @@ -236,8 +237,8 @@ static void alarm_set_internal(alarm_t* alarm, period_ms_t period, std::lock_guard<std::mutex> lock(alarms_mutex); - alarm->creation_time = now(); - alarm->period = period; + alarm->creation_time_ms = now_ms(); + alarm->period_ms = period_ms; alarm->queue = queue; alarm->callback = cb; alarm->data = data; @@ -268,8 +269,8 @@ static void alarm_cancel_internal(alarm_t* alarm) { remove_pending_alarm(alarm); - alarm->deadline = 0; - alarm->prev_deadline = 0; + alarm->deadline_ms = 0; + alarm->prev_deadline_ms = 0; alarm->callback = NULL; alarm->data = NULL; alarm->stats.canceled_count++; @@ -387,7 +388,7 @@ error: return false; } -static period_ms_t now(void) { +static uint64_t now_ms(void) { CHECK(alarms != NULL); struct timespec ts; @@ -425,22 +426,23 @@ static void schedule_next_instance(alarm_t* alarm) { if (alarm->callback) remove_pending_alarm(alarm); // Calculate the next deadline for this alarm - period_ms_t just_now = now(); - period_ms_t ms_into_period = 0; - if ((alarm->is_periodic) && (alarm->period != 0)) - ms_into_period = ((just_now - alarm->creation_time) % alarm->period); - alarm->deadline = just_now + (alarm->period - ms_into_period); + uint64_t just_now_ms = now_ms(); + uint64_t ms_into_period = 0; + if ((alarm->is_periodic) && (alarm->period_ms != 0)) + ms_into_period = + ((just_now_ms - alarm->creation_time_ms) % alarm->period_ms); + alarm->deadline_ms = just_now_ms + (alarm->period_ms - ms_into_period); // Add it into the timer list sorted by deadline (earliest deadline first). if (list_is_empty(alarms) || - ((alarm_t*)list_front(alarms))->deadline > alarm->deadline) { + ((alarm_t*)list_front(alarms))->deadline_ms > alarm->deadline_ms) { list_prepend(alarms, alarm); } else { for (list_node_t* node = list_begin(alarms); node != list_end(alarms); node = list_next(node)) { list_node_t* next = list_next(node); if (next == list_end(alarms) || - ((alarm_t*)list_node(next))->deadline > alarm->deadline) { + ((alarm_t*)list_node(next))->deadline_ms > alarm->deadline_ms) { list_insert_after(alarms, node, alarm); break; } @@ -470,7 +472,7 @@ static void reschedule_root_alarm(void) { if (list_is_empty(alarms)) goto done; next = static_cast<alarm_t*>(list_front(alarms)); - next_expiration = next->deadline - now(); + next_expiration = next->deadline_ms - now_ms(); if (next_expiration < TIMER_INTERVAL_FOR_WAKELOCK_IN_MS) { if (!timer_set) { if (!wakelock_acquire()) { @@ -479,8 +481,8 @@ static void reschedule_root_alarm(void) { } } - timer_time.it_value.tv_sec = (next->deadline / 1000); - timer_time.it_value.tv_nsec = (next->deadline % 1000) * 1000000LL; + timer_time.it_value.tv_sec = (next->deadline_ms / 1000); + timer_time.it_value.tv_nsec = (next->deadline_ms % 1000) * 1000000LL; // It is entirely unsafe to call timer_settime(2) with a zeroed timerspec // for timers with *_ALARM clock IDs. Although the man page states that the @@ -505,8 +507,8 @@ static void reschedule_root_alarm(void) { struct itimerspec wakeup_time; memset(&wakeup_time, 0, sizeof(wakeup_time)); - wakeup_time.it_value.tv_sec = (next->deadline / 1000); - wakeup_time.it_value.tv_nsec = (next->deadline % 1000) * 1000000LL; + wakeup_time.it_value.tv_sec = (next->deadline_ms / 1000); + wakeup_time.it_value.tv_nsec = (next->deadline_ms % 1000) * 1000000LL; if (timer_settime(wakeup_timer, TIMER_ABSTIME, &wakeup_time, NULL) == -1) LOG_ERROR(LOG_TAG, "%s unable to set wakeup timer: %s", __func__, strerror(errno)); @@ -567,13 +569,13 @@ static void alarm_ready_generic(alarm_t* alarm, // alarm_callback_t callback = alarm->callback; void* data = alarm->data; - period_ms_t deadline = alarm->deadline; + uint64_t deadline_ms = alarm->deadline_ms; if (alarm->is_periodic) { // The periodic alarm has been rescheduled and alarm->deadline has been // updated, hence we need to use the previous deadline. - deadline = alarm->prev_deadline; + deadline_ms = alarm->prev_deadline_ms; } else { - alarm->deadline = 0; + alarm->deadline_ms = 0; alarm->callback = NULL; alarm->data = NULL; alarm->queue = NULL; @@ -583,7 +585,7 @@ static void alarm_ready_generic(alarm_t* alarm, lock.unlock(); // Update the statistics - update_scheduling_stats(&alarm->stats, now(), deadline); + update_scheduling_stats(&alarm->stats, now_ms(), deadline_ms); // NOTE: Do NOT access "alarm" after the callback, as a safety precaution // in case the callback itself deleted the alarm. @@ -624,7 +626,8 @@ static void callback_dispatch(UNUSED_ATTR void* context) { // We're done here if there are no alarms or the alarm at the front is in // the future. Exit right away since there's nothing left to do. if (list_is_empty(alarms) || - (alarm = static_cast<alarm_t*>(list_front(alarms)))->deadline > now()) { + (alarm = static_cast<alarm_t*>(list_front(alarms)))->deadline_ms > + now_ms()) { reschedule_root_alarm(); continue; } @@ -632,7 +635,7 @@ static void callback_dispatch(UNUSED_ATTR void* context) { list_remove(alarms, alarm); if (alarm->is_periodic) { - alarm->prev_deadline = alarm->deadline; + alarm->prev_deadline_ms = alarm->deadline_ms; schedule_next_instance(alarm); alarm->stats.rescheduled_count++; } @@ -692,24 +695,24 @@ static bool timer_create_internal(const clockid_t clock_id, timer_t* timer) { return true; } -static void update_scheduling_stats(alarm_stats_t* stats, period_ms_t now_ms, - period_ms_t deadline_ms) { +static void update_scheduling_stats(alarm_stats_t* stats, uint64_t now_ms, + uint64_t deadline_ms) { stats->total_updates++; stats->last_update_ms = now_ms; if (deadline_ms < now_ms) { // Overdue scheduling - period_ms_t delta_ms = now_ms - deadline_ms; + uint64_t delta_ms = now_ms - deadline_ms; update_stat(&stats->overdue_scheduling, delta_ms); } else if (deadline_ms > now_ms) { // Premature scheduling - period_ms_t delta_ms = deadline_ms - now_ms; + uint64_t delta_ms = deadline_ms - now_ms; update_stat(&stats->premature_scheduling, delta_ms); } } static void dump_stat(int fd, stat_t* stat, const char* description) { - period_ms_t average_time_ms = 0; + uint64_t average_time_ms = 0; if (stat->count != 0) average_time_ms = stat->total_ms / stat->count; dprintf(fd, "%-51s: %llu / %llu / %llu\n", description, @@ -727,7 +730,7 @@ void alarm_debug_dump(int fd) { return; } - period_ms_t just_now = now(); + uint64_t just_now_ms = now_ms(); dprintf(fd, " Total Alarms: %zu\n\n", list_length(alarms)); @@ -751,9 +754,9 @@ void alarm_debug_dump(int fd) { dprintf(fd, "%-51s: %llu / %llu / %lld\n", " Time in ms (since creation/interval/remaining)", - (unsigned long long)(just_now - alarm->creation_time), - (unsigned long long)alarm->period, - (long long)(alarm->deadline - just_now)); + (unsigned long long)(just_now_ms - alarm->creation_time_ms), + (unsigned long long)alarm->period_ms, + (long long)(alarm->deadline_ms - just_now_ms)); dump_stat(fd, &stats->overdue_scheduling, " Overdue scheduling time in ms (total/max/avg)"); diff --git a/system/osi/src/wakelock.cc b/system/osi/src/wakelock.cc index 46c462caa0127fe4495154d850232c3a093fb7c9..aec9ea962408653f7f2eabdd7c5588e0d0340390 100644 --- a/system/osi/src/wakelock.cc +++ b/system/osi/src/wakelock.cc @@ -65,13 +65,13 @@ typedef struct { size_t released_count; size_t acquired_errors; size_t released_errors; - period_ms_t min_acquired_interval_ms; - period_ms_t max_acquired_interval_ms; - period_ms_t last_acquired_interval_ms; - period_ms_t total_acquired_interval_ms; - period_ms_t last_acquired_timestamp_ms; - period_ms_t last_released_timestamp_ms; - period_ms_t last_reset_timestamp_ms; + uint64_t min_acquired_interval_ms; + uint64_t max_acquired_interval_ms; + uint64_t last_acquired_interval_ms; + uint64_t total_acquired_interval_ms; + uint64_t last_acquired_timestamp_ms; + uint64_t last_released_timestamp_ms; + uint64_t last_reset_timestamp_ms; int last_acquired_error; int last_released_error; } wakelock_stats_t; @@ -224,7 +224,7 @@ void wakelock_set_paths(const char* lock_path, const char* unlock_path) { if (unlock_path) wake_unlock_path = unlock_path; } -static period_ms_t now(void) { +static uint64_t now_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_ID, &ts) == -1) { LOG_ERROR(LOG_TAG, "%s unable to get current time: %s", __func__, @@ -251,7 +251,7 @@ static void reset_wakelock_stats(void) { wakelock_stats.total_acquired_interval_ms = 0; wakelock_stats.last_acquired_timestamp_ms = 0; wakelock_stats.last_released_timestamp_ms = 0; - wakelock_stats.last_reset_timestamp_ms = now(); + wakelock_stats.last_reset_timestamp_ms = now_ms(); } // @@ -263,7 +263,7 @@ static void reset_wakelock_stats(void) { // This function is thread-safe. // static void update_wakelock_acquired_stats(bt_status_t acquired_status) { - const period_ms_t now_ms = now(); + const uint64_t just_now_ms = now_ms(); std::lock_guard<std::mutex> lock(stats_mutex); @@ -278,10 +278,10 @@ static void update_wakelock_acquired_stats(bt_status_t acquired_status) { wakelock_stats.is_acquired = true; wakelock_stats.acquired_count++; - wakelock_stats.last_acquired_timestamp_ms = now_ms; + wakelock_stats.last_acquired_timestamp_ms = just_now_ms; BluetoothMetricsLogger::GetInstance()->LogWakeEvent( - system_bt_osi::WAKE_EVENT_ACQUIRED, "", "", now_ms); + system_bt_osi::WAKE_EVENT_ACQUIRED, "", "", just_now_ms); } // @@ -293,7 +293,7 @@ static void update_wakelock_acquired_stats(bt_status_t acquired_status) { // This function is thread-safe. // static void update_wakelock_released_stats(bt_status_t released_status) { - const period_ms_t now_ms = now(); + const uint64_t just_now_ms = now_ms(); std::lock_guard<std::mutex> lock(stats_mutex); @@ -308,10 +308,10 @@ static void update_wakelock_released_stats(bt_status_t released_status) { wakelock_stats.is_acquired = false; wakelock_stats.released_count++; - wakelock_stats.last_released_timestamp_ms = now_ms; + wakelock_stats.last_released_timestamp_ms = just_now_ms; // Compute the acquired interval and update the statistics - period_ms_t delta_ms = now_ms - wakelock_stats.last_acquired_timestamp_ms; + uint64_t delta_ms = just_now_ms - wakelock_stats.last_acquired_timestamp_ms; if (delta_ms < wakelock_stats.min_acquired_interval_ms || wakelock_stats.released_count == 1) { wakelock_stats.min_acquired_interval_ms = delta_ms; @@ -323,32 +323,32 @@ static void update_wakelock_released_stats(bt_status_t released_status) { wakelock_stats.total_acquired_interval_ms += delta_ms; BluetoothMetricsLogger::GetInstance()->LogWakeEvent( - system_bt_osi::WAKE_EVENT_RELEASED, "", "", now_ms); + system_bt_osi::WAKE_EVENT_RELEASED, "", "", just_now_ms); } void wakelock_debug_dump(int fd) { - const period_ms_t now_ms = now(); + const uint64_t just_now_ms = now_ms(); std::lock_guard<std::mutex> lock(stats_mutex); // Compute the last acquired interval if the wakelock is still acquired - period_ms_t delta_ms = 0; - period_ms_t last_interval = wakelock_stats.last_acquired_interval_ms; - period_ms_t min_interval = wakelock_stats.min_acquired_interval_ms; - period_ms_t max_interval = wakelock_stats.max_acquired_interval_ms; - period_ms_t ave_interval = 0; + uint64_t delta_ms = 0; + uint64_t last_interval_ms = wakelock_stats.last_acquired_interval_ms; + uint64_t min_interval_ms = wakelock_stats.min_acquired_interval_ms; + uint64_t max_interval_ms = wakelock_stats.max_acquired_interval_ms; + uint64_t avg_interval_ms = 0; if (wakelock_stats.is_acquired) { - delta_ms = now_ms - wakelock_stats.last_acquired_timestamp_ms; - if (delta_ms > max_interval) max_interval = delta_ms; - if (delta_ms < min_interval) min_interval = delta_ms; - last_interval = delta_ms; + delta_ms = just_now_ms - wakelock_stats.last_acquired_timestamp_ms; + if (delta_ms > max_interval_ms) max_interval_ms = delta_ms; + if (delta_ms < min_interval_ms) min_interval_ms = delta_ms; + last_interval_ms = delta_ms; } - period_ms_t total_interval = + uint64_t total_interval_ms = wakelock_stats.total_acquired_interval_ms + delta_ms; if (wakelock_stats.acquired_count > 0) - ave_interval = total_interval / wakelock_stats.acquired_count; + avg_interval_ms = total_interval_ms / wakelock_stats.acquired_count; dprintf(fd, "\nBluetooth Wakelock Statistics:\n"); dprintf(fd, " Is acquired : %s\n", @@ -361,13 +361,14 @@ void wakelock_debug_dump(int fd) { wakelock_stats.last_acquired_error, wakelock_stats.last_released_error); dprintf(fd, " Last acquired time (ms) : %llu\n", - (unsigned long long)last_interval); + (unsigned long long)last_interval_ms); dprintf(fd, " Acquired time min/max/avg (ms) : %llu / %llu / %llu\n", - (unsigned long long)min_interval, (unsigned long long)max_interval, - (unsigned long long)ave_interval); + (unsigned long long)min_interval_ms, + (unsigned long long)max_interval_ms, + (unsigned long long)avg_interval_ms); dprintf(fd, " Total acquired time (ms) : %llu\n", - (unsigned long long)total_interval); - dprintf( - fd, " Total run time (ms) : %llu\n", - (unsigned long long)(now_ms - wakelock_stats.last_reset_timestamp_ms)); + (unsigned long long)total_interval_ms); + dprintf(fd, " Total run time (ms) : %llu\n", + (unsigned long long)(just_now_ms - + wakelock_stats.last_reset_timestamp_ms)); } diff --git a/system/stack/a2dp/a2dp_aac.cc b/system/stack/a2dp/a2dp_aac.cc index 7103d63923195a808d17e31e58318a09d0e5dbb1..67a2430534e31b4579d243ac0cf6923ef8f92603 100644 --- a/system/stack/a2dp/a2dp_aac.cc +++ b/system/stack/a2dp/a2dp_aac.cc @@ -1426,7 +1426,7 @@ bool A2dpCodecConfigAacSink::init() { return true; } -period_ms_t A2dpCodecConfigAacSink::encoderIntervalMs() const { +uint64_t A2dpCodecConfigAacSink::encoderIntervalMs() const { // TODO: This method applies only to Source codecs return 0; } diff --git a/system/stack/a2dp/a2dp_aac_encoder.cc b/system/stack/a2dp/a2dp_aac_encoder.cc index 43b61811e9e7a4b441bf93f2e74f4320a41276d9..22cb4eaf45dc931ae9ece60c4b9dd0bc0233b256 100644 --- a/system/stack/a2dp/a2dp_aac_encoder.cc +++ b/system/stack/a2dp/a2dp_aac_encoder.cc @@ -483,7 +483,7 @@ void a2dp_aac_feeding_flush(void) { a2dp_aac_encoder_cb.aac_feeding_state.counter = 0; } -period_ms_t a2dp_aac_get_encoder_interval_ms(void) { +uint64_t a2dp_aac_get_encoder_interval_ms(void) { return A2DP_AAC_ENCODER_INTERVAL_MS; } @@ -694,7 +694,7 @@ static bool a2dp_aac_read_feeding(uint8_t* read_buffer, uint32_t* bytes_read) { return true; } -period_ms_t A2dpCodecConfigAacSource::encoderIntervalMs() const { +uint64_t A2dpCodecConfigAacSource::encoderIntervalMs() const { return a2dp_aac_get_encoder_interval_ms(); } diff --git a/system/stack/a2dp/a2dp_sbc.cc b/system/stack/a2dp/a2dp_sbc.cc index 6a80357e99c08058b01400f9411fc71d66436030..53f1e1a0f51a5e65a9e70ff09747edeac6f1b0b5 100644 --- a/system/stack/a2dp/a2dp_sbc.cc +++ b/system/stack/a2dp/a2dp_sbc.cc @@ -1570,7 +1570,7 @@ bool A2dpCodecConfigSbcSink::updateEncoderUserConfig( return false; } -period_ms_t A2dpCodecConfigSbcSink::encoderIntervalMs() const { +uint64_t A2dpCodecConfigSbcSink::encoderIntervalMs() const { // TODO: This method applies only to Source codecs return 0; } diff --git a/system/stack/a2dp/a2dp_sbc_encoder.cc b/system/stack/a2dp/a2dp_sbc_encoder.cc index bd09989356ea99cc04ff3dfe2f942812e28f7d15..b90ba52dc9a35e21d4528ebe3e17451265a7318f 100644 --- a/system/stack/a2dp/a2dp_sbc_encoder.cc +++ b/system/stack/a2dp/a2dp_sbc_encoder.cc @@ -399,7 +399,7 @@ void a2dp_sbc_feeding_flush(void) { a2dp_sbc_encoder_cb.feeding_state.aa_feed_residue = 0; } -period_ms_t a2dp_sbc_get_encoder_interval_ms(void) { +uint64_t a2dp_sbc_get_encoder_interval_ms(void) { return A2DP_SBC_ENCODER_INTERVAL_MS; } @@ -909,7 +909,7 @@ uint32_t a2dp_sbc_get_bitrate() { return p_encoder_params->u16BitRate * 1000; } -period_ms_t A2dpCodecConfigSbcSource::encoderIntervalMs() const { +uint64_t A2dpCodecConfigSbcSource::encoderIntervalMs() const { return a2dp_sbc_get_encoder_interval_ms(); } diff --git a/system/stack/a2dp/a2dp_vendor_aptx_encoder.cc b/system/stack/a2dp/a2dp_vendor_aptx_encoder.cc index 0252935581b0e2b5cd2fe48a1a2e0ea7df3ababf..1b65776bb025713040e1feba00680edeba9e7e69 100644 --- a/system/stack/a2dp/a2dp_vendor_aptx_encoder.cc +++ b/system/stack/a2dp/a2dp_vendor_aptx_encoder.cc @@ -369,7 +369,7 @@ void a2dp_vendor_aptx_feeding_flush(void) { aptx_init_framing_params(&a2dp_aptx_encoder_cb.framing_params); } -period_ms_t a2dp_vendor_aptx_get_encoder_interval_ms(void) { +uint64_t a2dp_vendor_aptx_get_encoder_interval_ms(void) { return a2dp_aptx_encoder_cb.framing_params.sleep_time_ns / (1000 * 1000); } @@ -480,7 +480,7 @@ static size_t aptx_encode_16bit(tAPTX_FRAMING_PARAMS* framing_params, return pcm_bytes_encoded; } -period_ms_t A2dpCodecConfigAptx::encoderIntervalMs() const { +uint64_t A2dpCodecConfigAptx::encoderIntervalMs() const { return a2dp_vendor_aptx_get_encoder_interval_ms(); } diff --git a/system/stack/a2dp/a2dp_vendor_aptx_hd_encoder.cc b/system/stack/a2dp/a2dp_vendor_aptx_hd_encoder.cc index d72ec5a9972e398f365d369c37f43613bc287e2b..dc045e399b423f16c4d086f9e045ddaedb5899c3 100644 --- a/system/stack/a2dp/a2dp_vendor_aptx_hd_encoder.cc +++ b/system/stack/a2dp/a2dp_vendor_aptx_hd_encoder.cc @@ -353,7 +353,7 @@ void a2dp_vendor_aptx_hd_feeding_flush(void) { aptx_hd_init_framing_params(&a2dp_aptx_hd_encoder_cb.framing_params); } -period_ms_t a2dp_vendor_aptx_hd_get_encoder_interval_ms(void) { +uint64_t a2dp_vendor_aptx_hd_get_encoder_interval_ms(void) { return a2dp_aptx_hd_encoder_cb.framing_params.sleep_time_ns / (1000 * 1000); } @@ -477,7 +477,7 @@ static size_t aptx_hd_encode_24bit(tAPTX_HD_FRAMING_PARAMS* framing_params, return pcm_bytes_encoded; } -period_ms_t A2dpCodecConfigAptxHd::encoderIntervalMs() const { +uint64_t A2dpCodecConfigAptxHd::encoderIntervalMs() const { return a2dp_vendor_aptx_hd_get_encoder_interval_ms(); } diff --git a/system/stack/a2dp/a2dp_vendor_ldac_encoder.cc b/system/stack/a2dp/a2dp_vendor_ldac_encoder.cc index 21d5e7216199d4287293cc74ebb6b6fe9e3d278e..6c01db120f059ce8cd2ce59d1b9c1463a505b175 100644 --- a/system/stack/a2dp/a2dp_vendor_ldac_encoder.cc +++ b/system/stack/a2dp/a2dp_vendor_ldac_encoder.cc @@ -533,7 +533,7 @@ void a2dp_vendor_ldac_feeding_flush(void) { a2dp_ldac_encoder_cb.ldac_feeding_state.counter = 0; } -period_ms_t a2dp_vendor_ldac_get_encoder_interval_ms(void) { +uint64_t a2dp_vendor_ldac_get_encoder_interval_ms(void) { return A2DP_LDAC_ENCODER_INTERVAL_MS; } @@ -759,7 +759,7 @@ void a2dp_vendor_ldac_set_transmit_queue_length(size_t transmit_queue_length) { a2dp_ldac_encoder_cb.TxQueueLength = transmit_queue_length; } -period_ms_t A2dpCodecConfigLdac::encoderIntervalMs() const { +uint64_t A2dpCodecConfigLdac::encoderIntervalMs() const { return a2dp_vendor_ldac_get_encoder_interval_ms(); } diff --git a/system/stack/avdt/avdt_ccb_act.cc b/system/stack/avdt/avdt_ccb_act.cc index 52f3857c75be3e8fd77f6b2c1b61ab506ade220b..3059d8ace639de5c533bc129a0623ffd6ede66e9 100644 --- a/system/stack/avdt/avdt_ccb_act.cc +++ b/system/stack/avdt/avdt_ccb_act.cc @@ -122,7 +122,7 @@ void avdt_ccb_chk_close(AvdtpCcb* p_ccb, UNUSED_ATTR tAVDT_CCB_EVT* p_data) { if (i == AVDT_NUM_SEPS) { alarm_cancel(p_ccb->ret_ccb_timer); alarm_cancel(p_ccb->rsp_ccb_timer); - period_ms_t interval_ms = avdtp_cb.rcb.idle_tout * 1000; + uint64_t interval_ms = avdtp_cb.rcb.idle_tout * 1000; alarm_set_on_mloop(p_ccb->idle_ccb_timer, interval_ms, avdt_ccb_idle_ccb_timer_timeout, p_ccb); } @@ -780,7 +780,7 @@ void avdt_ccb_ret_cmd(AvdtpCcb* p_ccb, tAVDT_CCB_EVT* p_data) { /* restart ret timer */ alarm_cancel(p_ccb->idle_ccb_timer); alarm_cancel(p_ccb->rsp_ccb_timer); - period_ms_t interval_ms = avdtp_cb.rcb.ret_tout * 1000; + uint64_t interval_ms = avdtp_cb.rcb.ret_tout * 1000; alarm_set_on_mloop(p_ccb->ret_ccb_timer, interval_ms, avdt_ccb_ret_ccb_timer_timeout, p_ccb); } diff --git a/system/stack/avdt/avdt_msg.cc b/system/stack/avdt/avdt_msg.cc index cf517d12527d8f1145cbb0d12ba991db394271fa..0ac9b64be96d8c33bf61763ed61a613b9b7e17d5 100644 --- a/system/stack/avdt/avdt_msg.cc +++ b/system/stack/avdt/avdt_msg.cc @@ -1135,13 +1135,13 @@ bool avdt_msg_send(AvdtpCcb* p_ccb, BT_HDR* p_msg) { (sig == AVDT_SIG_SECURITY) || (avdtp_cb.rcb.ret_tout == 0)) { alarm_cancel(p_ccb->idle_ccb_timer); alarm_cancel(p_ccb->ret_ccb_timer); - period_ms_t interval_ms = avdtp_cb.rcb.sig_tout * 1000; + uint64_t interval_ms = avdtp_cb.rcb.sig_tout * 1000; alarm_set_on_mloop(p_ccb->rsp_ccb_timer, interval_ms, avdt_ccb_rsp_ccb_timer_timeout, p_ccb); } else if (sig != AVDT_SIG_DELAY_RPT) { alarm_cancel(p_ccb->idle_ccb_timer); alarm_cancel(p_ccb->rsp_ccb_timer); - period_ms_t interval_ms = avdtp_cb.rcb.ret_tout * 1000; + uint64_t interval_ms = avdtp_cb.rcb.ret_tout * 1000; alarm_set_on_mloop(p_ccb->ret_ccb_timer, interval_ms, avdt_ccb_ret_ccb_timer_timeout, p_ccb); } diff --git a/system/stack/btm/btm_ble_addr.cc b/system/stack/btm/btm_ble_addr.cc index 2528915468b1b8e366c71222a6664d3028f27312..c94dfd4bb78eb6ea5329c78e436b1e3c32731a16 100644 --- a/system/stack/btm/btm_ble_addr.cc +++ b/system/stack/btm/btm_ble_addr.cc @@ -72,7 +72,7 @@ void btm_gen_resolve_paddr_low(const RawAddress& address) { p_cb->own_addr_type = BLE_ADDR_RANDOM; /* start a periodical timer to refresh random addr */ - period_ms_t interval_ms = BTM_BLE_PRIVATE_ADDR_INT_MS; + uint64_t interval_ms = BTM_BLE_PRIVATE_ADDR_INT_MS; #if (BTM_BLE_CONFORMANCE_TESTING == TRUE) interval_ms = btm_cb.ble_ctr_cb.rpa_tout * 1000; #endif diff --git a/system/stack/btm/btm_ble_gap.cc b/system/stack/btm/btm_ble_gap.cc index 1f8263f05b33084f4f4aee23b636fe55dab73c05..603adb46420347bf8c699743b97fe484d5b919af 100644 --- a/system/stack/btm/btm_ble_gap.cc +++ b/system/stack/btm/btm_ble_gap.cc @@ -452,7 +452,7 @@ tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration, btm_cb.ble_ctr_cb.scan_activity |= BTM_LE_OBSERVE_ACTIVE; if (duration != 0) { /* start observer timer */ - period_ms_t duration_ms = duration * 1000; + uint64_t duration_ms = duration * 1000; alarm_set_on_mloop(btm_cb.ble_ctr_cb.observer_timer, duration_ms, btm_ble_observer_timer_timeout, NULL); } @@ -1416,7 +1416,7 @@ tBTM_STATUS btm_ble_start_inquiry(uint8_t mode, uint8_t duration) { if (duration != 0) { /* start inquiry timer */ - period_ms_t duration_ms = duration * 1000; + uint64_t duration_ms = duration * 1000; alarm_set_on_mloop(p_ble_cb->inq_var.inquiry_timer, duration_ms, btm_ble_inquiry_timer_timeout, NULL); } diff --git a/system/stack/btm/btm_ble_multi_adv.cc b/system/stack/btm/btm_ble_multi_adv.cc index a7960cd1b33347596b8fcec226595cf35949ac03..bc9baed65084ae8e91a6341a5e56cf9d35d0b373 100644 --- a/system/stack/btm/btm_ble_multi_adv.cc +++ b/system/stack/btm/btm_ble_multi_adv.cc @@ -130,7 +130,7 @@ static void alarm_closure_cb(void* p) { // Periodic alarms are not supported, because we clean up data in callback void alarm_set_closure(const tracked_objects::Location& posted_from, - alarm_t* alarm, period_ms_t interval_ms, + alarm_t* alarm, uint64_t interval_ms, base::Closure user_task) { closure_data* data = new closure_data; data->posted_from = posted_from; diff --git a/system/stack/btm/btm_inq.cc b/system/stack/btm/btm_inq.cc index bdcce381a3f980cbca9179766bd6cbddd612c48c..383d2903817ab6c59ed1eabf5759aa40190763d7 100644 --- a/system/stack/btm/btm_inq.cc +++ b/system/stack/btm/btm_inq.cc @@ -1951,7 +1951,7 @@ void btm_process_cancel_complete(uint8_t status, uint8_t mode) { * ******************************************************************************/ tBTM_STATUS btm_initiate_rem_name(const RawAddress& remote_bda, uint8_t origin, - period_ms_t timeout_ms, tBTM_CMPL_CB* p_cb) { + uint64_t timeout_ms, tBTM_CMPL_CB* p_cb) { tBTM_INQUIRY_VAR_ST* p_inq = &btm_cb.btm_inq_vars; /*** Make sure the device is ready ***/ diff --git a/system/stack/btm/btm_int.h b/system/stack/btm/btm_int.h index 325cb4f5acfbede9e8bcc9f2303d07af4b5e8e6b..74a87143935e6acc53044e4e7aa227b418603ba6 100644 --- a/system/stack/btm/btm_int.h +++ b/system/stack/btm/btm_int.h @@ -53,7 +53,7 @@ extern void btm_init(void); ****************************************** */ extern tBTM_STATUS btm_initiate_rem_name(const RawAddress& remote_bda, - uint8_t origin, period_ms_t timeout_ms, + uint8_t origin, uint64_t timeout_ms, tBTM_CMPL_CB* p_cb); extern void btm_process_remote_name(const RawAddress* bda, BD_NAME name, diff --git a/system/stack/gatt/gatt_utils.cc b/system/stack/gatt/gatt_utils.cc index 9fa48f8bf82fbcfcedbf9eb93c8c492880869f73..d92f42347dc772e8ebdabc918bef8e59b2a8b4d5 100644 --- a/system/stack/gatt/gatt_utils.cc +++ b/system/stack/gatt/gatt_utils.cc @@ -528,7 +528,7 @@ bool gatt_parse_uuid_from_cmd(Uuid* p_uuid_rec, uint16_t uuid_size, * ******************************************************************************/ void gatt_start_rsp_timer(tGATT_CLCB* p_clcb) { - period_ms_t timeout_ms = GATT_WAIT_FOR_RSP_TIMEOUT_MS; + uint64_t timeout_ms = GATT_WAIT_FOR_RSP_TIMEOUT_MS; if (p_clcb->operation == GATTC_OPTYPE_DISCOVERY && p_clcb->op_subtype == GATT_DISC_SRVC_ALL) { diff --git a/system/stack/hid/hidh_conn.cc b/system/stack/hid/hidh_conn.cc index 76c03a6f96b53140defa3b9c245ca761c75f5e7c..df0083a462c12dd391355085201a91e8b62994d3 100644 --- a/system/stack/hid/hidh_conn.cc +++ b/system/stack/hid/hidh_conn.cc @@ -655,7 +655,7 @@ static void hidh_l2cif_disconnect_ind(uint16_t l2cap_cid, bool ack_needed) { (!(hh_cb.devices[dhandle].attr_mask & HID_RECONN_INIT)) && (hh_cb.devices[dhandle].attr_mask & HID_NORMALLY_CONNECTABLE)) { hh_cb.devices[dhandle].conn_tries = 0; - period_ms_t interval_ms = HID_HOST_REPAGE_WIN * 1000; + uint64_t interval_ms = HID_HOST_REPAGE_WIN * 1000; alarm_set_on_mloop(hh_cb.devices[dhandle].conn.process_repage_timer, interval_ms, hidh_process_repage_timer_timeout, UINT_TO_PTR(dhandle)); @@ -1064,7 +1064,7 @@ static void hidh_conn_retry(uint8_t dhandle) { p_dev->conn.conn_state = HID_CONN_STATE_UNUSED; #if (HID_HOST_REPAGE_WIN > 0) - period_ms_t interval_ms = HID_HOST_REPAGE_WIN * 1000; + uint64_t interval_ms = HID_HOST_REPAGE_WIN * 1000; alarm_set_on_mloop(p_dev->conn.process_repage_timer, interval_ms, hidh_process_repage_timer_timeout, UINT_TO_PTR(dhandle)); #else diff --git a/system/stack/include/a2dp_aac.h b/system/stack/include/a2dp_aac.h index 29b27535d7fe84eee8dc5f8958d1aeef07fc7800..49b1495a5d71a6b25d1e33ed14e7e2aafb9349ec 100644 --- a/system/stack/include/a2dp_aac.h +++ b/system/stack/include/a2dp_aac.h @@ -48,7 +48,7 @@ class A2dpCodecConfigAacSource : public A2dpCodecConfigAacBase { virtual ~A2dpCodecConfigAacSource(); bool init() override; - period_ms_t encoderIntervalMs() const override; + uint64_t encoderIntervalMs() const override; int getEffectiveMtu() const override; private: @@ -66,7 +66,7 @@ class A2dpCodecConfigAacSink : public A2dpCodecConfigAacBase { virtual ~A2dpCodecConfigAacSink(); bool init() override; - period_ms_t encoderIntervalMs() const override; + uint64_t encoderIntervalMs() const override; int getEffectiveMtu() const override; private: diff --git a/system/stack/include/a2dp_aac_encoder.h b/system/stack/include/a2dp_aac_encoder.h index e6b732380d620484c0e0dae7ba1783a7dfdb45ed..5adf2184e35690461f8c00e10073b671f26b1095 100644 --- a/system/stack/include/a2dp_aac_encoder.h +++ b/system/stack/include/a2dp_aac_encoder.h @@ -51,7 +51,7 @@ void a2dp_aac_feeding_reset(void); void a2dp_aac_feeding_flush(void); // Get the A2DP AAC encoder interval (in milliseconds). -period_ms_t a2dp_aac_get_encoder_interval_ms(void); +uint64_t a2dp_aac_get_encoder_interval_ms(void); // Prepare and send A2DP AAC encoded frames. // |timestamp_us| is the current timestamp (in microseconds). diff --git a/system/stack/include/a2dp_codec_api.h b/system/stack/include/a2dp_codec_api.h index 9fdc13b20c2718e5a6bff695b44e329c4ef540c4..f5e15739272714835473a514a892a3be45738369 100644 --- a/system/stack/include/a2dp_codec_api.h +++ b/system/stack/include/a2dp_codec_api.h @@ -217,7 +217,7 @@ class A2dpCodecConfig { virtual bool isValid() const; // Returns the encoder's periodic interval (in milliseconds). - virtual period_ms_t encoderIntervalMs() const = 0; + virtual uint64_t encoderIntervalMs() const = 0; // Checks whether the A2DP Codec Configuration is valid. // Returns true if A2DP Codec Configuration stored in |codec_config| @@ -527,7 +527,7 @@ typedef struct { void (*feeding_flush)(void); // Get the A2DP encoder interval (in milliseconds). - period_ms_t (*get_encoder_interval_ms)(void); + uint64_t (*get_encoder_interval_ms)(void); // Prepare and send A2DP encoded frames. // |timestamp_us| is the current timestamp (in microseconds). diff --git a/system/stack/include/a2dp_sbc.h b/system/stack/include/a2dp_sbc.h index 0381d311fa53c343cae7c61dd30ddfcbfeb6819e..3a03a55be90d8a31783dfe4212ead4aa035398cf 100644 --- a/system/stack/include/a2dp_sbc.h +++ b/system/stack/include/a2dp_sbc.h @@ -48,7 +48,7 @@ class A2dpCodecConfigSbcSource : public A2dpCodecConfigSbcBase { virtual ~A2dpCodecConfigSbcSource(); bool init() override; - period_ms_t encoderIntervalMs() const override; + uint64_t encoderIntervalMs() const override; int getEffectiveMtu() const override; private: @@ -66,7 +66,7 @@ class A2dpCodecConfigSbcSink : public A2dpCodecConfigSbcBase { virtual ~A2dpCodecConfigSbcSink(); bool init() override; - period_ms_t encoderIntervalMs() const override; + uint64_t encoderIntervalMs() const override; int getEffectiveMtu() const override; private: diff --git a/system/stack/include/a2dp_sbc_encoder.h b/system/stack/include/a2dp_sbc_encoder.h index a8530121db0824e62907427d6409b55adea2cef6..d97e78ce4e71d02d11f01aab03a7a1eedfe63196 100644 --- a/system/stack/include/a2dp_sbc_encoder.h +++ b/system/stack/include/a2dp_sbc_encoder.h @@ -54,7 +54,7 @@ void a2dp_sbc_feeding_reset(void); void a2dp_sbc_feeding_flush(void); // Get the A2DP SBC encoder interval (in milliseconds). -period_ms_t a2dp_sbc_get_encoder_interval_ms(void); +uint64_t a2dp_sbc_get_encoder_interval_ms(void); // Prepare and send A2DP SBC encoded frames. // |timestamp_us| is the current timestamp (in microseconds). diff --git a/system/stack/include/a2dp_vendor_aptx.h b/system/stack/include/a2dp_vendor_aptx.h index 38a1245a3f1f90f19445fb4bd76c2ec4b1ca42cb..a2b154a8b3042f51ccfb6395cff96a2ba9298faf 100644 --- a/system/stack/include/a2dp_vendor_aptx.h +++ b/system/stack/include/a2dp_vendor_aptx.h @@ -31,7 +31,7 @@ class A2dpCodecConfigAptx : public A2dpCodecConfig { virtual ~A2dpCodecConfigAptx(); bool init() override; - period_ms_t encoderIntervalMs() const override; + uint64_t encoderIntervalMs() const override; int getEffectiveMtu() const override; bool setCodecConfig(const uint8_t* p_peer_codec_info, bool is_capability, uint8_t* p_result_codec_config) override; diff --git a/system/stack/include/a2dp_vendor_aptx_encoder.h b/system/stack/include/a2dp_vendor_aptx_encoder.h index 7deaca305f061a6402a06271033fd7eeb84b54ec..585819de278ed9147bca9fd8e7921d4aac1a5fd6 100644 --- a/system/stack/include/a2dp_vendor_aptx_encoder.h +++ b/system/stack/include/a2dp_vendor_aptx_encoder.h @@ -52,7 +52,7 @@ void a2dp_vendor_aptx_feeding_reset(void); void a2dp_vendor_aptx_feeding_flush(void); // Get the A2DP aptX encoder interval (in milliseconds). -period_ms_t a2dp_vendor_aptx_get_encoder_interval_ms(void); +uint64_t a2dp_vendor_aptx_get_encoder_interval_ms(void); // Prepare and send A2DP aptX encoded frames. // |timestamp_us| is the current timestamp (in microseconds). diff --git a/system/stack/include/a2dp_vendor_aptx_hd.h b/system/stack/include/a2dp_vendor_aptx_hd.h index 05ca16fe9c4ae8cdf7d2d7d3dc4f9dbd9c6222cc..c5373300d3f1727889fbbbff025b9bbdfe47ec4c 100644 --- a/system/stack/include/a2dp_vendor_aptx_hd.h +++ b/system/stack/include/a2dp_vendor_aptx_hd.h @@ -31,7 +31,7 @@ class A2dpCodecConfigAptxHd : public A2dpCodecConfig { virtual ~A2dpCodecConfigAptxHd(); bool init() override; - period_ms_t encoderIntervalMs() const override; + uint64_t encoderIntervalMs() const override; int getEffectiveMtu() const override; bool setCodecConfig(const uint8_t* p_peer_codec_info, bool is_capability, uint8_t* p_result_codec_config) override; diff --git a/system/stack/include/a2dp_vendor_aptx_hd_encoder.h b/system/stack/include/a2dp_vendor_aptx_hd_encoder.h index 53e7d02d685d71784074882d0e81680c16c7d6e6..c7b5de326014405ac7f8a62e3e4829ab33c42964 100644 --- a/system/stack/include/a2dp_vendor_aptx_hd_encoder.h +++ b/system/stack/include/a2dp_vendor_aptx_hd_encoder.h @@ -52,7 +52,7 @@ void a2dp_vendor_aptx_hd_feeding_reset(void); void a2dp_vendor_aptx_hd_feeding_flush(void); // Get the A2DP aptX-HD encoder interval (in milliseconds). -period_ms_t a2dp_vendor_aptx_hd_get_encoder_interval_ms(void); +uint64_t a2dp_vendor_aptx_hd_get_encoder_interval_ms(void); // Prepare and send A2DP aptX-HD encoded frames. // |timestamp_us| is the current timestamp (in microseconds). diff --git a/system/stack/include/a2dp_vendor_ldac.h b/system/stack/include/a2dp_vendor_ldac.h index ccb5d1e5e980595b91c08af2ff2e41aad9c8ca62..d3e206c3d50dc92783495b589ae6cf9dde8b0642 100644 --- a/system/stack/include/a2dp_vendor_ldac.h +++ b/system/stack/include/a2dp_vendor_ldac.h @@ -31,7 +31,7 @@ class A2dpCodecConfigLdac : public A2dpCodecConfig { virtual ~A2dpCodecConfigLdac(); bool init() override; - period_ms_t encoderIntervalMs() const override; + uint64_t encoderIntervalMs() const override; int getEffectiveMtu() const override; bool setCodecConfig(const uint8_t* p_peer_codec_info, bool is_capability, uint8_t* p_result_codec_config) override; diff --git a/system/stack/include/a2dp_vendor_ldac_encoder.h b/system/stack/include/a2dp_vendor_ldac_encoder.h index 810f03b5df3afc5c820824d2e3690b85f3dc4908..9980f398a8627cd026a4cf00ce1747b328e034fe 100644 --- a/system/stack/include/a2dp_vendor_ldac_encoder.h +++ b/system/stack/include/a2dp_vendor_ldac_encoder.h @@ -52,7 +52,7 @@ void a2dp_vendor_ldac_feeding_reset(void); void a2dp_vendor_ldac_feeding_flush(void); // Get the A2DP LDAC encoder interval (in milliseconds). -period_ms_t a2dp_vendor_ldac_get_encoder_interval_ms(void); +uint64_t a2dp_vendor_ldac_get_encoder_interval_ms(void); // Prepare and send A2DP LDAC encoded frames. // |timestamp_us| is the current timestamp (in microseconds). diff --git a/system/stack/l2cap/l2c_link.cc b/system/stack/l2cap/l2c_link.cc index db7e6135c2b78f12ce9b77c963391f26bcf65e9d..b9b905dbd72ba4db31ce81d44797420e3878b770 100644 --- a/system/stack/l2cap/l2c_link.cc +++ b/system/stack/l2cap/l2c_link.cc @@ -217,7 +217,7 @@ bool l2c_link_hci_conn_comp(uint8_t status, uint16_t handle, alarm_set_on_mloop(p_lcb->l2c_lcb_timer, L2CAP_ECHO_RSP_TIMEOUT_MS, l2c_lcb_timer_timeout, p_lcb); } else if (!p_lcb->ccb_queue.p_first_ccb) { - period_ms_t timeout_ms = L2CAP_LINK_STARTUP_TOUT * 1000; + uint64_t timeout_ms = L2CAP_LINK_STARTUP_TOUT * 1000; alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms, l2c_lcb_timer_timeout, p_lcb); } @@ -557,7 +557,7 @@ void l2c_link_timeout(tL2C_LCB* p_lcb) { /* If no channels in use, drop the link. */ if (!p_lcb->ccb_queue.p_first_ccb) { - period_ms_t timeout_ms; + uint64_t timeout_ms; bool start_timeout = true; rc = btm_sec_disconnect(p_lcb->handle, HCI_ERR_PEER_USER); diff --git a/system/stack/l2cap/l2c_utils.cc b/system/stack/l2cap/l2c_utils.cc index f43f4b40bbbc64253ab985c5ea1a759b640d277b..cabf800276509e41bea088f0c3b9833ba0ac176a 100644 --- a/system/stack/l2cap/l2c_utils.cc +++ b/system/stack/l2cap/l2c_utils.cc @@ -1537,7 +1537,7 @@ bool l2cu_start_post_bond_timer(uint16_t handle) { if ((p_lcb->link_state == LST_CONNECTED) || (p_lcb->link_state == LST_CONNECTING) || (p_lcb->link_state == LST_DISCONNECTING)) { - period_ms_t timeout_ms = L2CAP_BONDING_TIMEOUT * 1000; + uint64_t timeout_ms = L2CAP_BONDING_TIMEOUT * 1000; if (p_lcb->idle_timeout == 0) { btsnd_hcic_disconnect(p_lcb->handle, HCI_ERR_PEER_USER); @@ -2608,7 +2608,7 @@ bool l2cu_initialize_fixed_ccb(tL2C_LCB* p_lcb, uint16_t fixed_cid, ******************************************************************************/ void l2cu_no_dynamic_ccbs(tL2C_LCB* p_lcb) { tBTM_STATUS rc; - period_ms_t timeout_ms = p_lcb->idle_timeout * 1000; + uint64_t timeout_ms = p_lcb->idle_timeout * 1000; bool start_timeout = true; #if (L2CAP_NUM_FIXED_CHNLS > 0) diff --git a/system/stack/mcap/mca_cact.cc b/system/stack/mcap/mca_cact.cc index 48d0c0ae0c0641a77714cd6256ffda1ca1dc70c7..29e2b68860facc135f658a1ee2b601b434937a84 100644 --- a/system/stack/mcap/mca_cact.cc +++ b/system/stack/mcap/mca_cact.cc @@ -128,7 +128,7 @@ void mca_ccb_snd_req(tMCA_CCB* p_ccb, tMCA_CCB_EVT* p_data) { p_msg->hdr.layer_specific = true; /* mark this message as sent */ p_pkt->len = p - p_start; L2CA_DataWrite(p_ccb->lcid, p_pkt); - period_ms_t interval_ms = p_ccb->p_rcb->reg.rsp_tout * 1000; + uint64_t interval_ms = p_ccb->p_rcb->reg.rsp_tout * 1000; alarm_set_on_mloop(p_ccb->mca_ccb_timer, interval_ms, mca_ccb_timer_timeout, p_ccb); } diff --git a/system/stack/rfcomm/rfc_utils.cc b/system/stack/rfcomm/rfc_utils.cc index 616e24eff91bb08c09af9f2c42b57bb2d5a6f40f..3dee8a1ad2519a6387e54c7fd2a16f4fadda50e5 100644 --- a/system/stack/rfcomm/rfc_utils.cc +++ b/system/stack/rfcomm/rfc_utils.cc @@ -225,7 +225,7 @@ void rfc_release_multiplexer_channel(tRFC_MCB* p_mcb) { void rfc_timer_start(tRFC_MCB* p_mcb, uint16_t timeout) { RFCOMM_TRACE_EVENT("%s - timeout:%d seconds", __func__, timeout); - period_ms_t interval_ms = timeout * 1000; + uint64_t interval_ms = timeout * 1000; alarm_set_on_mloop(p_mcb->mcb_timer, interval_ms, rfcomm_mcb_timer_timeout, p_mcb); } @@ -253,7 +253,7 @@ void rfc_timer_stop(tRFC_MCB* p_mcb) { void rfc_port_timer_start(tPORT* p_port, uint16_t timeout) { RFCOMM_TRACE_EVENT("%s - timeout:%d seconds", __func__, timeout); - period_ms_t interval_ms = timeout * 1000; + uint64_t interval_ms = timeout * 1000; alarm_set_on_mloop(p_port->rfc.port_timer, interval_ms, rfcomm_port_timer_timeout, p_port); } diff --git a/system/stack/test/ble_advertiser_test.cc b/system/stack/test/ble_advertiser_test.cc index 6ca0ad446389b24054d3e3d336ce2935cd24c2e4..9c7d5a529a354e5db216c7bf94e9484302d2daca 100644 --- a/system/stack/test/ble_advertiser_test.cc +++ b/system/stack/test/ble_advertiser_test.cc @@ -56,7 +56,7 @@ void btm_gen_resolvable_private_addr( alarm_callback_t last_alarm_cb = nullptr; void* last_alarm_data = nullptr; -void alarm_set_on_mloop(alarm_t* alarm, period_ms_t interval_ms, +void alarm_set_on_mloop(alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb, void* data) { last_alarm_cb = cb; last_alarm_data = data;