#define BTA_AG_DEBUG FALSE
#endif
-extern fixed_queue_t* btu_bta_alarm_queue;
-
#if (BTA_AG_DEBUG == TRUE)
static char* bta_ag_evt_str(uint16_t event, tBTA_AG_RES result);
static char* bta_ag_state_str(uint8_t state);
bta_ag_start_servers(p_scb, p_scb->reg_services);
/* Start timer to han */
- alarm_set_on_queue(p_scb->collision_timer, BTA_AG_COLLISION_TIMEOUT_MS,
- bta_ag_collision_timer_cback, p_scb,
- btu_bta_alarm_queue);
+ alarm_set_on_mloop(p_scb->collision_timer, BTA_AG_COLLISION_TIMEOUT_MS,
+ bta_ag_collision_timer_cback, p_scb);
}
}
#define BTA_AG_CODEC_NEGOTIATION_TIMEOUT_MS (3 * 1000) /* 3 seconds */
#endif
-extern fixed_queue_t* btu_bta_alarm_queue;
-
#if (BTA_AG_SCO_DEBUG == TRUE)
static char* bta_ag_sco_evt_str(uint8_t event);
static char* bta_ag_sco_state_str(uint8_t state);
bta_ag_send_bcs(p_scb, NULL);
/* Start timer to handle timeout */
- alarm_set_on_queue(
- p_scb->codec_negotiation_timer, BTA_AG_CODEC_NEGOTIATION_TIMEOUT_MS,
- bta_ag_codec_negotiation_timer_cback, p_scb, btu_bta_alarm_queue);
+ alarm_set_on_mloop(p_scb->codec_negotiation_timer,
+ BTA_AG_CODEC_NEGOTIATION_TIMEOUT_MS,
+ bta_ag_codec_negotiation_timer_cback, p_scb);
} else {
/* use same codec type as previous SCO connection, skip codec negotiation */
APPL_TRACE_DEBUG(
#define BTA_AV_ACCEPT_SIGNALLING_TIMEOUT_MS (2 * 1000) /* 2 seconds */
#endif
-extern fixed_queue_t* btu_bta_alarm_queue;
-
static void bta_av_accept_signalling_timer_cback(void* data);
#ifndef AVRC_MIN_META_CMD_LEN
/* Possible collision : need to avoid outgoing processing while the
* timer is running */
p_cb->p_scb[xx]->coll_mask = BTA_AV_COLL_INC_TMR;
- alarm_set_on_queue(p_cb->accept_signalling_timer,
+ alarm_set_on_mloop(p_cb->accept_signalling_timer,
BTA_AV_ACCEPT_SIGNALLING_TIMEOUT_MS,
bta_av_accept_signalling_timer_cback,
- UINT_TO_PTR(xx), btu_bta_alarm_queue);
+ UINT_TO_PTR(xx));
}
break;
}
/* We are still doing SDP. Run the timer again. */
p_scb->coll_mask |= BTA_AV_COLL_INC_TMR;
- alarm_set_on_queue(p_cb->accept_signalling_timer,
+ alarm_set_on_mloop(p_cb->accept_signalling_timer,
BTA_AV_ACCEPT_SIGNALLING_TIMEOUT_MS,
bta_av_accept_signalling_timer_cback,
- UINT_TO_PTR(inx), btu_bta_alarm_queue);
+ UINT_TO_PTR(inx));
} else {
/* SNK did not start signalling, resume signalling process. */
bta_av_discover_req(p_scb, NULL);
uint8_t g_disc_raw_data_buf[MAX_DISC_RAW_DATA_BUF];
extern DEV_CLASS local_device_default_class;
-extern fixed_queue_t* btu_bta_alarm_queue;
/*******************************************************************************
*
*/
APPL_TRACE_WARNING("%s BTA_DISABLE_DELAY set to %d ms", __func__,
BTA_DISABLE_DELAY);
- alarm_set_on_queue(bta_dm_cb.disable_timer, BTA_DISABLE_DELAY,
- bta_dm_disable_conn_down_timer_cback, NULL,
- btu_bta_alarm_queue);
+ alarm_set_on_mloop(bta_dm_cb.disable_timer, BTA_DISABLE_DELAY,
+ bta_dm_disable_conn_down_timer_cback, NULL);
#else
bta_dm_disable_conn_down_timer_cback(NULL);
#endif
} else {
- alarm_set_on_queue(bta_dm_cb.disable_timer, BTA_DM_DISABLE_TIMER_MS,
- bta_dm_disable_timer_cback, UINT_TO_PTR(0),
- btu_bta_alarm_queue);
+ alarm_set_on_mloop(bta_dm_cb.disable_timer, BTA_DM_DISABLE_TIMER_MS,
+ bta_dm_disable_timer_cback, UINT_TO_PTR(0));
}
}
need
to be sent out to avoid jave layer disable timeout */
if (trigger_disc) {
- alarm_set_on_queue(
- bta_dm_cb.disable_timer, BTA_DM_DISABLE_TIMER_RETRIAL_MS,
- bta_dm_disable_timer_cback, UINT_TO_PTR(1), btu_bta_alarm_queue);
+ alarm_set_on_mloop(bta_dm_cb.disable_timer,
+ BTA_DM_DISABLE_TIMER_RETRIAL_MS,
+ bta_dm_disable_timer_cback, UINT_TO_PTR(1));
}
} else {
bta_dm_cb.disabling = false;
} else {
/* wait until link is disconnected or timeout */
bta_dm_search_cb.sdp_results = true;
- alarm_set_on_queue(bta_dm_search_cb.search_timer,
+ alarm_set_on_mloop(bta_dm_search_cb.search_timer,
1000 * (L2CAP_LINK_INACTIVITY_TOUT + 1),
- bta_dm_search_timer_cback, NULL, btu_bta_alarm_queue);
+ bta_dm_search_timer_cback, NULL);
}
}
* Start a timer to make sure that the profiles
* get the disconnect event.
*/
- alarm_set_on_queue(
- bta_dm_cb.disable_timer, BTA_DM_DISABLE_CONN_DOWN_TIMER_MS,
- bta_dm_disable_conn_down_timer_cback, NULL, btu_bta_alarm_queue);
+ alarm_set_on_mloop(bta_dm_cb.disable_timer,
+ BTA_DM_DISABLE_CONN_DOWN_TIMER_MS,
+ bta_dm_disable_conn_down_timer_cback, NULL);
}
}
if (conn.link_down.is_removed) {
BTM_SwitchRole(bta_dm_cb.device_list.peer_device[i].peer_bdaddr,
HCI_ROLE_MASTER, NULL);
} else {
- alarm_set_on_queue(
- bta_dm_cb.switch_delay_timer, BTA_DM_SWITCH_DELAY_TIMER_MS,
- bta_dm_delay_role_switch_cback, NULL, btu_bta_alarm_queue);
+ alarm_set_on_mloop(bta_dm_cb.switch_delay_timer,
+ BTA_DM_SWITCH_DELAY_TIMER_MS,
+ bta_dm_delay_role_switch_cback, NULL);
}
}
}
#include "bta_sys.h"
#include "btm_api.h"
-extern fixed_queue_t* btu_bta_alarm_queue;
-
static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, uint8_t id,
uint8_t app_id, const RawAddress& peer_addr);
static void bta_dm_pm_set_mode(const RawAddress& peer_addr,
p_timer->srvc_id[timer_idx] = srvc_id;
state_lock.unlock();
- alarm_set_on_queue(p_timer->timer[timer_idx], timeout_ms,
- bta_dm_pm_timer_cback, p_timer->timer[timer_idx],
- btu_bta_alarm_queue);
+ alarm_set_on_mloop(p_timer->timer[timer_idx], timeout_ms,
+ bta_dm_pm_timer_cback, p_timer->timer[timer_idx]);
}
/*******************************************************************************
#define BTA_HF_CLIENT_AT_HOLD_TIMEOUT 41
/******************************************************************************
- *
- * DATA TYPES AND CONTAINERS
- *
- ******************************************************************************/
-extern fixed_queue_t* btu_bta_alarm_queue;
-
-/******************************************************************************
* SUPPORTED EVENT MESSAGES
******************************************************************************/
}
static void bta_hf_client_start_at_resp_timer(tBTA_HF_CLIENT_CB* client_cb) {
- alarm_set_on_queue(client_cb->at_cb.resp_timer, BTA_HF_CLIENT_AT_TIMEOUT,
- bta_hf_client_at_resp_timer_cback, (void*)client_cb,
- btu_bta_alarm_queue);
+ alarm_set_on_mloop(client_cb->at_cb.resp_timer, BTA_HF_CLIENT_AT_TIMEOUT,
+ bta_hf_client_at_resp_timer_cback, (void*)client_cb);
}
static void bta_hf_client_stop_at_resp_timer(tBTA_HF_CLIENT_CB* client_cb) {
static void bta_hf_client_start_at_hold_timer(tBTA_HF_CLIENT_CB* client_cb) {
APPL_TRACE_DEBUG("%s", __func__);
- alarm_set_on_queue(client_cb->at_cb.hold_timer, BTA_HF_CLIENT_AT_HOLD_TIMEOUT,
- bta_hf_client_at_hold_timer_cback, (void*)client_cb,
- btu_bta_alarm_queue);
+ alarm_set_on_mloop(client_cb->at_cb.hold_timer, BTA_HF_CLIENT_AT_HOLD_TIMEOUT,
+ bta_hf_client_at_hold_timer_cback, (void*)client_cb);
}
/******************************************************************************
#include "osi/include/properties.h"
#include "utl.h"
-extern fixed_queue_t* btu_bta_alarm_queue;
-
static const char* bta_hf_client_evt_str(uint16_t event);
static const char* bta_hf_client_state_str(uint8_t state);
void bta_hf_client_cb_init(tBTA_HF_CLIENT_CB* client_cb, uint16_t handle);
// bta_hf_client_start_server();
/* Start timer to handle connection opening restart */
- alarm_set_on_queue(client_cb->collision_timer,
+ alarm_set_on_mloop(client_cb->collision_timer,
BTA_HF_CLIENT_COLLISION_TIMER_MS,
- bta_hf_client_collision_timer_cback, (void*)client_cb,
- btu_bta_alarm_queue);
+ bta_hf_client_collision_timer_cback, (void*)client_cb);
}
}
/* system manager control block definition */
tBTA_SYS_CB bta_sys_cb;
-fixed_queue_t* btu_bta_alarm_queue;
extern thread_t* bt_workqueue_thread;
/* trace level */
uint8_t appl_trace_level = BT_TRACE_LEVEL_WARNING; // APPL_INITIAL_TRACE_LEVEL;
uint8_t btif_trace_level = BT_TRACE_LEVEL_WARNING;
-// Communication queue between btu_task and bta.
-extern fixed_queue_t* btu_bta_msg_queue;
-
static const tBTA_SYS_REG bta_sys_hw_reg = {bta_sys_sm_execute, NULL};
/* type for action functions */
void bta_sys_init(void) {
memset(&bta_sys_cb, 0, sizeof(tBTA_SYS_CB));
- btu_bta_alarm_queue = fixed_queue_new(SIZE_MAX);
-
- alarm_register_processing_queue(btu_bta_alarm_queue, bt_workqueue_thread);
-
appl_trace_level = APPL_INITIAL_TRACE_LEVEL;
/* register BTA SYS message handler */
}
void bta_sys_free(void) {
- alarm_unregister_processing_queue(btu_bta_alarm_queue);
- fixed_queue_free(btu_bta_alarm_queue, NULL);
- btu_bta_alarm_queue = NULL;
}
/*******************************************************************************
p_buf->event = event;
p_buf->layer_specific = layer_specific;
- alarm_set_on_queue(alarm, interval, bta_sys_sendmsg, p_buf,
- btu_bta_alarm_queue);
+ alarm_set_on_mloop(alarm, interval, bta_sys_sendmsg, p_buf);
}
/*******************************************************************************
#include "bta/hf_client/bta_hf_client_int.h"
#include "bta/include/bta_hf_client_api.h"
+namespace base {
+class MessageLoop;
+} // namespace base
+
+base::MessageLoop* get_message_loop() { return NULL; }
+
namespace {
const RawAddress bdaddr1({0x11, 0x22, 0x33, 0x44, 0x55, 0x66});
const RawAddress bdaddr2({0x66, 0x55, 0x44, 0x33, 0x22, 0x11});
extern void btif_rc_check_handle_pending_play(const RawAddress& peer_addr,
bool bSendToApp);
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*****************************************************************************
* Local helper functions
*****************************************************************************/
*/
BTIF_TRACE_DEBUG("BTA_AV_RC_OPEN_EVT received w/o AV");
- alarm_set_on_queue(av_open_on_rc_timer, BTIF_TIMEOUT_AV_OPEN_ON_RC_MS,
- btif_initiate_av_open_timer_timeout, NULL,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(av_open_on_rc_timer, BTIF_TIMEOUT_AV_OPEN_ON_RC_MS,
+ btif_initiate_av_open_timer_timeout, NULL);
btif_rc_handler(event, (tBTA_AV*)p_data);
break;
#define LOGITECH_KB_MX5500_VENDOR_ID 0x046D
#define LOGITECH_KB_MX5500_PRODUCT_ID 0xB30B
-extern fixed_queue_t* btu_general_alarm_queue;
extern const int BT_UID;
extern const int BT_GID;
static int btif_hh_keylockstates = 0; // The current key state of each key
alarm_free(p_dev->vup_timer);
p_dev->vup_timer = alarm_new("btif_hh.vup_timer");
- alarm_set_on_queue(p_dev->vup_timer, BTIF_TIMEOUT_VUP_MS,
- btif_hh_timer_timeout, p_dev, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_dev->vup_timer, BTIF_TIMEOUT_VUP_MS,
+ btif_hh_timer_timeout, p_dev);
}
/*******************************************************************************
extern void btif_hl_release_socket(uint8_t app_idx, uint8_t mcl_idx,
uint8_t mdl_idx);
-extern fixed_queue_t* btu_general_alarm_queue;
-
btif_hl_cb_t btif_hl_cb;
btif_hl_cb_t* p_btif_hl_cb = &btif_hl_cb;
alarm_free(p_mcb->cch_timer);
p_mcb->cch_timer = alarm_new("btif_hl.mcl_cch_timer");
- alarm_set_on_queue(p_mcb->cch_timer, BTIF_TIMEOUT_CCH_NO_DCH_MS,
- btif_hl_timer_timeout, p_mcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_mcb->cch_timer, BTIF_TIMEOUT_CCH_NO_DCH_MS,
+ btif_hl_timer_timeout, p_mcb);
}
/*******************************************************************************
extern bool btif_hf_call_terminated_recently();
extern bool check_cod(const RawAddress* remote_bdaddr, uint32_t cod);
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*****************************************************************************
* Functions
*****************************************************************************/
if (p_dev->rc_play_status_timer == NULL) {
p_dev->rc_play_status_timer = alarm_new("p_dev->rc_play_status_timer");
}
- alarm_set_on_queue(p_dev->rc_play_status_timer,
- BTIF_TIMEOUT_RC_INTERIM_RSP_MS,
- btif_rc_play_status_timer_timeout,
- UINT_TO_PTR(p_dev->rc_handle), btu_general_alarm_queue);
+ alarm_set_on_mloop(
+ p_dev->rc_play_status_timer, BTIF_TIMEOUT_RC_INTERIM_RSP_MS,
+ btif_rc_play_status_timer_timeout, UINT_TO_PTR(p_dev->rc_handle));
}
}
alarm_free(p_transaction->txn_timer);
p_transaction->txn_timer = alarm_new("btif_rc.status_command_txn_timer");
- alarm_set_on_queue(p_transaction->txn_timer, BTIF_TIMEOUT_RC_INTERIM_RSP_MS,
- btif_rc_status_cmd_timer_timeout, p_context,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_transaction->txn_timer, BTIF_TIMEOUT_RC_INTERIM_RSP_MS,
+ btif_rc_status_cmd_timer_timeout, p_context);
}
static void start_status_command_timer(uint8_t pdu_id, rc_transaction_t* p_txn,
alarm_free(p_txn->txn_timer);
p_txn->txn_timer = alarm_new("btif_rc.status_command_txn_timer");
- alarm_set_on_queue(p_txn->txn_timer, BTIF_TIMEOUT_RC_STATUS_CMD_MS,
- btif_rc_status_cmd_timer_timeout, p_context,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_txn->txn_timer, BTIF_TIMEOUT_RC_STATUS_CMD_MS,
+ btif_rc_status_cmd_timer_timeout, p_context);
}
static void start_control_command_timer(uint8_t pdu_id, rc_transaction_t* p_txn,
alarm_free(p_txn->txn_timer);
p_txn->txn_timer = alarm_new("btif_rc.control_command_txn_timer");
- alarm_set_on_queue(p_txn->txn_timer, BTIF_TIMEOUT_RC_CONTROL_CMD_MS,
- btif_rc_control_cmd_timer_timeout, p_context,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_txn->txn_timer, BTIF_TIMEOUT_RC_CONTROL_CMD_MS,
+ btif_rc_control_cmd_timer_timeout, p_context);
}
bt_status_t build_and_send_vendor_cmd(tAVRC_COMMAND* avrc_cmd,
void alarm_set(alarm_t* alarm, period_ms_t interval_ms, alarm_callback_t cb,
void* data);
-// Sets an |alarm| to execute a callback in the future on a
-// specific |queue|. This function is same as |alarm_set| except
-// that the |cb| callback is scheduled for execution in the
-// context of the thread responsible for processing |queue|.
-// Also, the callback execution ordering guarantee exists only
-// among alarms that are scheduled on the same queue. |queue|
-// may not be NULL.
-void alarm_set_on_queue(alarm_t* alarm, period_ms_t interval_ms,
- alarm_callback_t cb, void* data, fixed_queue_t* queue);
+// 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,
+ alarm_callback_t cb, void* data);
// This function cancels the |alarm| if it was previously set.
// When this call returns, the caller has a guarantee that the
// Return true if the |alarm| is scheduled or NULL, otherwise false.
bool alarm_is_scheduled(const alarm_t* alarm);
-// Registers |queue| for processing alarm callbacks on |thread|.
-// |queue| may not be NULL. |thread| may not be NULL.
-void alarm_register_processing_queue(fixed_queue_t* queue, thread_t* thread);
-
-// Unregisters |queue| for processing alarm callbacks on whichever thread
-// it is registered with. All alarms currently set for execution on |queue|
-// will be canceled. |queue| may not be NULL. This function is idempotent.
-void alarm_unregister_processing_queue(fixed_queue_t* queue);
-
// 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
#include "osi/include/alarm.h"
+#include <base/cancelable_callback.h>
#include <base/logging.h>
+#include <base/message_loop/message_loop.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include "osi/include/thread.h"
#include "osi/include/wakelock.h"
+using base::Bind;
+using base::CancelableClosure;
+using base::MessageLoop;
+
+extern base::MessageLoop* get_message_loop();
+
// Callback and timer threads should run at RT priority in order to ensure they
// meet audio deadlines. Use this priority for all audio/timer related thread.
static const int THREAD_RT_PRIORITY = 1;
stat_t premature_scheduling;
} alarm_stats_t;
+/* Wrapper around CancellableClosure that let it be embedded in structs, without
+ * need to define copy operator. */
+struct CancelableClosureInStruct {
+ base::CancelableClosure i;
+
+ CancelableClosureInStruct& operator=(const CancelableClosureInStruct& in) {
+ if (!in.i.callback().is_null()) i.Reset(in.i.callback());
+ return *this;
+ }
+};
+
struct alarm_t {
// The mutex is held while the callback for this alarm is being executed.
// It allows us to release the coarse-grained monitor lock while a
alarm_callback_t callback;
void* data;
alarm_stats_t stats;
+
+ bool for_msg_loop; // True, if the alarm should be processed on message loop
+ CancelableClosureInStruct closure; // posted to message loop for processing
};
// If the next wakeup time is less than this threshold, we should acquire
static period_ms_t now(void);
static void alarm_set_internal(alarm_t* alarm, period_ms_t period,
alarm_callback_t cb, void* data,
- fixed_queue_t* queue);
+ fixed_queue_t* queue, bool for_msg_loop);
static void alarm_cancel_internal(alarm_t* alarm);
static void remove_pending_alarm(alarm_t* alarm);
static void schedule_next_instance(alarm_t* alarm);
static void update_scheduling_stats(alarm_stats_t* stats, period_ms_t now_ms,
period_ms_t deadline_ms,
period_ms_t execution_delta_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;
ret->callback_mutex = new std::recursive_mutex;
ret->is_periodic = is_periodic;
ret->stats.name = osi_strdup(name);
+
+ ret->for_msg_loop = false;
+ // placement new
+ new (&ret->closure) CancelableClosureInStruct();
+
// NOTE: The stats were reset by osi_calloc() above
return ret;
alarm_cancel(alarm);
delete alarm->callback_mutex;
osi_free((void*)alarm->stats.name);
+ alarm->closure.~CancelableClosureInStruct();
osi_free(alarm);
}
void alarm_set(alarm_t* alarm, period_ms_t interval_ms, alarm_callback_t cb,
void* data) {
- alarm_set_on_queue(alarm, interval_ms, cb, data, default_callback_queue);
+ alarm_set_internal(alarm, interval_ms, cb, data, default_callback_queue,
+ false);
}
-void alarm_set_on_queue(alarm_t* alarm, period_ms_t interval_ms,
- alarm_callback_t cb, void* data, fixed_queue_t* queue) {
- CHECK(queue != NULL);
- alarm_set_internal(alarm, interval_ms, cb, data, queue);
+void alarm_set_on_mloop(alarm_t* alarm, period_ms_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,
alarm_callback_t cb, void* data,
- fixed_queue_t* queue) {
+ fixed_queue_t* queue, bool for_msg_loop) {
CHECK(alarms != NULL);
CHECK(alarm != NULL);
CHECK(cb != NULL);
alarm->queue = queue;
alarm->callback = cb;
alarm->data = data;
+ alarm->for_msg_loop = for_msg_loop;
schedule_next_instance(alarm);
alarm->stats.scheduled_count++;
// The caller must hold the |alarms_mutex|
static void remove_pending_alarm(alarm_t* alarm) {
list_remove(alarms, alarm);
- while (fixed_queue_try_remove_from_queue(alarm->queue, alarm) != NULL) {
- // Remove all repeated alarm instances from the queue.
- // NOTE: We are defensive here - we shouldn't have repeated alarm instances
+
+ if (alarm->for_msg_loop) {
+ alarm->closure.i.Cancel();
+ } else {
+ while (fixed_queue_try_remove_from_queue(alarm->queue, alarm) != NULL) {
+ // Remove all repeated alarm instances from the queue.
+ // NOTE: We are defensive here - we shouldn't have repeated alarm
+ // instances
+ }
}
}
}
}
-void alarm_register_processing_queue(fixed_queue_t* queue, thread_t* thread) {
+static void alarm_register_processing_queue(fixed_queue_t* queue,
+ thread_t* thread) {
CHECK(queue != NULL);
CHECK(thread != NULL);
alarm_queue_ready, NULL);
}
-void alarm_unregister_processing_queue(fixed_queue_t* queue) {
- CHECK(alarms != NULL);
- CHECK(queue != NULL);
-
- fixed_queue_unregister_dequeue(queue);
-
- // Cancel all alarms that are using this queue
- std::lock_guard<std::mutex> lock(alarms_mutex);
- for (list_node_t* node = list_begin(alarms); node != list_end(alarms);) {
- alarm_t* alarm = (alarm_t*)list_node(node);
- node = list_next(node);
- // TODO: Each module is responsible for tearing down its alarms; currently,
- // this is not the case. In the future, this check should be replaced by
- // an assert.
- if (alarm->queue == queue) alarm_cancel_internal(alarm);
- }
-}
-
-static void alarm_queue_ready(fixed_queue_t* queue, UNUSED_ATTR void* context) {
- CHECK(queue != NULL);
-
- std::unique_lock<std::mutex> lock(alarms_mutex);
- alarm_t* alarm = (alarm_t*)fixed_queue_try_dequeue(queue);
+static void alarm_ready_generic(alarm_t* alarm,
+ std::unique_lock<std::mutex>& lock) {
if (alarm == NULL) {
return; // The alarm was probably canceled
}
-
//
// If the alarm is not periodic, we've fully serviced it now, and can reset
// some of its internal state. This is useful to distinguish between expired
update_scheduling_stats(&alarm->stats, t0, deadline, delta);
}
+static void alarm_ready_mloop(alarm_t* alarm) {
+ std::unique_lock<std::mutex> lock(alarms_mutex);
+ alarm_ready_generic(alarm, lock);
+}
+
+static void alarm_queue_ready(fixed_queue_t* queue, UNUSED_ATTR void* context) {
+ CHECK(queue != NULL);
+
+ std::unique_lock<std::mutex> lock(alarms_mutex);
+ alarm_t* alarm = (alarm_t*)fixed_queue_try_dequeue(queue);
+ alarm_ready_generic(alarm, lock);
+}
+
// Callback function for wake alarms and our posix timer
static void timer_callback(UNUSED_ATTR void* ptr) {
semaphore_post(alarm_expired);
reschedule_root_alarm();
// Enqueue the alarm for processing
- fixed_queue_enqueue(alarm->queue, alarm);
+ if (alarm->for_msg_loop) {
+ if (!get_message_loop()) {
+ LOG_ERROR(LOG_TAG, "%s: message loop already NULL. Alarm: %s", __func__,
+ alarm->stats.name);
+ continue;
+ }
+
+ alarm->closure.i.Reset(Bind(alarm_ready_mloop, alarm));
+ get_message_loop()->PostTask(FROM_HERE, alarm->closure.i.callback());
+ } else {
+ fixed_queue_enqueue(alarm->queue, alarm);
+ }
}
LOG_DEBUG(LOG_TAG, "%s Callback thread exited", __func__);
*
******************************************************************************/
+#include <base/message_loop/message_loop.h>
+#include <base/run_loop.h>
#include <gtest/gtest.h>
#include "AlarmTestHarness.h"
#include "osi/include/semaphore.h"
#include "osi/include/thread.h"
+using base::Closure;
+using base::TimeDelta;
+
static semaphore_t* semaphore;
static int cb_counter;
static int cb_misordered_counter;
static void msleep(uint64_t ms) { usleep(ms * 1000); }
+base::MessageLoop* message_loop_;
+base::RunLoop* run_loop_;
+static semaphore_t* msg_loop_ready;
+
+void message_loop_run(UNUSED_ATTR void* context) {
+ message_loop_ = new base::MessageLoop();
+ run_loop_ = new base::RunLoop();
+
+ semaphore_post(msg_loop_ready);
+ run_loop_->Run();
+
+ delete message_loop_;
+ message_loop_ = nullptr;
+
+ delete run_loop_;
+ run_loop_ = nullptr;
+}
+
+base::MessageLoop* get_message_loop() { return message_loop_; }
+
class AlarmTest : public AlarmTestHarness {
protected:
virtual void SetUp() {
}
// Test whether the callbacks are involed in the expected order on a
-// separate queue.
-TEST_F(AlarmTest, test_callback_ordering_on_queue) {
+// message loop.
+TEST_F(AlarmTest, test_callback_ordering_on_mloop) {
alarm_t* alarms[100];
- fixed_queue_t* queue = fixed_queue_new(SIZE_MAX);
- thread_t* thread =
- thread_new("timers.test_callback_ordering_on_queue.thread");
- alarm_register_processing_queue(queue, thread);
+ // Initialize MesageLoop, and wait till it's initialized.
+ msg_loop_ready = semaphore_new(0);
+ thread_t* message_loop_thread_ = thread_new("btu message loop");
+ if (!message_loop_thread_) {
+ FAIL() << "unable to create btu message loop thread.";
+ }
+
+ thread_post(message_loop_thread_, message_loop_run, nullptr);
+ semaphore_wait(msg_loop_ready);
+ semaphore_free(msg_loop_ready);
for (int i = 0; i < 100; i++) {
const std::string alarm_name =
- "alarm_test.test_callback_ordering_on_queue[" + std::to_string(i) + "]";
+ "alarm_test.test_callback_ordering_on_mloop[" + std::to_string(i) + "]";
alarms[i] = alarm_new(alarm_name.c_str());
}
for (int i = 0; i < 100; i++) {
- alarm_set_on_queue(alarms[i], 100, ordered_cb, INT_TO_PTR(i), queue);
+ alarm_set_on_mloop(alarms[i], 100, ordered_cb, INT_TO_PTR(i));
}
for (int i = 1; i <= 100; i++) {
for (int i = 0; i < 100; i++) alarm_free(alarms[i]);
+ message_loop_->PostTask(FROM_HERE, run_loop_->QuitWhenIdleClosure());
+ thread_free(message_loop_thread_);
EXPECT_FALSE(WakeLockHeld());
-
- alarm_unregister_processing_queue(queue);
- fixed_queue_free(queue, NULL);
- thread_free(thread);
-}
-
-// Test whether unregistering a processing queue cancels all timers using
-// that queue.
-TEST_F(AlarmTest, test_unregister_processing_queue) {
- alarm_t* alarms[100];
- fixed_queue_t* queue = fixed_queue_new(SIZE_MAX);
- thread_t* thread =
- thread_new("timers.test_unregister_processing_queue.thread");
-
- alarm_register_processing_queue(queue, thread);
-
- for (int i = 0; i < 100; i++) {
- const std::string alarm_name =
- "alarm_test.test_unregister_processing_queue[" + std::to_string(i) +
- "]";
- alarms[i] = alarm_new(alarm_name.c_str());
- }
-
- // Schedule half of the timers to expire soon, and the rest far in the future
- for (int i = 0; i < 50; i++) {
- alarm_set_on_queue(alarms[i], 100, ordered_cb, INT_TO_PTR(i), queue);
- }
- for (int i = 50; i < 100; i++) {
- alarm_set_on_queue(alarms[i], 1000 * 1000, ordered_cb, INT_TO_PTR(i),
- queue);
- }
-
- // Wait until half of the timers have expired
- for (int i = 1; i <= 50; i++) {
- semaphore_wait(semaphore);
- EXPECT_GE(cb_counter, i);
- }
- EXPECT_EQ(cb_counter, 50);
- EXPECT_EQ(cb_misordered_counter, 0);
-
- // Test that only the expired timers are not scheduled
- for (int i = 0; i < 50; i++) {
- EXPECT_FALSE(alarm_is_scheduled(alarms[i]));
- }
- for (int i = 50; i < 100; i++) {
- EXPECT_TRUE(alarm_is_scheduled(alarms[i]));
- }
-
- alarm_unregister_processing_queue(queue);
-
- // Test that none of the timers are scheduled
- for (int i = 0; i < 100; i++) {
- EXPECT_FALSE(alarm_is_scheduled(alarms[i]));
- }
-
- for (int i = 0; i < 100; i++) {
- alarm_free(alarms[i]);
- }
-
- EXPECT_FALSE(WakeLockHeld());
-
- fixed_queue_free(queue, NULL);
- thread_free(thread);
-}
-
-// Test whether unregistering a processing queue cancels all periodic timers
-// using that queue.
-TEST_F(AlarmTest, test_periodic_unregister_processing_queue) {
- alarm_t* alarms[5];
- fixed_queue_t* queue = fixed_queue_new(SIZE_MAX);
- thread_t* thread =
- thread_new("timers.test_periodic_unregister_processing_queue.thread");
-
- alarm_register_processing_queue(queue, thread);
-
- for (int i = 0; i < 5; i++) {
- const std::string alarm_name =
- "alarm_test.test_periodic_unregister_processing_queue[" +
- std::to_string(i) + "]";
- alarms[i] = alarm_new_periodic(alarm_name.c_str());
- }
-
- // Schedule each of the timers with different period
- for (int i = 0; i < 5; i++) {
- alarm_set_on_queue(alarms[i], 20 + i, cb, INT_TO_PTR(i), queue);
- }
- EXPECT_TRUE(WakeLockHeld());
-
- for (int i = 1; i <= 20; i++) {
- semaphore_wait(semaphore);
-
- EXPECT_GE(cb_counter, i);
- EXPECT_TRUE(WakeLockHeld());
- }
-
- // Test that all timers are still scheduled
- for (int i = 0; i < 5; i++) {
- EXPECT_TRUE(alarm_is_scheduled(alarms[i]));
- }
-
- alarm_unregister_processing_queue(queue);
-
- int saved_cb_counter = cb_counter;
-
- // Test that none of the timers are scheduled
- for (int i = 0; i < 5; i++) {
- EXPECT_FALSE(alarm_is_scheduled(alarms[i]));
- }
-
- // Sleep for 500ms and test again that the cb_counter hasn't been modified
- usleep(500 * 1000);
- EXPECT_TRUE(cb_counter == saved_cb_counter);
-
- for (int i = 0; i < 5; i++) {
- alarm_free(alarms[i]);
- }
-
- EXPECT_FALSE(WakeLockHeld());
-
- fixed_queue_free(queue, NULL);
- thread_free(thread);
}
// Try to catch any race conditions between the timer callback and |alarm_free|.
#include "btu.h"
#include "osi/include/osi.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*******************************************************************************
*
* Function avdt_ccb_clear_ccb
alarm_cancel(p_ccb->ret_ccb_timer);
alarm_cancel(p_ccb->rsp_ccb_timer);
period_ms_t interval_ms = avdt_cb.rcb.idle_tout * 1000;
- alarm_set_on_queue(p_ccb->idle_ccb_timer, interval_ms,
- avdt_ccb_idle_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->idle_ccb_timer, interval_ms,
+ avdt_ccb_idle_ccb_timer_timeout, p_ccb);
}
}
alarm_cancel(p_ccb->idle_ccb_timer);
alarm_cancel(p_ccb->rsp_ccb_timer);
period_ms_t interval_ms = avdt_cb.rcb.ret_tout * 1000;
- alarm_set_on_queue(p_ccb->ret_ccb_timer, interval_ms,
- avdt_ccb_ret_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->ret_ccb_timer, interval_ms,
+ avdt_ccb_ret_ccb_timer_timeout, p_ccb);
}
}
#include "btu.h"
#include "osi/include/osi.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*****************************************************************************
* constants
****************************************************************************/
alarm_cancel(p_ccb->idle_ccb_timer);
alarm_cancel(p_ccb->ret_ccb_timer);
period_ms_t interval_ms = avdt_cb.rcb.sig_tout * 1000;
- alarm_set_on_queue(p_ccb->rsp_ccb_timer, interval_ms,
- avdt_ccb_rsp_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ 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 = avdt_cb.rcb.ret_tout * 1000;
- alarm_set_on_queue(p_ccb->ret_ccb_timer, interval_ms,
- avdt_ccb_ret_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->ret_ccb_timer, interval_ms,
+ avdt_ccb_ret_ccb_timer_timeout, p_ccb);
}
}
} else {
#include "btu.h"
#include "osi/include/osi.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/* This table is used to lookup the callback event that matches a particular
* state machine API request event. Note that state machine API request
* events are at the beginning of the event list starting at zero, thus
avdt_ad_open_req(AVDT_CHAN_MEDIA, p_scb->p_ccb, p_scb, AVDT_INT);
/* start tc connect timer */
- alarm_set_on_queue(
- p_scb->transport_channel_timer, AVDT_SCB_TC_CONN_TIMEOUT_MS,
- avdt_scb_transport_channel_timer_timeout, p_scb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_scb->transport_channel_timer,
+ AVDT_SCB_TC_CONN_TIMEOUT_MS,
+ avdt_scb_transport_channel_timer_timeout, p_scb);
}
/*******************************************************************************
/* send response */
avdt_msg_send_rsp(p_scb->p_ccb, AVDT_SIG_OPEN, &p_data->msg);
- alarm_set_on_queue(
- p_scb->transport_channel_timer, AVDT_SCB_TC_CONN_TIMEOUT_MS,
- avdt_scb_transport_channel_timer_timeout, p_scb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_scb->transport_channel_timer,
+ AVDT_SCB_TC_CONN_TIMEOUT_MS,
+ avdt_scb_transport_channel_timer_timeout, p_scb);
}
/*******************************************************************************
******************************************************************************/
void avdt_scb_transport_channel_timer(tAVDT_SCB* p_scb,
UNUSED_ATTR tAVDT_SCB_EVT* p_data) {
- alarm_set_on_queue(
- p_scb->transport_channel_timer, AVDT_SCB_TC_DISC_TIMEOUT_MS,
- avdt_scb_transport_channel_timer_timeout, p_scb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_scb->transport_channel_timer,
+ AVDT_SCB_TC_DISC_TIMEOUT_MS,
+ avdt_scb_transport_channel_timer_timeout, p_scb);
}
/*******************************************************************************
/*****************************************************************************
* Global data
****************************************************************************/
-extern fixed_queue_t* btu_general_alarm_queue;
#define AVRC_MAX_RCV_CTRL_EVT AVCT_BROWSE_UNCONG_IND_EVT
AVRC_TRACE_DEBUG("AVRC: starting timer (handle=0x%02x, label=0x%02x)", handle,
label);
- alarm_set_on_queue(avrc_cb.ccb_int[handle].tle, AVRC_CMD_TOUT_MS,
- avrc_process_timeout, param, btu_general_alarm_queue);
+ alarm_set_on_mloop(avrc_cb.ccb_int[handle].tle, AVRC_CMD_TOUT_MS,
+ avrc_process_timeout, param);
}
/******************************************************************************
#include <string.h>
#include "bnep_int.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*******************************************************************************
*
* Function BNEP_Init
}
/* Start timer waiting for connect */
- alarm_set_on_queue(p_bcb->conn_timer, BNEP_CONN_TIMEOUT_MS,
- bnep_conn_timer_timeout, p_bcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_bcb->conn_timer, BNEP_CONN_TIMEOUT_MS,
+ bnep_conn_timer_timeout, p_bcb);
}
*p_handle = p_bcb->handle;
#include "device/include/controller.h"
#include "osi/include/osi.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/******************************************************************************/
/* G L O B A L B N E P D A T A */
/******************************************************************************/
L2CA_ConfigReq(l2cap_cid, &bnep_cb.l2cap_my_cfg);
/* Start timer waiting for config setup */
- alarm_set_on_queue(p_bcb->conn_timer, BNEP_CONN_TIMEOUT_MS,
- bnep_conn_timer_timeout, p_bcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_bcb->conn_timer, BNEP_CONN_TIMEOUT_MS,
+ bnep_conn_timer_timeout, p_bcb);
BNEP_TRACE_EVENT("BNEP - Rcvd L2CAP conn ind, CID: 0x%x", p_bcb->l2cap_cid);
}
L2CA_ConfigReq(l2cap_cid, &bnep_cb.l2cap_my_cfg);
/* Start timer waiting for config results */
- alarm_set_on_queue(p_bcb->conn_timer, BNEP_CONN_TIMEOUT_MS,
- bnep_conn_timer_timeout, p_bcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_bcb->conn_timer, BNEP_CONN_TIMEOUT_MS,
+ bnep_conn_timer_timeout, p_bcb);
BNEP_TRACE_EVENT("BNEP - got conn cnf, sent cfg req, CID: 0x%x",
p_bcb->l2cap_cid);
p_bcb->con_state = BNEP_STATE_SEC_CHECKING;
/* Start timer waiting for setup or response */
- alarm_set_on_queue(p_bcb->conn_timer, BNEP_HOST_TIMEOUT_MS,
- bnep_conn_timer_timeout, p_bcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_bcb->conn_timer, BNEP_HOST_TIMEOUT_MS,
+ bnep_conn_timer_timeout, p_bcb);
if (p_bcb->con_flags & BNEP_FLAGS_IS_ORIG) {
btm_sec_mx_access_request(
p_bcb->con_state = BNEP_STATE_SEC_CHECKING;
/* Start timer waiting for setup or response */
- alarm_set_on_queue(p_bcb->conn_timer, BNEP_HOST_TIMEOUT_MS,
- bnep_conn_timer_timeout, p_bcb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_bcb->conn_timer, BNEP_HOST_TIMEOUT_MS,
+ bnep_conn_timer_timeout, p_bcb);
if (p_bcb->con_flags & BNEP_FLAGS_IS_ORIG) {
btm_sec_mx_access_request(p_bcb->rem_bda, BT_PSM_BNEP, true,
if (p_bcb->re_transmits++ != BNEP_MAX_RETRANSMITS) {
bnep_send_conn_req(p_bcb);
- alarm_set_on_queue(p_bcb->conn_timer, BNEP_CONN_TIMEOUT_MS,
- bnep_conn_timer_timeout, p_bcb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_bcb->conn_timer, BNEP_CONN_TIMEOUT_MS,
+ bnep_conn_timer_timeout, p_bcb);
} else {
L2CA_DisconnectReq(p_bcb->l2cap_cid);
} else if (p_bcb->con_flags & BNEP_FLAGS_FILTER_RESP_PEND) {
if (p_bcb->re_transmits++ != BNEP_MAX_RETRANSMITS) {
bnepu_send_peer_our_filters(p_bcb);
- alarm_set_on_queue(p_bcb->conn_timer, BNEP_FILTER_SET_TIMEOUT_MS,
- bnep_conn_timer_timeout, p_bcb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_bcb->conn_timer, BNEP_FILTER_SET_TIMEOUT_MS,
+ bnep_conn_timer_timeout, p_bcb);
} else {
L2CA_DisconnectReq(p_bcb->l2cap_cid);
} else if (p_bcb->con_flags & BNEP_FLAGS_MULTI_RESP_PEND) {
if (p_bcb->re_transmits++ != BNEP_MAX_RETRANSMITS) {
bnepu_send_peer_our_multi_filters(p_bcb);
- alarm_set_on_queue(p_bcb->conn_timer, BNEP_FILTER_SET_TIMEOUT_MS,
- bnep_conn_timer_timeout, p_bcb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_bcb->conn_timer, BNEP_FILTER_SET_TIMEOUT_MS,
+ bnep_conn_timer_timeout, p_bcb);
} else {
L2CA_DisconnectReq(p_bcb->l2cap_cid);
#include "device/include/controller.h"
#include "osi/include/osi.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/******************************************************************************/
/* L O C A L F U N C T I O N P R O T O T Y P E S */
/******************************************************************************/
p_bcb->con_flags |= BNEP_FLAGS_FILTER_RESP_PEND;
/* Start timer waiting for setup response */
- alarm_set_on_queue(p_bcb->conn_timer, BNEP_FILTER_SET_TIMEOUT_MS,
- bnep_conn_timer_timeout, p_bcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_bcb->conn_timer, BNEP_FILTER_SET_TIMEOUT_MS,
+ bnep_conn_timer_timeout, p_bcb);
}
/*******************************************************************************
p_bcb->con_flags |= BNEP_FLAGS_MULTI_RESP_PEND;
/* Start timer waiting for setup response */
- alarm_set_on_queue(p_bcb->conn_timer, BNEP_FILTER_SET_TIMEOUT_MS,
- bnep_conn_timer_timeout, p_bcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_bcb->conn_timer, BNEP_FILTER_SET_TIMEOUT_MS,
+ bnep_conn_timer_timeout, p_bcb);
}
/*******************************************************************************
p_bcb->con_state = BNEP_STATE_CONN_SETUP;
bnep_send_conn_req(p_bcb);
- alarm_set_on_queue(p_bcb->conn_timer, BNEP_CONN_TIMEOUT_MS,
- bnep_conn_timer_timeout, p_bcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_bcb->conn_timer, BNEP_CONN_TIMEOUT_MS,
+ bnep_conn_timer_timeout, p_bcb);
return;
}
#include "l2c_int.h"
#include "osi/include/osi.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
static void btm_read_remote_features(uint16_t handle);
static void btm_read_remote_ext_features(uint16_t handle, uint8_t page_number);
static void btm_process_remote_ext_features(tACL_CONN* p_acl_cb,
p = btm_bda_to_acl(bd, BT_TRANSPORT_BR_EDR);
if (p != NULL) {
btm_cb.devcb.p_qos_setup_cmpl_cb = p_cb;
- alarm_set_on_queue(btm_cb.devcb.qos_setup_timer, BTM_DEV_REPLY_TIMEOUT_MS,
- btm_qos_setup_timeout, NULL, btu_general_alarm_queue);
+ alarm_set_on_mloop(btm_cb.devcb.qos_setup_timer, BTM_DEV_REPLY_TIMEOUT_MS,
+ btm_qos_setup_timeout, NULL);
btsnd_hcic_qos_setup(p->hci_handle, p_flow->qos_flags, p_flow->service_type,
p_flow->token_rate, p_flow->peak_bandwidth,
p = btm_bda_to_acl(remote_bda, transport);
if (p != (tACL_CONN*)NULL) {
btm_cb.devcb.p_rssi_cmpl_cb = p_cb;
- alarm_set_on_queue(btm_cb.devcb.read_rssi_timer, BTM_DEV_REPLY_TIMEOUT_MS,
- btm_read_rssi_timeout, NULL, btu_general_alarm_queue);
+ alarm_set_on_mloop(btm_cb.devcb.read_rssi_timer, BTM_DEV_REPLY_TIMEOUT_MS,
+ btm_read_rssi_timeout, NULL);
btsnd_hcic_read_rssi(p->hci_handle);
return (BTM_CMD_STARTED);
p = btm_bda_to_acl(remote_bda, transport);
if (p != (tACL_CONN*)NULL) {
btm_cb.devcb.p_failed_contact_counter_cmpl_cb = p_cb;
- alarm_set_on_queue(btm_cb.devcb.read_failed_contact_counter_timer,
+ alarm_set_on_mloop(btm_cb.devcb.read_failed_contact_counter_timer,
BTM_DEV_REPLY_TIMEOUT_MS,
- btm_read_failed_contact_counter_timeout, NULL,
- btu_general_alarm_queue);
+ btm_read_failed_contact_counter_timeout, NULL);
btsnd_hcic_read_failed_contact_counter(p->hci_handle);
return (BTM_CMD_STARTED);
if (!p) return BTM_UNKNOWN_ADDR;
btm_cb.devcb.p_automatic_flush_timeout_cmpl_cb = p_cb;
- alarm_set_on_queue(btm_cb.devcb.read_automatic_flush_timeout_timer,
+ alarm_set_on_mloop(btm_cb.devcb.read_automatic_flush_timeout_timer,
BTM_DEV_REPLY_TIMEOUT_MS,
- btm_read_automatic_flush_timeout_timeout, nullptr,
- btu_general_alarm_queue);
+ btm_read_automatic_flush_timeout_timeout, nullptr);
btsnd_hcic_read_automatic_flush_timeout(p->hci_handle);
return BTM_CMD_STARTED;
tACL_CONN* p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
if (p != (tACL_CONN*)NULL) {
btm_cb.devcb.p_link_qual_cmpl_cb = p_cb;
- alarm_set_on_queue(btm_cb.devcb.read_link_quality_timer,
+ alarm_set_on_mloop(btm_cb.devcb.read_link_quality_timer,
BTM_DEV_REPLY_TIMEOUT_MS, btm_read_link_quality_timeout,
- NULL, btu_general_alarm_queue);
+ NULL);
btsnd_hcic_get_link_quality(p->hci_handle);
return (BTM_CMD_STARTED);
p = btm_bda_to_acl(remote_bda, transport);
if (p != (tACL_CONN*)NULL) {
btm_cb.devcb.p_tx_power_cmpl_cb = p_cb;
- alarm_set_on_queue(btm_cb.devcb.read_tx_power_timer,
+ alarm_set_on_mloop(btm_cb.devcb.read_tx_power_timer,
BTM_DEV_REPLY_TIMEOUT_MS, btm_read_tx_power_timeout,
- NULL, btu_general_alarm_queue);
+ NULL);
if (p->transport == BT_TRANSPORT_LE) {
btm_cb.devcb.read_tx_pwr_addr = remote_bda;
#include "btm_ble_int.h"
#include "smp_api.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*******************************************************************************
*
* Function btm_gen_resolve_paddr_cmpl
#if (BTM_BLE_CONFORMANCE_TESTING == TRUE)
interval_ms = btm_cb.ble_ctr_cb.rpa_tout * 1000;
#endif
- alarm_set_on_queue(p_cb->refresh_raddr_timer, interval_ms,
- btm_ble_refresh_raddr_timer_timeout, NULL,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_cb->refresh_raddr_timer, interval_ms,
+ btm_ble_refresh_raddr_timer_timeout, NULL);
} else {
/* random address set failure */
BTM_TRACE_DEBUG("set random address failed");
#define MIN_ADV_LENGTH 2
#define BTM_VSC_CHIP_CAPABILITY_RSP_LEN_L_RELEASE 9
-extern fixed_queue_t* btu_general_alarm_queue;
-
namespace {
class AdvertisingCache {
if (duration != 0) {
/* start observer timer */
period_ms_t duration_ms = duration * 1000;
- alarm_set_on_queue(btm_cb.ble_ctr_cb.observer_timer, duration_ms,
- btm_ble_observer_timer_timeout, NULL,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(btm_cb.ble_ctr_cb.observer_timer, duration_ms,
+ btm_ble_observer_timer_timeout, NULL);
}
}
} else if (BTM_BLE_IS_OBS_ACTIVE(btm_cb.ble_ctr_cb.scan_activity)) {
if (p_cb->adv_mode == BTM_BLE_ADV_ENABLE) {
p_cb->fast_adv_on = true;
/* start initial GAP mode adv timer */
- alarm_set_on_queue(p_cb->fast_adv_timer, BTM_BLE_GAP_FAST_ADV_TIMEOUT_MS,
- btm_ble_fast_adv_timer_timeout, NULL,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_cb->fast_adv_timer, BTM_BLE_GAP_FAST_ADV_TIMEOUT_MS,
+ btm_ble_fast_adv_timer_timeout, NULL);
} else {
#if (BLE_PRIVACY_SPT == TRUE)
btm_ble_disable_resolving_list(BTM_BLE_RL_ADV, true);
BTM_TRACE_EVENT("start timer for limited disc mode duration=%d ms",
BTM_BLE_GAP_LIM_TIMEOUT_MS);
/* start Tgap(lim_timeout) */
- alarm_set_on_queue(p_cb->inquiry_timer, BTM_BLE_GAP_LIM_TIMEOUT_MS,
+ alarm_set_on_mloop(p_cb->inquiry_timer, BTM_BLE_GAP_LIM_TIMEOUT_MS,
btm_ble_inquiry_timer_gap_limited_discovery_timeout,
- NULL, btu_general_alarm_queue);
+ NULL);
}
return status;
}
if (p_cb->adv_mode == BTM_BLE_ADV_ENABLE) {
p_cb->fast_adv_on = true;
/* start initial GAP mode adv timer */
- alarm_set_on_queue(p_cb->fast_adv_timer, BTM_BLE_GAP_FAST_ADV_TIMEOUT_MS,
- btm_ble_fast_adv_timer_timeout, NULL,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_cb->fast_adv_timer, BTM_BLE_GAP_FAST_ADV_TIMEOUT_MS,
+ btm_ble_fast_adv_timer_timeout, NULL);
} else {
#if (BLE_PRIVACY_SPT == TRUE)
btm_ble_disable_resolving_list(BTM_BLE_RL_ADV, true);
if (duration != 0) {
/* start inquiry timer */
period_ms_t duration_ms = duration * 1000;
- alarm_set_on_queue(p_ble_cb->inq_var.inquiry_timer, duration_ms,
- btm_ble_inquiry_timer_timeout, NULL,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ble_cb->inq_var.inquiry_timer, duration_ms,
+ btm_ble_inquiry_timer_timeout, NULL);
}
}
p_inq->remname_active = true;
p_inq->remname_bda = remote_bda;
- alarm_set_on_queue(p_inq->remote_name_timer, BTM_EXT_BLE_RMT_NAME_TIMEOUT_MS,
- btm_inq_remote_name_timer_timeout, NULL,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_inq->remote_name_timer, BTM_EXT_BLE_RMT_NAME_TIMEOUT_MS,
+ btm_inq_remote_name_timer_timeout, NULL);
return BTM_CMD_STARTED;
}
uint8_t /* inst_id */, int8_t /* tx_power */, uint8_t /* status */)>;
extern void btm_gen_resolvable_private_addr(
base::Callback<void(uint8_t[8])> cb);
-extern fixed_queue_t* btu_general_alarm_queue;
constexpr int ADV_DATA_LEN_MAX = 251;
}
// Periodic alarms are not supported, because we clean up data in callback
-void alarm_set_closure_on_queue(const tracked_objects::Location& posted_from,
- alarm_t* alarm, period_ms_t interval_ms,
- base::Closure user_task, fixed_queue_t* queue) {
+void alarm_set_closure(const tracked_objects::Location& posted_from,
+ alarm_t* alarm, period_ms_t interval_ms,
+ base::Closure user_task) {
closure_data* data = new closure_data;
data->posted_from = posted_from;
data->user_task = std::move(user_task);
VLOG(1) << "scheduling timer %s" << data->posted_from.ToString();
- alarm_set_on_queue(alarm, interval_ms, alarm_closure_cb, data, queue);
+ alarm_set_on_mloop(alarm, interval_ms, alarm_closure_cb, data);
}
class BleAdvertisingManagerImpl;
RawAddress bda) {
p_inst->own_address = bda;
- alarm_set_on_queue(p_inst->adv_raddr_timer,
+ alarm_set_on_mloop(p_inst->adv_raddr_timer,
BTM_BLE_PRIVATE_ADDR_INT_MS,
- btm_ble_adv_raddr_timer_timeout, p_inst,
- btu_general_alarm_queue);
+ btm_ble_adv_raddr_timer_timeout, p_inst);
cb.Run(p_inst->inst_id, BTM_BLE_MULTI_ADV_SUCCESS);
},
p_inst, cb));
std::move(timeout_cb), 0, 0, base::Bind(DoNothing));
// schedule disable when the timeout passes
- alarm_set_closure_on_queue(FROM_HERE, p_inst->timeout_timer, duration * 10,
- std::move(cb), btu_general_alarm_queue);
+ alarm_set_closure(FROM_HERE, p_inst->timeout_timer, duration * 10,
+ std::move(cb));
}
void Enable(uint8_t inst_id, bool enable, MultiAdvCb cb, uint16_t duration,
#include "gatt_int.h"
-extern fixed_queue_t* btu_general_alarm_queue;
extern thread_t* bt_workqueue_thread;
/******************************************************************************/
btm_cb.devcb.p_rln_cmpl_cb = p_rln_cmpl_cback;
btsnd_hcic_read_name();
- alarm_set_on_queue(btm_cb.devcb.read_local_name_timer,
+ alarm_set_on_mloop(btm_cb.devcb.read_local_name_timer,
BTM_DEV_NAME_REPLY_TIMEOUT_MS, btm_read_local_name_timeout,
- NULL, btu_general_alarm_queue);
+ NULL);
return BTM_CMD_STARTED;
}
#define BTM_INQ_DEBUG FALSE
#endif
-extern fixed_queue_t* btu_general_alarm_queue;
-
/******************************************************************************/
/* L O C A L D A T A D E F I N I T I O N S */
/******************************************************************************/
if (btm_cb.devcb.p_inq_tx_power_cmpl_cb) return (BTM_BUSY);
btm_cb.devcb.p_inq_tx_power_cmpl_cb = p_cb;
- alarm_set_on_queue(btm_cb.devcb.read_inq_tx_power_timer,
+ alarm_set_on_mloop(btm_cb.devcb.read_inq_tx_power_timer,
BTM_INQ_REPLY_TIMEOUT_MS, btm_read_inq_tx_power_timeout,
- NULL, btu_general_alarm_queue);
+ NULL);
btsnd_hcic_read_inq_tx_power();
return (BTM_CMD_STARTED);
p_inq->p_remname_cmpl_cb = p_cb;
p_inq->remname_bda = remote_bda;
- alarm_set_on_queue(p_inq->remote_name_timer, timeout_ms,
- btm_inq_remote_name_timer_timeout, NULL,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_inq->remote_name_timer, timeout_ms,
+ btm_inq_remote_name_timer_timeout, NULL);
/* If the database entry exists for the device, use its clock offset */
tINQ_DB_ENT* p_i = btm_inq_db_find(remote_bda);
#define BTM_SEC_MAX_COLLISION_DELAY (5000)
-extern fixed_queue_t* btu_general_alarm_queue;
-
#ifdef APPL_AUTH_WRITE_EXCEPTION
bool(APPL_AUTH_WRITE_EXCEPTION)(const RawAddress& bd_addr);
#endif
btm_sec_change_pairing_state(BTM_PAIR_STATE_WAIT_DISCONNECT);
/* Change the timer to 1 second */
- alarm_set_on_queue(btm_cb.pairing_timer, BT_1SEC_TIMEOUT_MS,
- btm_sec_pairing_timeout, NULL,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(btm_cb.pairing_timer, BT_1SEC_TIMEOUT_MS,
+ btm_sec_pairing_timeout, NULL);
} else if (btm_cb.pairing_bda == evt_data.bd_addr) {
/* stop the timer */
alarm_cancel(btm_cb.pairing_timer);
p_dev_rec->sec_state = 0;
btm_cb.p_collided_dev_rec = p_dev_rec;
- alarm_set_on_queue(btm_cb.sec_collision_timer, BT_1SEC_TIMEOUT_MS,
- btm_sec_collision_timeout, NULL,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(btm_cb.sec_collision_timer, BT_1SEC_TIMEOUT_MS,
+ btm_sec_collision_timeout, NULL);
}
}
}
/* Start timer with 0 to initiate connection with new LCB */
/* because L2CAP will delete current LCB with this event */
btm_cb.p_collided_dev_rec = p_dev_rec;
- alarm_set_on_queue(btm_cb.sec_collision_timer, 0,
- btm_sec_connect_after_reject_timeout, NULL,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(btm_cb.sec_collision_timer, 0,
+ btm_sec_connect_after_reject_timeout, NULL);
} else {
btm_sec_change_pairing_state(BTM_PAIR_STATE_GET_REM_NAME);
if (BTM_ReadRemoteDeviceName(p_dev_rec->bd_addr, NULL,
/* Start timer with 0 to initiate connection with new LCB */
/* because L2CAP will delete current LCB with this event */
btm_cb.p_collided_dev_rec = p_dev_rec;
- alarm_set_on_queue(btm_cb.sec_collision_timer, 0,
- btm_sec_connect_after_reject_timeout, NULL,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(btm_cb.sec_collision_timer, 0,
+ btm_sec_connect_after_reject_timeout, NULL);
}
return;
if (old_state == BTM_PAIR_STATE_IDLE)
l2cu_update_lcb_4_bonding(btm_cb.pairing_bda, true);
- alarm_set_on_queue(btm_cb.pairing_timer, BTM_SEC_TIMEOUT_VALUE * 1000,
- btm_sec_pairing_timeout, NULL, btu_general_alarm_queue);
+ alarm_set_on_mloop(btm_cb.pairing_timer, BTM_SEC_TIMEOUT_VALUE * 1000,
+ btm_sec_pairing_timeout, NULL);
}
}
// RT priority for audio-related tasks
#define BTU_TASK_RT_PRIORITY 1
-extern fixed_queue_t* btif_msg_queue;
-
-// Communication queue from bta thread to bt_workqueue.
-fixed_queue_t* btu_bta_msg_queue;
-
// Communication queue from hci thread to bt_workqueue.
extern fixed_queue_t* btu_hci_msg_queue;
-// General timer queue.
-fixed_queue_t* btu_general_alarm_queue;
-
thread_t* bt_workqueue_thread;
static const char* BT_WORKQUEUE_NAME = "bt_workqueue";
void BTU_StartUp(void) {
btu_trace_level = HCI_INITIAL_TRACE_LEVEL;
- btu_bta_msg_queue = fixed_queue_new(SIZE_MAX);
- if (btu_bta_msg_queue == NULL) goto error_exit;
-
- btu_general_alarm_queue = fixed_queue_new(SIZE_MAX);
- if (btu_general_alarm_queue == NULL) goto error_exit;
-
bt_workqueue_thread = thread_new(BT_WORKQUEUE_NAME);
if (bt_workqueue_thread == NULL) goto error_exit;
void BTU_ShutDown(void) {
btu_task_shut_down(NULL);
- fixed_queue_free(btu_bta_msg_queue, NULL);
- btu_bta_msg_queue = NULL;
-
- fixed_queue_free(btu_general_alarm_queue, NULL);
- btu_general_alarm_queue = NULL;
thread_free(bt_workqueue_thread);
#include "stack/include/btu.h"
#include "stack/l2cap/l2c_int.h"
+static const int THREAD_RT_PRIORITY = 1;
+
/* Define BTU storage area */
uint8_t btu_trace_level = HCI_INITIAL_TRACE_LEVEL;
-// General timer queue.
-extern fixed_queue_t* btu_general_alarm_queue;
-
extern thread_t* bt_workqueue_thread;
static base::MessageLoop* message_loop_ = NULL;
module_init(get_module(BTE_LOGMSG_MODULE));
message_loop_thread_ = thread_new("btu message loop");
+ if (!message_loop_thread_) {
+ LOG(FATAL) << __func__ << " unable to create btu message loop thread.";
+ }
+
+ thread_set_rt_priority(message_loop_thread_, THREAD_RT_PRIORITY);
thread_post(message_loop_thread_, btu_message_loop_run, nullptr);
- alarm_register_processing_queue(btu_general_alarm_queue, bt_workqueue_thread);
}
void btu_task_shut_down(UNUSED_ATTR void* context) {
message_loop_->task_runner()->PostTask(FROM_HERE, run_loop_->QuitClosure());
}
- alarm_unregister_processing_queue(btu_general_alarm_queue);
-
module_clean_up(get_module(BTE_LOGMSG_MODULE));
bta_sys_free();
0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*******************************************************************************
*
* Function gatt_free_pending_ind
if (p_clcb->gatt_rsp_timer_ent == NULL) {
p_clcb->gatt_rsp_timer_ent = alarm_new("gatt.gatt_rsp_timer_ent");
}
- alarm_set_on_queue(p_clcb->gatt_rsp_timer_ent, timeout_ms, gatt_rsp_timeout,
- p_clcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_clcb->gatt_rsp_timer_ent, timeout_ms, gatt_rsp_timeout,
+ p_clcb);
}
/*******************************************************************************
*
******************************************************************************/
void gatt_start_conf_timer(tGATT_TCB* p_tcb) {
- alarm_set_on_queue(p_tcb->conf_timer, GATT_WAIT_FOR_RSP_TIMEOUT_MS,
- gatt_indication_confirmation_timeout, p_tcb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_tcb->conf_timer, GATT_WAIT_FOR_RSP_TIMEOUT_MS,
+ gatt_indication_confirmation_timeout, p_tcb);
}
/*******************************************************************************
******************************************************************************/
void gatt_start_ind_ack_timer(tGATT_TCB& tcb) {
/* start notification cache timer */
- alarm_set_on_queue(tcb.ind_ack_timer, GATT_WAIT_FOR_RSP_TIMEOUT_MS,
- gatt_ind_ack_timeout, &tcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(tcb.ind_ack_timer, GATT_WAIT_FOR_RSP_TIMEOUT_MS,
+ gatt_ind_ack_timeout, &tcb);
}
/*******************************************************************************
#include "osi/include/osi.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
static uint8_t find_conn_by_cid(uint16_t cid);
static void hidh_conn_retry(uint8_t dhandle);
(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;
- alarm_set_on_queue(hh_cb.devices[dhandle].conn.process_repage_timer,
+ alarm_set_on_mloop(hh_cb.devices[dhandle].conn.process_repage_timer,
interval_ms, hidh_process_repage_timer_timeout,
- UINT_TO_PTR(dhandle), btu_general_alarm_queue);
+ UINT_TO_PTR(dhandle));
hh_cb.callback(dhandle, hh_cb.devices[dhandle].addr, HID_HDEV_EVT_CLOSE,
disc_res, NULL);
} else
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;
- alarm_set_on_queue(p_dev->conn.process_repage_timer, interval_ms,
- hidh_process_repage_timer_timeout, UINT_TO_PTR(dhandle),
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_dev->conn.process_repage_timer, interval_ms,
+ hidh_process_repage_timer_timeout, UINT_TO_PTR(dhandle));
#else
hidh_try_repage(dhandle);
#endif
using base::StringPrintf;
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*******************************************************************************
*
* Function L2CA_Register
if (p_lcb->link_state == LST_CONNECTED) {
l2cu_adj_id(p_lcb, L2CAP_ADJ_BRCM_ID); /* Make sure not using Broadcom ID */
l2cu_send_peer_echo_req(p_lcb, NULL, 0);
- alarm_set_on_queue(p_lcb->l2c_lcb_timer, L2CAP_ECHO_RSP_TIMEOUT_MS,
- l2c_lcb_timer_timeout, p_lcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_lcb->l2c_lcb_timer, L2CAP_ECHO_RSP_TIMEOUT_MS,
+ l2c_lcb_timer_timeout, p_lcb);
}
return (true);
using base::StringPrintf;
-extern fixed_queue_t* btu_general_alarm_queue;
-
static void l2cble_start_conn_update(tL2C_LCB* p_lcb);
/*******************************************************************************
p_lcb->link_state = LST_CONNECTING;
l2cb.is_ble_connecting = true;
l2cb.ble_connecting_bda = p_lcb->remote_bd_addr;
- alarm_set_on_queue(p_lcb->l2c_lcb_timer, L2CAP_BLE_LINK_CONNECT_TIMEOUT_MS,
- l2c_lcb_timer_timeout, p_lcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_lcb->l2c_lcb_timer, L2CAP_BLE_LINK_CONNECT_TIMEOUT_MS,
+ l2c_lcb_timer_timeout, p_lcb);
btm_ble_set_conn_st(BLE_DIR_CONN);
return (true);
if ((p_lcb->link_state == LST_CONNECTED) &&
(!list_is_empty(p_lcb->link_xmit_data_q)) &&
(p_lcb->sent_not_acked < p_lcb->link_xmit_quota)) {
- alarm_set_on_queue(
- p_lcb->l2c_lcb_timer, L2CAP_LINK_FLOW_CONTROL_TIMEOUT_MS,
- l2c_lcb_timer_timeout, p_lcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_lcb->l2c_lcb_timer,
+ L2CAP_LINK_FLOW_CONTROL_TIMEOUT_MS,
+ l2c_lcb_timer_timeout, p_lcb);
}
}
}
#include "l2c_int.h"
#include "l2cdefs.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/******************************************************************************/
/* L O C A L F U N C T I O N P R O T O T Y P E S */
/******************************************************************************/
L2CAP_CONN_NO_LINK);
} else {
l2cu_send_peer_connect_req(p_ccb);
- alarm_set_on_queue(
- p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
+ L2CAP_CHNL_CONNECT_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
}
}
break;
* needed) */
p_ccb->chnl_state = CST_W4_L2CAP_CONNECT_RSP;
if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) {
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
l2cble_credit_based_conn_req(p_ccb); /* Start Connection */
} else {
if (!p_ccb->p_lcb->w4_info_rsp) {
l2cu_release_ccb(p_ccb);
(*connect_cfm)(local_cid, L2CAP_CONN_NO_LINK);
} else {
- alarm_set_on_queue(
- p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
+ L2CAP_CHNL_CONNECT_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
l2cu_send_peer_connect_req(p_ccb); /* Start Connection */
}
}
* needed) */
if (!p_ccb->p_lcb->w4_info_rsp) {
/* Don't need to get info from peer or already retrieved so continue */
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
L2CAP_TRACE_API("L2CAP - Calling Connect_Ind_Cb(), CID: 0x%04x",
p_ccb->local_cid);
if (((tL2C_CONN_INFO*)p_data)->status == BTM_DELAY_CHECK) {
/* start a timer - encryption change not received before L2CAP connect
* req */
- alarm_set_on_queue(
- p_ccb->l2c_ccb_timer, L2CAP_DELAY_CHECK_SM4_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
+ L2CAP_DELAY_CHECK_SM4_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
} else {
if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE)
l2cu_reject_ble_connection(p_ccb->p_lcb, p_ccb->remote_id,
p_ccb->chnl_state = CST_OPEN;
} else {
p_ccb->chnl_state = CST_CONFIG;
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
}
L2CAP_TRACE_API("L2CAP - Calling Connect_Cfm_Cb(), CID: 0x%04x, Success",
p_ccb->local_cid);
case L2CEVT_L2CAP_CONNECT_RSP_PND: /* Got peer connect pending */
p_ccb->remote_cid = p_ci->remote_cid;
- alarm_set_on_queue(p_ccb->l2c_ccb_timer,
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
L2CAP_CHNL_CONNECT_EXT_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ l2c_ccb_timer_timeout, p_ccb);
if (p_ccb->p_rcb->api.pL2CA_ConnectPnd_Cb) {
L2CAP_TRACE_API("L2CAP - Calling Connect_Pnd_Cb(), CID: 0x%04x",
p_ccb->local_cid);
if (p_ccb->remote_cid != 0) {
l2cu_send_peer_disc_req(p_ccb);
p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP;
- alarm_set_on_queue(
- p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
+ L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
} else {
tL2CA_DISCONNECT_CFM_CB* disconnect_cfm =
p_ccb->p_rcb->api.pL2CA_DisconnectCfm_Cb;
(*connect_cfm)(local_cid, L2CAP_CONN_NO_LINK);
} else {
/* We have feature info, so now send peer connect request */
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
l2cu_send_peer_connect_req(p_ccb); /* Start Connection */
}
break;
if ((!p_ci) || (p_ci->l2cap_result == L2CAP_CONN_OK)) {
l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_OK, 0);
p_ccb->chnl_state = CST_CONFIG;
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
} else {
/* If pending, stay in same state and start extended timer */
l2cu_send_peer_connect_rsp(p_ccb, p_ci->l2cap_result,
p_ci->l2cap_status);
- alarm_set_on_queue(
- p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_EXT_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
+ L2CAP_CHNL_CONNECT_EXT_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
}
}
break;
case L2CEVT_L2CA_DISCONNECT_REQ: /* Upper wants to disconnect */
l2cu_send_peer_disc_req(p_ccb);
p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP;
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
break;
case L2CEVT_L2CAP_INFO_RSP:
/* We have feature info, so now give the upper layer connect IND */
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
L2CAP_TRACE_API("L2CAP - Calling Connect_Ind_Cb(), CID: 0x%04x",
p_ccb->local_cid);
break;
case L2CEVT_L2CAP_DISCONNECT_REQ: /* Peer disconnected request */
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
p_ccb->chnl_state = CST_W4_L2CA_DISCONNECT_RSP;
L2CAP_TRACE_API(
"L2CAP - Calling Disconnect_Ind_Cb(), CID: 0x%04x Conf Needed",
case L2CEVT_L2CA_CONFIG_REQ: /* Upper layer config req */
l2cu_process_our_cfg_req(p_ccb, p_cfg);
l2cu_send_peer_config_req(p_ccb, p_cfg);
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
break;
case L2CEVT_L2CA_CONFIG_RSP: /* Upper layer config rsp */
case L2CEVT_L2CA_CONFIG_RSP_NEG: /* Upper layer config reject */
l2cu_send_peer_config_rsp(p_ccb, p_cfg);
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
break;
case L2CEVT_L2CA_DISCONNECT_REQ: /* Upper wants to disconnect */
l2cu_send_peer_disc_req(p_ccb);
p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP;
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
break;
case L2CEVT_L2CAP_DATA: /* Peer data packet rcvd */
p_ccb->chnl_state = CST_CONFIG;
p_ccb->config_done &= ~CFG_DONE_MASK;
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
cfg_result = l2cu_process_peer_cfg_req(p_ccb, p_cfg);
if (cfg_result == L2CAP_PEER_CFG_OK) {
}
p_ccb->chnl_state = CST_W4_L2CA_DISCONNECT_RSP;
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
L2CAP_TRACE_API(
"L2CAP - Calling Disconnect_Ind_Cb(), CID: 0x%04x Conf Needed",
p_ccb->local_cid);
l2cu_send_peer_disc_req(p_ccb);
p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP;
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
break;
case L2CEVT_L2CA_DATA_WRITE: /* Upper layer data to send */
p_ccb->config_done &= ~CFG_DONE_MASK;
l2cu_process_our_cfg_req(p_ccb, (tL2CAP_CFG_INFO*)p_data);
l2cu_send_peer_config_req(p_ccb, (tL2CAP_CFG_INFO*)p_data);
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
break;
case L2CEVT_TIMEOUT:
#include "l2c_int.h"
#include "l2cdefs.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/* Flag passed to retransmit_i_frames() when all packets should be retransmitted
*/
#define L2C_FCR_RETX_ALL_PKTS 0xFF
/* Only start a timer that was not started */
if (!alarm_is_scheduled(p_ccb->fcrb.mon_retrans_timer)) {
- alarm_set_on_queue(p_ccb->fcrb.mon_retrans_timer, tout,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->fcrb.mon_retrans_timer, tout,
+ l2c_ccb_timer_timeout, p_ccb);
}
}
* final, */
/* then it speeds up recovery significantly if we poll him back soon
* after his poll. */
- alarm_set_on_queue(p_ccb->fcrb.mon_retrans_timer, BT_1SEC_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->fcrb.mon_retrans_timer, BT_1SEC_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
}
osi_free(p_buf);
return;
if (delay_ack) {
/* If it is the first I frame we did not ack, start ack timer */
if (!alarm_is_scheduled(p_ccb->fcrb.ack_timer)) {
- alarm_set_on_queue(p_ccb->fcrb.ack_timer, L2CAP_FCR_ACK_TIMEOUT_MS,
- l2c_fcrb_ack_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->fcrb.ack_timer, L2CAP_FCR_ACK_TIMEOUT_MS,
+ l2c_fcrb_ack_timer_timeout, p_ccb);
}
} else if ((fixed_queue_is_empty(p_ccb->xmit_hold_q) ||
l2c_fcr_is_flow_controlled(p_ccb)) &&
l2cu_process_our_cfg_req(p_ccb, &p_ccb->our_cfg);
l2cu_send_peer_config_req(p_ccb, &p_ccb->our_cfg);
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
return (true);
}
}
#include "l2cdefs.h"
#include "osi/include/osi.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
static bool l2c_link_send_to_lower(tL2C_LCB* p_lcb, BT_HDR* p_buf,
tL2C_TX_COMPLETE_CB_INFO* p_cbi);
p_lcb->link_state = LST_CONNECTING;
/* Start a timer waiting for connect complete */
- alarm_set_on_queue(p_lcb->l2c_lcb_timer, L2CAP_LINK_CONNECT_TIMEOUT_MS,
- l2c_lcb_timer_timeout, p_lcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_lcb->l2c_lcb_timer, L2CAP_LINK_CONNECT_TIMEOUT_MS,
+ l2c_lcb_timer_timeout, p_lcb);
return (true);
}
if (p_lcb->p_echo_rsp_cb) {
l2cu_send_peer_echo_req(p_lcb, NULL, 0);
- alarm_set_on_queue(p_lcb->l2c_lcb_timer, L2CAP_ECHO_RSP_TIMEOUT_MS,
- l2c_lcb_timer_timeout, p_lcb, btu_general_alarm_queue);
+ 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;
- alarm_set_on_queue(p_lcb->l2c_lcb_timer, timeout_ms,
- l2c_lcb_timer_timeout, p_lcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms,
+ l2c_lcb_timer_timeout, p_lcb);
}
}
/* Max number of acl connections. */
case BTM_DELAY_CHECK:
/* start a timer - encryption change not received before L2CAP connect
* req */
- alarm_set_on_queue(
- p_ccb->l2c_ccb_timer, L2CAP_DELAY_CHECK_SM4_TIMEOUT_MS,
- l2c_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
+ L2CAP_DELAY_CHECK_SM4_TIMEOUT_MS,
+ l2c_ccb_timer_timeout, p_ccb);
return;
default:
}
if (start_timeout) {
- alarm_set_on_queue(p_lcb->l2c_lcb_timer, timeout_ms,
- l2c_lcb_timer_timeout, p_lcb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms,
+ l2c_lcb_timer_timeout, p_lcb);
}
} else {
/* Check in case we were flow controlled */
p_ccb = p_ccb->p_next_ccb) {
if ((p_ccb->chnl_state == CST_ORIG_W4_SEC_COMP) ||
(p_ccb->chnl_state == CST_TERM_W4_SEC_COMP)) {
- alarm_set_on_queue(
- p_lcb->info_resp_timer, L2CAP_WAIT_INFO_RSP_TIMEOUT_MS,
- l2c_info_resp_timer_timeout, p_lcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_lcb->info_resp_timer,
+ L2CAP_WAIT_INFO_RSP_TIMEOUT_MS,
+ l2c_info_resp_timer_timeout, p_lcb);
return;
}
}
if ((p_lcb->link_state == LST_CONNECTED) &&
(!list_is_empty(p_lcb->link_xmit_data_q)) &&
(p_lcb->sent_not_acked < p_lcb->link_xmit_quota)) {
- alarm_set_on_queue(
- p_lcb->l2c_lcb_timer, L2CAP_LINK_FLOW_CONTROL_TIMEOUT_MS,
- l2c_lcb_timer_timeout, p_lcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_lcb->l2c_lcb_timer,
+ L2CAP_LINK_FLOW_CONTROL_TIMEOUT_MS,
+ l2c_lcb_timer_timeout, p_lcb);
}
}
}
tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_BR_EDR);
if ((p_lcb) && (!p_lcb->ccb_queue.p_first_ccb)) {
- alarm_set_on_queue(p_lcb->l2c_lcb_timer, L2CAP_LINK_CONNECT_EXT_TIMEOUT_MS,
- l2c_lcb_timer_timeout, p_lcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_lcb->l2c_lcb_timer, L2CAP_LINK_CONNECT_EXT_TIMEOUT_MS,
+ l2c_lcb_timer_timeout, p_lcb);
}
}
/* so we may need a timer to kick off this link's transmissions. */
if ((!list_is_empty(p_lcb->link_xmit_data_q)) &&
(p_lcb->sent_not_acked < p_lcb->link_xmit_quota)) {
- alarm_set_on_queue(p_lcb->l2c_lcb_timer,
+ alarm_set_on_mloop(p_lcb->l2c_lcb_timer,
L2CAP_LINK_FLOW_CONTROL_TIMEOUT_MS,
- l2c_lcb_timer_timeout, p_lcb, btu_general_alarm_queue);
+ l2c_lcb_timer_timeout, p_lcb);
}
}
}
#include "osi/include/log.h"
#include "osi/include/osi.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/******************************************************************************/
/* L O C A L F U N C T I O N P R O T O T Y P E S */
/******************************************************************************/
list_append(l2cb.rcv_pending_q, p_msg);
if (list_length(l2cb.rcv_pending_q) == 1) {
- alarm_set_on_queue(l2cb.receive_hold_timer, BT_1SEC_TIMEOUT_MS,
- l2c_receive_hold_timer_timeout, NULL,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(l2cb.receive_hold_timer, BT_1SEC_TIMEOUT_MS,
+ l2c_receive_hold_timer_timeout, NULL);
}
return;
/* If anyone still in the queue, restart the timeout */
if (!list_is_empty(l2cb.rcv_pending_q)) {
- alarm_set_on_queue(l2cb.receive_hold_timer, BT_1SEC_TIMEOUT_MS,
- l2c_receive_hold_timer_timeout, NULL,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(l2cb.receive_hold_timer, BT_1SEC_TIMEOUT_MS,
+ l2c_receive_hold_timer_timeout, NULL);
}
}
#if (L2CAP_UCD_INCLUDED == TRUE)
-extern fixed_queue_t* btu_bta_alarm_queue;
-
static bool l2c_ucd_connect(const RawAddress& rem_bda);
/*******************************************************************************
if (!fixed_queue_is_empty(p_ccb->p_lcb->ucd_out_sec_pending_q)) {
/* start a timer to send next UCD packet in OPEN state */
/* it will prevent stack overflow */
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, 0, l2c_ccb_timer_timeout,
- p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, 0, l2c_ccb_timer_timeout,
+ p_ccb);
} else {
/* start a timer for idle timeout of UCD */
period_ms_t timeout_ms = p_ccb->fixed_chnl_idle_tout * 1000;
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, timeout_ms,
- l2c_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, timeout_ms,
+ l2c_ccb_timer_timeout, p_ccb);
}
break;
/* start a timer for idle timeout of UCD */
period_ms_t timeout_ms = p_ccb->fixed_chnl_idle_tout * 1000;
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, timeout_ms,
- l2c_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, timeout_ms,
+ l2c_ccb_timer_timeout, p_ccb);
break;
case L2CEVT_L2CA_DATA_WRITE: /* Upper layer data to send */
if (!fixed_queue_is_empty(p_ccb->p_lcb->ucd_in_sec_pending_q)) {
/* start a timer to check next UCD packet in OPEN state */
/* it will prevent stack overflow */
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, 0, l2c_ccb_timer_timeout,
- p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, 0, l2c_ccb_timer_timeout,
+ p_ccb);
} else {
/* start a timer for idle timeout of UCD */
period_ms_t timeout_ms = p_ccb->fixed_chnl_idle_tout * 1000;
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, timeout_ms,
- l2c_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, timeout_ms,
+ l2c_ccb_timer_timeout, p_ccb);
}
break;
/* start a timer for idle timeout of UCD */
period_ms_t timeout_ms = p_ccb->fixed_chnl_idle_tout * 1000;
- alarm_set_on_queue(p_ccb->l2c_ccb_timer, timeout_ms,
- l2c_ccb_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, timeout_ms,
+ l2c_ccb_timer_timeout, p_ccb);
break;
case L2CEVT_L2CA_DATA_WRITE: /* Upper layer data to send */
#include "l2cdefs.h"
#include "osi/include/allocator.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*******************************************************************************
*
* Function l2cu_can_allocate_lcb
UINT16_TO_STREAM(p, info_type);
p_lcb->w4_info_rsp = true;
- alarm_set_on_queue(p_lcb->info_resp_timer, L2CAP_WAIT_INFO_RSP_TIMEOUT_MS,
- l2c_info_resp_timer_timeout, p_lcb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_lcb->info_resp_timer, L2CAP_WAIT_INFO_RSP_TIMEOUT_MS,
+ l2c_info_resp_timer_timeout, p_lcb);
l2c_link_check_send_pkts(p_lcb, NULL, p_buf);
}
p_lcb->link_state = LST_DISCONNECTING;
timeout_ms = L2CAP_LINK_DISCONNECT_TIMEOUT_MS;
}
- alarm_set_on_queue(p_lcb->l2c_lcb_timer, timeout_ms, l2c_lcb_timer_timeout,
- p_lcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms, l2c_lcb_timer_timeout,
+ p_lcb);
return (true);
}
if (BTM_SwitchRole(p_lcb_cur->remote_bd_addr, HCI_ROLE_MASTER, NULL) ==
BTM_CMD_STARTED) {
- alarm_set_on_queue(
- p_lcb->l2c_lcb_timer, L2CAP_LINK_ROLE_SWITCH_TIMEOUT_MS,
- l2c_lcb_timer_timeout, p_lcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_lcb->l2c_lcb_timer,
+ L2CAP_LINK_ROLE_SWITCH_TIMEOUT_MS,
+ l2c_lcb_timer_timeout, p_lcb);
return (true);
}
}
btm_acl_update_busy_level(BTM_BLI_PAGE_EVT);
- alarm_set_on_queue(p_lcb->l2c_lcb_timer, L2CAP_LINK_CONNECT_TIMEOUT_MS,
- l2c_lcb_timer_timeout, p_lcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_lcb->l2c_lcb_timer, L2CAP_LINK_CONNECT_TIMEOUT_MS,
+ l2c_lcb_timer_timeout, p_lcb);
return (true);
}
if (start_timeout) {
L2CAP_TRACE_DEBUG("%s starting IDLE timeout: %d ms", __func__, timeout_ms);
- alarm_set_on_queue(p_lcb->l2c_lcb_timer, timeout_ms, l2c_lcb_timer_timeout,
- p_lcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms, l2c_lcb_timer_timeout,
+ p_lcb);
} else {
alarm_cancel(p_lcb->l2c_lcb_timer);
}
#include "btu.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*****************************************************************************
* constants
****************************************************************************/
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;
- alarm_set_on_queue(p_ccb->mca_ccb_timer, interval_ms,
- mca_ccb_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->mca_ccb_timer, interval_ms,
+ mca_ccb_timer_timeout, p_ccb);
}
/* else the L2CAP channel is congested. keep the message to be sent later */
} else {
#include <string.h>
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*******************************************************************************
*
* Function rfc_calc_fcs
RFCOMM_TRACE_EVENT("%s - timeout:%d seconds", __func__, timeout);
period_ms_t interval_ms = timeout * 1000;
- alarm_set_on_queue(p_mcb->mcb_timer, interval_ms, rfcomm_mcb_timer_timeout,
- p_mcb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_mcb->mcb_timer, interval_ms, rfcomm_mcb_timer_timeout,
+ p_mcb);
}
/*******************************************************************************
RFCOMM_TRACE_EVENT("%s - timeout:%d seconds", __func__, timeout);
period_ms_t interval_ms = timeout * 1000;
- alarm_set_on_queue(p_port->rfc.port_timer, interval_ms,
- rfcomm_port_timer_timeout, p_port,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_port->rfc.port_timer, interval_ms,
+ rfcomm_port_timer_timeout, p_port);
}
/*******************************************************************************
/* Safety check in case we go crazy */
#define MAX_NEST_LEVELS 5
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*******************************************************************************
*
* Function sdpu_build_uuid_seq
L2CA_DataWrite(p_ccb->connection_id, p_cmd);
/* Start inactivity timer */
- alarm_set_on_queue(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
- sdp_conn_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
+ sdp_conn_timer_timeout, p_ccb);
}
/*******************************************************************************
L2CA_DataWrite(p_ccb->connection_id, p_msg);
/* Start inactivity timer */
- alarm_set_on_queue(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
- sdp_conn_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
+ sdp_conn_timer_timeout, p_ccb);
} else {
sdp_disconnect(p_ccb, SDP_SUCCESS);
return;
L2CA_DataWrite(p_ccb->connection_id, p_msg);
/* Start inactivity timer */
- alarm_set_on_queue(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
- sdp_conn_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
+ sdp_conn_timer_timeout, p_ccb);
return;
}
#include "sdp_api.h"
#include "sdpint.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/******************************************************************************/
/* G L O B A L S D P D A T A */
/******************************************************************************/
sdp_disc_connected(p_ccb);
} else {
/* Start inactivity timer */
- alarm_set_on_queue(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
- sdp_conn_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
+ sdp_conn_timer_timeout, p_ccb);
}
}
}
sdp_disc_connected(p_ccb);
} else {
/* Start inactivity timer */
- alarm_set_on_queue(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
- sdp_conn_timer_timeout, p_ccb,
- btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
+ sdp_conn_timer_timeout, p_ccb);
}
}
} else {
#if (SDP_SERVER_ENABLED == TRUE)
-extern fixed_queue_t* btu_general_alarm_queue;
-
/* Maximum number of bytes to reserve out of SDP MTU for response data */
#define SDP_MAX_SERVICE_RSPHDR_LEN 12
#define SDP_MAX_SERVATTR_RSPHDR_LEN 10
uint16_t trans_num, param_len;
/* Start inactivity timer */
- alarm_set_on_queue(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
- sdp_conn_timer_timeout, p_ccb, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
+ sdp_conn_timer_timeout, p_ccb);
/* The first byte in the message is the pdu type */
pdu_id = *p_req++;
#include "stack/smp/smp_int.h"
#include "utils/include/bt_utils.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
#define SMP_KEY_DIST_TYPE_MAX 4
const tSMP_ACT smp_distribute_act[] = {smp_generate_ltk, smp_send_id_info,
*/
if (!alarm_is_scheduled(p_cb->delayed_auth_timer_ent)) {
SMP_TRACE_DEBUG("%s delaying auth complete.", __func__);
- alarm_set_on_queue(
- p_cb->delayed_auth_timer_ent, SMP_DELAYED_AUTH_TIMEOUT_MS,
- smp_delayed_auth_complete_timeout, NULL, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_cb->delayed_auth_timer_ent,
+ SMP_DELAYED_AUTH_TIMEOUT_MS,
+ smp_delayed_auth_complete_timeout, NULL);
}
} else {
p_cb->wait_for_authorization_complete = true;
#include "smp_int.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
static void smp_tx_complete_callback(uint16_t cid, uint16_t num_pkt);
static void smp_connect_callback(uint16_t channel, const RawAddress& bd_addr,
}
if (bd_addr == p_cb->pairing_bda) {
- alarm_set_on_queue(p_cb->smp_rsp_timer_ent, SMP_WAIT_FOR_RSP_TIMEOUT_MS,
- smp_rsp_timeout, NULL, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_cb->smp_rsp_timer_ent, SMP_WAIT_FOR_RSP_TIMEOUT_MS,
+ smp_rsp_timeout, NULL);
if (cmd == SMP_OPCODE_CONFIRM) {
SMP_TRACE_DEBUG(
}
if (bd_addr == p_cb->pairing_bda) {
- alarm_set_on_queue(p_cb->smp_rsp_timer_ent, SMP_WAIT_FOR_RSP_TIMEOUT_MS,
- smp_rsp_timeout, NULL, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_cb->smp_rsp_timer_ent, SMP_WAIT_FOR_RSP_TIMEOUT_MS,
+ smp_rsp_timeout, NULL);
p_cb->rcvd_cmd_code = cmd;
p_cb->rcvd_cmd_len = (uint8_t)p_buf->len;
#include "osi/include/osi.h"
#include "smp_int.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
#define SMP_PAIRING_REQ_SIZE 7
#define SMP_CONFIRM_CMD_SIZE (BT_OCTET16_LEN + 1)
#define SMP_RAND_CMD_SIZE (BT_OCTET16_LEN + 1)
if (p_buf != NULL && smp_send_msg_to_L2CAP(p_cb->pairing_bda, p_buf)) {
sent = true;
- alarm_set_on_queue(p_cb->smp_rsp_timer_ent, SMP_WAIT_FOR_RSP_TIMEOUT_MS,
- smp_rsp_timeout, NULL, btu_general_alarm_queue);
+ alarm_set_on_mloop(p_cb->smp_rsp_timer_ent, SMP_WAIT_FOR_RSP_TIMEOUT_MS,
+ smp_rsp_timeout, NULL);
}
}
alarm_callback_t last_alarm_cb = nullptr;
void* last_alarm_data = nullptr;
-void alarm_set_on_queue(alarm_t* alarm, period_ms_t interval_ms,
- alarm_callback_t cb, void* data, fixed_queue_t* queue) {
+void alarm_set_on_mloop(alarm_t* alarm, period_ms_t interval_ms,
+ alarm_callback_t cb, void* data) {
last_alarm_cb = cb;
last_alarm_data = data;
}
alarm_t* alarm_new(const char* name) { return nullptr; }
void alarm_free(alarm_t* alarm) {}
const controller_t* controller_get_interface() { return nullptr; }
-fixed_queue_t* btu_general_alarm_queue = nullptr;
namespace {
void DoNothing(uint8_t) {}
void module_clean_up(module_t const*){};
thread_t* bt_workqueue_thread;
-fixed_queue_t* btu_general_alarm_queue;
class BtuMessageLoopTest : public testing::Test {
public:
virtual void SetUp() {
// Initialize alarms to prevent btu_task_shut_down from crashing
alarm_new("test alarm");
- btu_general_alarm_queue = fixed_queue_new(SIZE_MAX);
bt_workqueue_thread = thread_new("test alarm thread");
// btu_task_start_up calls btif_transfer_context to let the stack know