示例#1
0
/*
 * Starts a oneshot timer with a timeout in seconds.
 */
void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec)
{
    osi_alarm_t *alarm = NULL;

    assert(p_tle != NULL);

    // Get the alarm for the timer list entry.
    osi_mutex_lock(&btu_oneshot_alarm_lock, OSI_MUTEX_MAX_TIMEOUT);
    if (!hash_map_has_key(btu_oneshot_alarm_hash_map, p_tle)) {
        alarm = osi_alarm_new("btu_oneshot", btu_oneshot_alarm_cb, (void *)p_tle, 0);
        hash_map_set(btu_oneshot_alarm_hash_map, p_tle, alarm);
    }
    osi_mutex_unlock(&btu_oneshot_alarm_lock);

    alarm = hash_map_get(btu_oneshot_alarm_hash_map, p_tle);
    if (alarm == NULL) {
        LOG_ERROR("%s Unable to create alarm", __func__);
        return;
    }
    osi_alarm_cancel(alarm);

    p_tle->event = type;
    p_tle->in_use = TRUE;
    // NOTE: This value is in seconds but stored in a ticks field.
    p_tle->ticks = timeout_sec;
    osi_alarm_set(alarm, (period_ms_t)(timeout_sec * 1000));
}
示例#2
0
void btu_start_quick_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_ticks)
{
    osi_alarm_t *alarm = NULL;

    assert(p_tle != NULL);

    // Get the alarm for the timer list entry.
    osi_mutex_lock(&btu_l2cap_alarm_lock, OSI_MUTEX_MAX_TIMEOUT);
    if (!hash_map_has_key(btu_l2cap_alarm_hash_map, p_tle)) {
        alarm = osi_alarm_new("btu_l2cap", btu_l2cap_alarm_cb, (void *)p_tle, 0);
        hash_map_set(btu_l2cap_alarm_hash_map, p_tle, (void *)alarm);
    }
    osi_mutex_unlock(&btu_l2cap_alarm_lock);

    alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_tle);
    if (alarm == NULL) {
        LOG_ERROR("%s Unable to create alarm", __func__);
        return;
    }
    osi_alarm_cancel(alarm);

    p_tle->event = type;
    p_tle->ticks = timeout_ticks;
    p_tle->in_use = TRUE;
    // The quick timer ticks are 100ms long.
    osi_alarm_set(alarm, (period_ms_t)(timeout_ticks * 100));
}
示例#3
0
void btu_start_quick_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_ticks) {
  assert(p_tle != NULL);

  // Get the alarm for the timer list entry.
  pthread_mutex_lock(&btu_l2cap_alarm_lock);
  if (!hash_map_has_key(btu_l2cap_alarm_hash_map, p_tle)) {
    hash_map_set(btu_l2cap_alarm_hash_map, p_tle, alarm_new());
  }
  pthread_mutex_unlock(&btu_l2cap_alarm_lock);

  alarm_t *alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_tle);
  if (alarm == NULL) {
    LOG_ERROR(LOG_TAG, "%s Unable to create alarm", __func__);
    return;
  }
  alarm_cancel(alarm);

  p_tle->event = type;
  p_tle->ticks = timeout_ticks;
  p_tle->in_use = TRUE;
  // The quick timer ticks are 100ms long.
  alarm_set(alarm, (period_ms_t)(timeout_ticks * 100), btu_l2cap_alarm_cb, (void *)p_tle);
}
示例#4
0
void btu_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec) {
  assert(p_tle != NULL);

  // Get the alarm for the timer list entry.
  pthread_mutex_lock(&btu_general_alarm_lock);
  if (!hash_map_has_key(btu_general_alarm_hash_map, p_tle)) {
    hash_map_set(btu_general_alarm_hash_map, p_tle, alarm_new());
  }
  pthread_mutex_unlock(&btu_general_alarm_lock);

  alarm_t *alarm = hash_map_get(btu_general_alarm_hash_map, p_tle);
  if (alarm == NULL) {
    LOG_ERROR(LOG_TAG, "%s Unable to create alarm", __func__);
    return;
  }
  alarm_cancel(alarm);

  p_tle->event = type;
  // NOTE: This value is in seconds but stored in a ticks field.
  p_tle->ticks = timeout_sec;
  p_tle->in_use = TRUE;
  alarm_set(alarm, (period_ms_t)(timeout_sec * 1000), btu_general_alarm_cb, (void *)p_tle);
}