Fix alarms being posted on wrong thread
Alarms from btu_bta_alarm_queue and btu_generic_alarm_queue should be
processed on the main MessageLoop thread.
Replaced obsoleted alarm_set_on_queue() alarm API with the new
alarm_set_on_mloop() API
Test: manual
Bug: 65078753
Change-Id: I54b472b39b44a6c541dbdcdad7414056d0dd4163
Merged-In: I54b472b39b44a6c541dbdcdad7414056d0dd4163
(cherry picked from commit be8bbd7a83ec8bc900fac58a03010fbcb74956c9)
diff --git a/bta/ag/bta_ag_main.cc b/bta/ag/bta_ag_main.cc
index ae38817..d33247e 100644
--- a/bta/ag/bta_ag_main.cc
+++ b/bta/ag/bta_ag_main.cc
@@ -38,8 +38,6 @@
#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);
@@ -545,9 +543,8 @@
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);
}
}
diff --git a/bta/ag/bta_ag_sco.cc b/bta/ag/bta_ag_sco.cc
index 6d4ad31..f118988 100644
--- a/bta/ag/bta_ag_sco.cc
+++ b/bta/ag/bta_ag_sco.cc
@@ -47,8 +47,6 @@
#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);
@@ -558,9 +556,9 @@
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(
diff --git a/bta/av/bta_av_act.cc b/bta/av/bta_av_act.cc
index aa77663..ff9af59 100644
--- a/bta/av/bta_av_act.cc
+++ b/bta/av/bta_av_act.cc
@@ -58,8 +58,6 @@
#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
@@ -1429,10 +1427,10 @@
/* 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;
}
@@ -1548,10 +1546,10 @@
/* 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);
diff --git a/bta/dm/bta_dm_act.cc b/bta/dm/bta_dm_act.cc
index 03c4530..187bc68 100644
--- a/bta/dm/bta_dm_act.cc
+++ b/bta/dm/bta_dm_act.cc
@@ -248,7 +248,6 @@
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;
/*******************************************************************************
*
@@ -509,16 +508,14 @@
*/
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));
}
}
@@ -554,9 +551,9 @@
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;
@@ -1769,9 +1766,9 @@
} 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);
}
}
@@ -3081,9 +3078,9 @@
* 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) {
@@ -3319,9 +3316,9 @@
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);
}
}
}
diff --git a/bta/dm/bta_dm_pm.cc b/bta/dm/bta_dm_pm.cc
index 1bbeeb1..23716c1 100644
--- a/bta/dm/bta_dm_pm.cc
+++ b/bta/dm/bta_dm_pm.cc
@@ -35,8 +35,6 @@
#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,
@@ -285,9 +283,8 @@
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]);
}
/*******************************************************************************
diff --git a/bta/hf_client/bta_hf_client_at.cc b/bta/hf_client/bta_hf_client_at.cc
index 9163d02..5d8493b 100644
--- a/bta/hf_client/bta_hf_client_at.cc
+++ b/bta/hf_client/bta_hf_client_at.cc
@@ -42,13 +42,6 @@
#define BTA_HF_CLIENT_AT_HOLD_TIMEOUT 41
/******************************************************************************
- *
- * DATA TYPES AND CONTAINERS
- *
- ******************************************************************************/
-extern fixed_queue_t* btu_bta_alarm_queue;
-
-/******************************************************************************
* SUPPORTED EVENT MESSAGES
******************************************************************************/
@@ -164,9 +157,8 @@
}
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) {
@@ -234,9 +226,8 @@
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);
}
/******************************************************************************
diff --git a/bta/hf_client/bta_hf_client_main.cc b/bta/hf_client/bta_hf_client_main.cc
index 1d7dff1..e52994c 100644
--- a/bta/hf_client/bta_hf_client_main.cc
+++ b/bta/hf_client/bta_hf_client_main.cc
@@ -31,8 +31,6 @@
#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);
@@ -391,10 +389,9 @@
// 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);
}
}
diff --git a/bta/sys/bta_sys_main.cc b/bta/sys/bta_sys_main.cc
index f2453f7..777f23a 100644
--- a/bta/sys/bta_sys_main.cc
+++ b/bta/sys/bta_sys_main.cc
@@ -50,7 +50,6 @@
/* 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 */
@@ -58,9 +57,6 @@
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 */
@@ -179,10 +175,6 @@
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 */
@@ -197,9 +189,6 @@
}
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;
}
/*******************************************************************************
@@ -586,8 +575,7 @@
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);
}
/*******************************************************************************
diff --git a/bta/test/bta_hf_client_test.cc b/bta/test/bta_hf_client_test.cc
index 18f3d39..01d9f5f 100644
--- a/bta/test/bta_hf_client_test.cc
+++ b/bta/test/bta_hf_client_test.cc
@@ -21,6 +21,12 @@
#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});
diff --git a/btif/src/btif_av.cc b/btif/src/btif_av.cc
index 8074f1f..95a4d4b 100644
--- a/btif/src/btif_av.cc
+++ b/btif/src/btif_av.cc
@@ -147,8 +147,6 @@
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
*****************************************************************************/
@@ -387,9 +385,8 @@
*/
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;
diff --git a/btif/src/btif_hh.cc b/btif/src/btif_hh.cc
index 5ce9bb2..7c7352e 100644
--- a/btif/src/btif_hh.cc
+++ b/btif/src/btif_hh.cc
@@ -66,7 +66,6 @@
#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
@@ -412,8 +411,8 @@
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);
}
/*******************************************************************************
diff --git a/btif/src/btif_hl.cc b/btif/src/btif_hl.cc
index b539a9d..4f701fb 100644
--- a/btif/src/btif_hl.cc
+++ b/btif/src/btif_hl.cc
@@ -77,8 +77,6 @@
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;
@@ -307,8 +305,8 @@
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);
}
/*******************************************************************************
diff --git a/btif/src/btif_rc.cc b/btif/src/btif_rc.cc
index c691672..fc10b8b 100644
--- a/btif/src/btif_rc.cc
+++ b/btif/src/btif_rc.cc
@@ -350,8 +350,6 @@
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
*****************************************************************************/
@@ -2966,10 +2964,9 @@
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));
}
}
@@ -3022,9 +3019,8 @@
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,
@@ -3036,9 +3032,8 @@
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,
@@ -3050,9 +3045,8 @@
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,
diff --git a/osi/include/alarm.h b/osi/include/alarm.h
index a59f12d..a01e6d0 100644
--- a/osi/include/alarm.h
+++ b/osi/include/alarm.h
@@ -74,15 +74,11 @@
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
@@ -95,15 +91,6 @@
// 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
diff --git a/osi/src/alarm.cc b/osi/src/alarm.cc
index 81740d3..e1c87fc 100644
--- a/osi/src/alarm.cc
+++ b/osi/src/alarm.cc
@@ -22,7 +22,9 @@
#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>
@@ -45,6 +47,12 @@
#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;
@@ -68,6 +76,17 @@
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
@@ -85,6 +104,9 @@
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
@@ -123,7 +145,7 @@
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);
@@ -135,6 +157,10 @@
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;
@@ -160,6 +186,11 @@
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;
@@ -171,6 +202,7 @@
alarm_cancel(alarm);
delete alarm->callback_mutex;
osi_free((void*)alarm->stats.name);
+ alarm->closure.~CancelableClosureInStruct();
osi_free(alarm);
}
@@ -187,19 +219,19 @@
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);
@@ -211,6 +243,7 @@
alarm->queue = queue;
alarm->callback = cb;
alarm->data = data;
+ alarm->for_msg_loop = for_msg_loop;
schedule_next_instance(alarm);
alarm->stats.scheduled_count++;
@@ -373,9 +406,15 @@
// 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
+ }
}
}
@@ -509,7 +548,8 @@
}
}
-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);
@@ -517,33 +557,11 @@
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
@@ -576,6 +594,19 @@
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);
@@ -612,7 +643,18 @@
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__);
diff --git a/osi/test/alarm_test.cc b/osi/test/alarm_test.cc
index dd4bbc1..2eed78f 100644
--- a/osi/test/alarm_test.cc
+++ b/osi/test/alarm_test.cc
@@ -16,6 +16,8 @@
*
******************************************************************************/
+#include <base/message_loop/message_loop.h>
+#include <base/run_loop.h>
#include <gtest/gtest.h>
#include "AlarmTestHarness.h"
@@ -26,6 +28,9 @@
#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;
@@ -34,6 +39,26 @@
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() {
@@ -288,23 +313,29 @@
}
// 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++) {
@@ -316,128 +347,9 @@
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|.
diff --git a/stack/avdt/avdt_ccb_act.cc b/stack/avdt/avdt_ccb_act.cc
index 0184001..852dcf8 100644
--- a/stack/avdt/avdt_ccb_act.cc
+++ b/stack/avdt/avdt_ccb_act.cc
@@ -35,8 +35,6 @@
#include "btu.h"
#include "osi/include/osi.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*******************************************************************************
*
* Function avdt_ccb_clear_ccb
@@ -125,9 +123,8 @@
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);
}
}
@@ -773,9 +770,8 @@
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);
}
}
diff --git a/stack/avdt/avdt_msg.cc b/stack/avdt/avdt_msg.cc
index 2595ab8..ef06576 100644
--- a/stack/avdt/avdt_msg.cc
+++ b/stack/avdt/avdt_msg.cc
@@ -37,8 +37,6 @@
#include "btu.h"
#include "osi/include/osi.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*****************************************************************************
* constants
****************************************************************************/
@@ -1127,16 +1125,14 @@
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 {
diff --git a/stack/avdt/avdt_scb_act.cc b/stack/avdt/avdt_scb_act.cc
index acc64de..85d32fd 100644
--- a/stack/avdt/avdt_scb_act.cc
+++ b/stack/avdt/avdt_scb_act.cc
@@ -35,8 +35,6 @@
#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
@@ -209,9 +207,9 @@
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);
}
/*******************************************************************************
@@ -1061,9 +1059,9 @@
/* 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);
}
/*******************************************************************************
@@ -1446,9 +1444,9 @@
******************************************************************************/
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);
}
/*******************************************************************************
diff --git a/stack/avrc/avrc_api.cc b/stack/avrc/avrc_api.cc
index ed851d4..e2d85f9 100644
--- a/stack/avrc/avrc_api.cc
+++ b/stack/avrc/avrc_api.cc
@@ -34,7 +34,6 @@
/*****************************************************************************
* Global data
****************************************************************************/
-extern fixed_queue_t* btu_general_alarm_queue;
#define AVRC_MAX_RCV_CTRL_EVT AVCT_BROWSE_UNCONG_IND_EVT
@@ -205,8 +204,8 @@
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);
}
/******************************************************************************
diff --git a/stack/bnep/bnep_api.cc b/stack/bnep/bnep_api.cc
index 1fe1f57..923ce50 100644
--- a/stack/bnep/bnep_api.cc
+++ b/stack/bnep/bnep_api.cc
@@ -26,8 +26,6 @@
#include <string.h>
#include "bnep_int.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*******************************************************************************
*
* Function BNEP_Init
@@ -191,8 +189,8 @@
}
/* 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;
diff --git a/stack/bnep/bnep_main.cc b/stack/bnep/bnep_main.cc
index c03a4af..ce09c47 100644
--- a/stack/bnep/bnep_main.cc
+++ b/stack/bnep/bnep_main.cc
@@ -45,8 +45,6 @@
#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 */
/******************************************************************************/
@@ -139,8 +137,8 @@
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);
}
@@ -176,8 +174,8 @@
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);
@@ -252,8 +250,8 @@
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(
@@ -295,9 +293,8 @@
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,
@@ -638,9 +635,8 @@
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);
@@ -666,9 +662,8 @@
} 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);
@@ -683,9 +678,8 @@
} 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);
diff --git a/stack/bnep/bnep_utils.cc b/stack/bnep/bnep_utils.cc
index df267d9..a362635 100644
--- a/stack/bnep/bnep_utils.cc
+++ b/stack/bnep/bnep_utils.cc
@@ -33,8 +33,6 @@
#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 */
/******************************************************************************/
@@ -271,8 +269,8 @@
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);
}
/*******************************************************************************
@@ -315,8 +313,8 @@
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);
}
/*******************************************************************************
@@ -1179,8 +1177,8 @@
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;
}
diff --git a/stack/btm/btm_acl.cc b/stack/btm/btm_acl.cc
index 87a5268..9f0b1f3 100644
--- a/stack/btm/btm_acl.cc
+++ b/stack/btm/btm_acl.cc
@@ -50,8 +50,6 @@
#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,
@@ -1816,8 +1814,8 @@
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,
@@ -1909,8 +1907,8 @@
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);
@@ -1947,10 +1945,9 @@
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);
@@ -1988,10 +1985,9 @@
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;
@@ -2018,9 +2014,9 @@
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);
@@ -2056,9 +2052,9 @@
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;
diff --git a/stack/btm/btm_ble_addr.cc b/stack/btm/btm_ble_addr.cc
index b5010db..5459c53 100644
--- a/stack/btm/btm_ble_addr.cc
+++ b/stack/btm/btm_ble_addr.cc
@@ -35,8 +35,6 @@
#include "btm_ble_int.h"
#include "smp_api.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*******************************************************************************
*
* Function btm_gen_resolve_paddr_cmpl
@@ -66,9 +64,8 @@
#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");
diff --git a/stack/btm/btm_ble_gap.cc b/stack/btm/btm_ble_gap.cc
index 73d51b7..341d85d 100644
--- a/stack/btm/btm_ble_gap.cc
+++ b/stack/btm/btm_ble_gap.cc
@@ -60,8 +60,6 @@
#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 {
@@ -455,9 +453,8 @@
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)) {
@@ -1225,9 +1222,8 @@
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);
@@ -1239,9 +1235,9 @@
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;
}
@@ -1313,9 +1309,8 @@
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);
@@ -1420,9 +1415,8 @@
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);
}
}
@@ -1491,9 +1485,8 @@
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;
}
diff --git a/stack/btm/btm_ble_multi_adv.cc b/stack/btm/btm_ble_multi_adv.cc
index e71fb75..a00772c 100644
--- a/stack/btm/btm_ble_multi_adv.cc
+++ b/stack/btm/btm_ble_multi_adv.cc
@@ -39,7 +39,6 @@
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;
@@ -118,14 +117,14 @@
}
// 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;
@@ -275,10 +274,9 @@
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));
@@ -537,8 +535,8 @@
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,
diff --git a/stack/btm/btm_devctl.cc b/stack/btm/btm_devctl.cc
index 3dcb381..4910315 100644
--- a/stack/btm/btm_devctl.cc
+++ b/stack/btm/btm_devctl.cc
@@ -43,7 +43,6 @@
#include "gatt_int.h"
-extern fixed_queue_t* btu_general_alarm_queue;
extern thread_t* bt_workqueue_thread;
/******************************************************************************/
@@ -464,9 +463,9 @@
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;
}
diff --git a/stack/btm/btm_inq.cc b/stack/btm/btm_inq.cc
index bd276d6..213683c 100644
--- a/stack/btm/btm_inq.cc
+++ b/stack/btm/btm_inq.cc
@@ -51,8 +51,6 @@
#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 */
/******************************************************************************/
@@ -1121,9 +1119,9 @@
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);
@@ -2076,9 +2074,8 @@
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);
diff --git a/stack/btm/btm_sec.cc b/stack/btm/btm_sec.cc
index 263db46..00f2e92 100644
--- a/stack/btm/btm_sec.cc
+++ b/stack/btm/btm_sec.cc
@@ -44,8 +44,6 @@
#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
@@ -3708,9 +3706,8 @@
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);
@@ -3848,9 +3845,8 @@
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);
}
}
}
@@ -4311,9 +4307,8 @@
/* 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,
@@ -4371,9 +4366,8 @@
/* 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;
@@ -5650,8 +5644,8 @@
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);
}
}
diff --git a/stack/btu/btu_init.cc b/stack/btu/btu_init.cc
index e267d29..c847211 100644
--- a/stack/btu/btu_init.cc
+++ b/stack/btu/btu_init.cc
@@ -39,17 +39,9 @@
// 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";
@@ -115,12 +107,6 @@
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;
@@ -139,11 +125,6 @@
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);
diff --git a/stack/btu/btu_task.cc b/stack/btu/btu_task.cc
index 103990e..c0f374d 100644
--- a/stack/btu/btu_task.cc
+++ b/stack/btu/btu_task.cc
@@ -38,12 +38,11 @@
#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;
@@ -125,9 +124,13 @@
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) {
@@ -136,8 +139,6 @@
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();
diff --git a/stack/gatt/gatt_utils.cc b/stack/gatt/gatt_utils.cc
index dc20e65..ad8ab7a 100644
--- a/stack/gatt/gatt_utils.cc
+++ b/stack/gatt/gatt_utils.cc
@@ -80,8 +80,6 @@
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
@@ -670,8 +668,8 @@
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);
}
/*******************************************************************************
@@ -684,9 +682,8 @@
*
******************************************************************************/
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);
}
/*******************************************************************************
@@ -700,8 +697,8 @@
******************************************************************************/
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);
}
/*******************************************************************************
diff --git a/stack/hid/hidh_conn.cc b/stack/hid/hidh_conn.cc
index 18723bc..1ab03b7 100644
--- a/stack/hid/hidh_conn.cc
+++ b/stack/hid/hidh_conn.cc
@@ -44,8 +44,6 @@
#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);
@@ -658,9 +656,9 @@
(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
@@ -1067,9 +1065,8 @@
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
diff --git a/stack/l2cap/l2c_api.cc b/stack/l2cap/l2c_api.cc
index e158a88..809199f 100644
--- a/stack/l2cap/l2c_api.cc
+++ b/stack/l2cap/l2c_api.cc
@@ -44,8 +44,6 @@
using base::StringPrintf;
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*******************************************************************************
*
* Function L2CA_Register
@@ -934,8 +932,8 @@
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);
diff --git a/stack/l2cap/l2c_ble.cc b/stack/l2cap/l2c_ble.cc
index 573fde8..f611b78 100644
--- a/stack/l2cap/l2c_ble.cc
+++ b/stack/l2cap/l2c_ble.cc
@@ -38,8 +38,6 @@
using base::StringPrintf;
-extern fixed_queue_t* btu_general_alarm_queue;
-
static void l2cble_start_conn_update(tL2C_LCB* p_lcb);
/*******************************************************************************
@@ -907,8 +905,8 @@
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);
@@ -1075,9 +1073,9 @@
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);
}
}
}
diff --git a/stack/l2cap/l2c_csm.cc b/stack/l2cap/l2c_csm.cc
index b5c148f..66033ee 100644
--- a/stack/l2cap/l2c_csm.cc
+++ b/stack/l2cap/l2c_csm.cc
@@ -35,8 +35,6 @@
#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 */
/******************************************************************************/
@@ -229,9 +227,9 @@
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;
@@ -356,9 +354,8 @@
* 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) {
@@ -367,9 +364,9 @@
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 */
}
}
@@ -446,9 +443,8 @@
* 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);
@@ -474,9 +470,9 @@
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,
@@ -566,9 +562,8 @@
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);
@@ -578,9 +573,9 @@
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);
@@ -608,9 +603,9 @@
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;
@@ -635,9 +630,8 @@
(*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;
@@ -695,16 +689,15 @@
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;
@@ -736,14 +729,14 @@
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);
@@ -877,8 +870,8 @@
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",
@@ -889,8 +882,8 @@
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 */
@@ -949,15 +942,15 @@
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 */
@@ -1056,8 +1049,8 @@
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) {
@@ -1093,8 +1086,8 @@
}
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);
@@ -1125,8 +1118,8 @@
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 */
@@ -1139,8 +1132,8 @@
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:
diff --git a/stack/l2cap/l2c_fcr.cc b/stack/l2cap/l2c_fcr.cc
index 47714e1..0e5a84a 100644
--- a/stack/l2cap/l2c_fcr.cc
+++ b/stack/l2cap/l2c_fcr.cc
@@ -38,8 +38,6 @@
#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
@@ -180,8 +178,8 @@
/* 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);
}
}
@@ -712,9 +710,8 @@
* 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;
@@ -1301,9 +1298,8 @@
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)) &&
@@ -2198,9 +2194,8 @@
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);
}
}
diff --git a/stack/l2cap/l2c_link.cc b/stack/l2cap/l2c_link.cc
index c51967c..bd4a610 100644
--- a/stack/l2cap/l2c_link.cc
+++ b/stack/l2cap/l2c_link.cc
@@ -42,8 +42,6 @@
#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);
@@ -102,8 +100,8 @@
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);
}
@@ -216,12 +214,12 @@
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. */
@@ -316,9 +314,9 @@
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:
@@ -590,9 +588,8 @@
}
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 */
@@ -623,9 +620,9 @@
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;
}
}
@@ -761,9 +758,9 @@
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);
}
}
}
@@ -896,8 +893,8 @@
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);
}
}
@@ -1084,9 +1081,9 @@
/* 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);
}
}
}
diff --git a/stack/l2cap/l2c_main.cc b/stack/l2cap/l2c_main.cc
index 04dc88b..83d1737 100644
--- a/stack/l2cap/l2c_main.cc
+++ b/stack/l2cap/l2c_main.cc
@@ -40,8 +40,6 @@
#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 */
/******************************************************************************/
@@ -103,9 +101,8 @@
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;
@@ -747,9 +744,8 @@
/* 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);
}
}
diff --git a/stack/l2cap/l2c_ucd.cc b/stack/l2cap/l2c_ucd.cc
index e52b90b..2216368 100644
--- a/stack/l2cap/l2c_ucd.cc
+++ b/stack/l2cap/l2c_ucd.cc
@@ -38,8 +38,6 @@
#if (L2CAP_UCD_INCLUDED == TRUE)
-extern fixed_queue_t* btu_bta_alarm_queue;
-
static bool l2c_ucd_connect(const RawAddress& rem_bda);
/*******************************************************************************
@@ -965,14 +963,13 @@
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;
@@ -982,9 +979,8 @@
/* 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 */
@@ -1015,14 +1011,13 @@
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;
@@ -1036,9 +1031,8 @@
/* 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 */
diff --git a/stack/l2cap/l2c_utils.cc b/stack/l2cap/l2c_utils.cc
index 8317beb..f07f4e3 100644
--- a/stack/l2cap/l2c_utils.cc
+++ b/stack/l2cap/l2c_utils.cc
@@ -39,8 +39,6 @@
#include "l2cdefs.h"
#include "osi/include/allocator.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*******************************************************************************
*
* Function l2cu_can_allocate_lcb
@@ -1054,9 +1052,8 @@
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);
}
@@ -1556,8 +1553,8 @@
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);
}
@@ -2175,9 +2172,9 @@
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);
}
}
@@ -2272,8 +2269,8 @@
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);
}
@@ -2650,8 +2647,8 @@
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);
}
diff --git a/stack/mcap/mca_cact.cc b/stack/mcap/mca_cact.cc
index 93aef14..f0759ac 100644
--- a/stack/mcap/mca_cact.cc
+++ b/stack/mcap/mca_cact.cc
@@ -34,8 +34,6 @@
#include "btu.h"
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*****************************************************************************
* constants
****************************************************************************/
@@ -131,8 +129,8 @@
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 {
diff --git a/stack/rfcomm/rfc_utils.cc b/stack/rfcomm/rfc_utils.cc
index 7e40355..baf9aa0 100644
--- a/stack/rfcomm/rfc_utils.cc
+++ b/stack/rfcomm/rfc_utils.cc
@@ -38,8 +38,6 @@
#include <string.h>
-extern fixed_queue_t* btu_general_alarm_queue;
-
/*******************************************************************************
*
* Function rfc_calc_fcs
@@ -228,8 +226,8 @@
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);
}
/*******************************************************************************
@@ -256,9 +254,8 @@
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);
}
/*******************************************************************************
diff --git a/stack/sdp/sdp_discovery.cc b/stack/sdp/sdp_discovery.cc
index 191608f..fd9339f 100644
--- a/stack/sdp/sdp_discovery.cc
+++ b/stack/sdp/sdp_discovery.cc
@@ -56,8 +56,6 @@
/* 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
@@ -171,8 +169,8 @@
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);
}
/*******************************************************************************
@@ -486,8 +484,8 @@
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;
@@ -616,8 +614,8 @@
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;
}
diff --git a/stack/sdp/sdp_main.cc b/stack/sdp/sdp_main.cc
index 8cbc3e8..e9fd225 100644
--- a/stack/sdp/sdp_main.cc
+++ b/stack/sdp/sdp_main.cc
@@ -42,8 +42,6 @@
#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 */
/******************************************************************************/
@@ -359,9 +357,8 @@
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);
}
}
}
@@ -400,9 +397,8 @@
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 {
diff --git a/stack/sdp/sdp_server.cc b/stack/sdp/sdp_server.cc
index 24a168c..da85cda 100644
--- a/stack/sdp/sdp_server.cc
+++ b/stack/sdp/sdp_server.cc
@@ -42,8 +42,6 @@
#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
@@ -120,8 +118,8 @@
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++;
diff --git a/stack/smp/smp_act.cc b/stack/smp/smp_act.cc
index 2eba4d8..1ce5264 100644
--- a/stack/smp/smp_act.cc
+++ b/stack/smp/smp_act.cc
@@ -25,8 +25,6 @@
#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,
@@ -1174,9 +1172,9 @@
*/
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;
diff --git a/stack/smp/smp_l2c.cc b/stack/smp/smp_l2c.cc
index f596e0d..6111f10 100644
--- a/stack/smp/smp_l2c.cc
+++ b/stack/smp/smp_l2c.cc
@@ -30,8 +30,6 @@
#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,
@@ -168,8 +166,8 @@
}
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(
@@ -301,8 +299,8 @@
}
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;
diff --git a/stack/smp/smp_utils.cc b/stack/smp/smp_utils.cc
index c935e08..8bdce6b 100644
--- a/stack/smp/smp_utils.cc
+++ b/stack/smp/smp_utils.cc
@@ -36,8 +36,6 @@
#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)
@@ -342,8 +340,8 @@
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);
}
}
diff --git a/stack/test/ble_advertiser_test.cc b/stack/test/ble_advertiser_test.cc
index 39d585a..2ebf62b 100644
--- a/stack/test/ble_advertiser_test.cc
+++ b/stack/test/ble_advertiser_test.cc
@@ -59,8 +59,8 @@
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;
}
@@ -70,7 +70,6 @@
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) {}
diff --git a/stack/test/stack_btu_test.cc b/stack/test/stack_btu_test.cc
index 9d72509..49dc52e 100644
--- a/stack/test/stack_btu_test.cc
+++ b/stack/test/stack_btu_test.cc
@@ -83,7 +83,6 @@
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:
@@ -93,7 +92,6 @@
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