Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba4dbee1 authored by Henri Chataing's avatar Henri Chataing Committed by Gerrit Code Review
Browse files

Merge "system/stack/avrc: Migrate to libbluetooth_log" into main

parents 48dda7c7 b539bde2
Loading
Loading
Loading
Loading
+57 −54
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
#include "avrc_api.h"

#include <android_bluetooth_sysprop.h>
#include <base/logging.h>
#include <bluetooth/log.h>
#include <string.h>

#include "avrc_int.h"
@@ -42,6 +42,8 @@
#include "storage/config_keys.h"
#include "types/raw_address.h"

using namespace bluetooth;

/*****************************************************************************
 *  Global data
 ****************************************************************************/
@@ -135,7 +137,7 @@ static void avrc_ctrl_cback(uint8_t handle, uint8_t event, uint16_t result,
 *
 *****************************************************************************/
void avrc_flush_cmd_q(uint8_t handle) {
  LOG_VERBOSE("AVRC: Flushing command queue for handle=0x%02x", handle);
  log::verbose("AVRC: Flushing command queue for handle=0x{:02x}", handle);
  avrc_cb.ccb_int[handle].flags &= ~AVRC_CB_FLAGS_RSP_PENDING;

  alarm_cancel(avrc_cb.ccb_int[handle].tle);
@@ -155,7 +157,7 @@ void avrc_flush_cmd_q(uint8_t handle) {
void avrc_process_timeout(void* data) {
  tAVRC_PARAM* param = (tAVRC_PARAM*)data;

  LOG_VERBOSE("AVRC: command timeout (handle=0x%02x, label=0x%02x)",
  log::verbose("AVRC: command timeout (handle=0x{:02x}, label=0x{:02x})",
               param->handle, param->label);

  /* Notify app */
@@ -190,8 +192,9 @@ void avrc_send_next_vendor_cmd(uint8_t handle) {
    next_label = (p_next_cmd->layer_specific) >> 8; /* extract label */
    p_next_cmd->layer_specific &= 0xFF; /* AVCT_DATA_CTRL or AVCT_DATA_BROWSE */

    LOG_VERBOSE("AVRC: Dequeuing command 0x%p (handle=0x%02x, label=0x%02x)",
                p_next_cmd, handle, next_label);
    log::verbose(
        "AVRC: Dequeuing command 0x{} (handle=0x{:02x}, label=0x{:02x})",
        fmt::ptr(p_next_cmd), handle, next_label);

    /* Send the message */
    if ((AVCT_MsgReq(handle, next_label, AVCT_CMD, p_next_cmd)) ==
@@ -224,7 +227,7 @@ void avrc_start_cmd_timer(uint8_t handle, uint8_t label, uint8_t msg_mask) {
  param->label = label;
  param->msg_mask = msg_mask;

  LOG_VERBOSE("AVRC: starting timer (handle=0x%02x, label=0x%02x)", handle,
  log::verbose("AVRC: starting timer (handle=0x{:02x}, label=0x{:02x})", handle,
               label);

  alarm_set_on_mloop(avrc_cb.ccb_int[handle].tle, AVRC_CMD_TOUT_MS,
@@ -284,7 +287,7 @@ static void avrc_prep_end_frag(uint8_t handle) {
  uint8_t *p_data, *p_orig_data;
  uint8_t rsp_type;

  LOG_VERBOSE("%s", __func__);
  log::verbose("");
  p_fcb = &avrc_cb.fcb[handle];

  /* The response type of the end fragment should be the same as the the PDU of
@@ -331,8 +334,7 @@ static uint16_t avrc_send_continue_frag(uint8_t handle, uint8_t label) {
  p_fcb = &avrc_cb.fcb[handle];
  p_pkt = p_fcb->p_fmsg;

  LOG_VERBOSE("%s handle = %u label = %u len = %d", __func__, handle, label,
              p_pkt->len);
  log::verbose("handle = {} label = {} len = {}", handle, label, p_pkt->len);
  if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN) {
    int offset_len = MAX(AVCT_MSG_OFFSET, p_pkt->offset);
    p_pkt_old = p_fcb->p_fmsg;
@@ -388,7 +390,7 @@ static BT_HDR* avrc_proc_vendor_command(uint8_t handle, uint8_t label,

  if (pkt_type != AVRC_PKT_SINGLE) {
    /* reject - commands can only be in single packets at AVRCP level */
    LOG_ERROR("commands must be in single packet pdu:0x%x", *p_data);
    log::error("commands must be in single packet pdu:0x{:x}", *p_data);
    /* use the current GKI buffer to send the reject */
    status = AVRC_STS_BAD_CMD;
  }
@@ -422,9 +424,9 @@ static BT_HDR* avrc_proc_vendor_command(uint8_t handle, uint8_t label,
          } else {
            /* the pdu id does not match - reject the command using the current
             * GKI buffer */
            LOG_ERROR(
                "%s continue pdu: 0x%x does not match the current pdu: 0x%x",
                __func__, *(p_data + 4), p_fcb->frag_pdu);
            log::error(
                "continue pdu: 0x{:x} does not match the current pdu: 0x{:x}",
                *(p_data + 4), p_fcb->frag_pdu);
            status = AVRC_STS_BAD_PARAM;
            abort_frag = true;
          }
@@ -491,7 +493,7 @@ static uint8_t avrc_proc_far_msg(uint8_t handle, uint8_t label, uint8_t cr,
  p_data += AVRC_VENDOR_HDR_SIZE;

  pkt_type = *(p_data + 1) & AVRC_PKT_TYPE_MASK;
  LOG_VERBOSE("pkt_type %d", pkt_type);
  log::verbose("pkt_type {}", pkt_type);
  p_rcb = &avrc_cb.rcb[handle];

  /* check if the message needs to be re-assembled */
@@ -534,9 +536,9 @@ static uint8_t avrc_proc_far_msg(uint8_t handle, uint8_t label, uint8_t cr,
    } else if (p_rcb->p_rmsg == NULL) {
      /* Received a CONTINUE/END, but no corresponding START
                      (or previous fragmented response was dropped) */
      LOG_VERBOSE(
          "Received a CONTINUE/END without no corresponding START"
          " (or previous fragmented response was dropped)");
      log::verbose(
          "Received a CONTINUE/END without no corresponding START (or previous "
          "fragmented response was dropped)");
      drop_code = 5;
      osi_free(p_pkt);
      *pp_pkt = NULL;
@@ -552,7 +554,7 @@ static uint8_t avrc_proc_far_msg(uint8_t handle, uint8_t label, uint8_t cr,
      p_pkt->len -= (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE);
      /* verify length */
      if ((p_rcb->p_rmsg->offset + p_pkt->len) > buf_len) {
        LOG_WARN("Fragmented message too big! - report the partial message");
        log::warn("Fragmented message too big! - report the partial message");
        p_pkt->len = buf_len - p_rcb->p_rmsg->offset;
        pkt_type = AVRC_PKT_END;
        buf_overflow = true;
@@ -577,7 +579,7 @@ static uint8_t avrc_proc_far_msg(uint8_t handle, uint8_t label, uint8_t cr,
        *p_data++ = AVRC_PKT_SINGLE;
        UINT16_TO_BE_STREAM(p_data,
                            (p_msg->vendor_len - AVRC_MIN_META_HDR_SIZE));
        LOG_VERBOSE("end frag:%d, total len:%d, offset:%d", p_pkt->len,
        log::verbose("end frag:{}, total len:{}, offset:{}", p_pkt->len,
                     p_pkt_new->len, p_pkt_new->offset);
      } else {
        p_rcb->p_rmsg->offset += p_pkt->len;
@@ -655,8 +657,8 @@ static void avrc_msg_cback(uint8_t handle, uint8_t label, uint8_t cr,

  if (cr == AVCT_CMD && (p_pkt->layer_specific & AVCT_DATA_CTRL &&
                         p_pkt->len > AVRC_PACKET_LEN)) {
    LOG_WARN("%s: Command length %d too long: must be at most %d", __func__,
             p_pkt->len, AVRC_PACKET_LEN);
    log::warn("Command length {} too long: must be at most {}", p_pkt->len,
              AVRC_PACKET_LEN);
    osi_free(p_pkt);
    return;
  }
@@ -669,7 +671,7 @@ static void avrc_msg_cback(uint8_t handle, uint8_t label, uint8_t cr,
    return;
  } else if (cr == AVCT_RSP) {
    /* Received response. Stop command timeout timer */
    LOG_VERBOSE("AVRC: stopping timer (handle=0x%02x)", handle);
    log::verbose("AVRC: stopping timer (handle=0x{:02x})", handle);
    alarm_cancel(avrc_cb.ccb_int[handle].tle);
  }

@@ -684,13 +686,13 @@ static void avrc_msg_cback(uint8_t handle, uint8_t label, uint8_t cr,
    msg.browse.p_browse_pkt = p_pkt;
  } else {
    if (p_pkt->len < AVRC_AVC_HDR_SIZE) {
      LOG_WARN("%s: message length %d too short: must be at least %d", __func__,
               p_pkt->len, AVRC_AVC_HDR_SIZE);
      log::warn("message length {} too short: must be at least {}", p_pkt->len,
                AVRC_AVC_HDR_SIZE);
      osi_free(p_pkt);
      return;
    }
    msg.hdr.ctype = p_data[0] & AVRC_CTYPE_MASK;
    LOG_VERBOSE("%s handle:%d, ctype:%d, offset:%d, len: %d", __func__, handle,
    log::verbose("handle:{}, ctype:{}, offset:{}, len: {}", handle,
                 msg.hdr.ctype, p_pkt->offset, p_pkt->len);
    msg.hdr.subunit_type =
        (p_data[1] & AVRC_SUBTYPE_MASK) >> AVRC_SUBTYPE_SHIFT;
@@ -723,8 +725,8 @@ static void avrc_msg_cback(uint8_t handle, uint8_t label, uint8_t cr,
        } else {
          /* parse response */
          if (p_pkt->len < AVRC_OP_UNIT_INFO_RSP_LEN) {
            LOG_WARN("%s: message length %d too short: must be at least %d",
                     __func__, p_pkt->len, AVRC_OP_UNIT_INFO_RSP_LEN);
            log::warn("message length {} too short: must be at least {}",
                      p_pkt->len, AVRC_OP_UNIT_INFO_RSP_LEN);
            drop = true;
            p_drop_msg = "UNIT_INFO_RSP too short";
            break;
@@ -759,8 +761,8 @@ static void avrc_msg_cback(uint8_t handle, uint8_t label, uint8_t cr,
        } else {
          /* parse response */
          if (p_pkt->len < AVRC_OP_SUB_UNIT_INFO_RSP_LEN) {
            LOG_WARN("%s: message length %d too short: must be at least %d",
                     __func__, p_pkt->len, AVRC_OP_SUB_UNIT_INFO_RSP_LEN);
            log::warn("message length {} too short: must be at least {}",
                      p_pkt->len, AVRC_OP_SUB_UNIT_INFO_RSP_LEN);
            drop = true;
            p_drop_msg = "SUB_UNIT_INFO_RSP too short";
            break;
@@ -905,8 +907,8 @@ static void avrc_msg_cback(uint8_t handle, uint8_t label, uint8_t cr,
    msg.hdr.opcode = opcode;
    avrc_cb.ccb[handle].msg_cback.Run(handle, label, opcode, &msg);
  } else {
    LOG_WARN("%s %s msg handle:%d, control:%d, cr:%d, opcode:x%x", __func__,
             p_drop_msg, handle, avrc_cb.ccb[handle].control, cr, opcode);
    log::warn("{} msg handle:{}, control:{}, cr:{}, opcode:x{:x}", p_drop_msg,
              handle, avrc_cb.ccb[handle].control, cr, opcode);
  }

  if (opcode == AVRC_OP_BROWSE && msg.browse.p_browse_pkt == NULL) {
@@ -1090,8 +1092,8 @@ uint16_t AVRC_Open(uint8_t* p_handle, tAVRC_CONN_CB* p_ccb,
    avrc_cb.ccb_int[*p_handle].tle = alarm_new("avrcp.commandTimer");
    avrc_cb.ccb_int[*p_handle].cmd_q = fixed_queue_new(SIZE_MAX);
  }
  LOG_VERBOSE("%s role: %d, control:%d status:%d, handle:%d", __func__, cc.role,
              cc.control, status, *p_handle);
  log::verbose("role: {}, control:{} status:{}, handle:{}", cc.role, cc.control,
               status, *p_handle);

  return status;
}
@@ -1115,7 +1117,7 @@ uint16_t AVRC_Open(uint8_t* p_handle, tAVRC_CONN_CB* p_ccb,
 *
 *****************************************************************************/
uint16_t AVRC_Close(uint8_t handle) {
  LOG_VERBOSE("%s handle:%d", __func__, handle);
  log::verbose("handle:{}", handle);
  avrc_flush_cmd_q(handle);
  return AVCT_RemoveConn(handle);
}
@@ -1186,8 +1188,8 @@ uint16_t AVRC_MsgReq(uint8_t handle, uint8_t label, uint8_t ctype,

  if (!p_pkt) return AVRC_BAD_PARAM;

  LOG_VERBOSE("%s handle = %u label = %u ctype = %u len = %d", __func__, handle,
              label, ctype, p_pkt->len);
  log::verbose("handle = {} label = {} ctype = {} len = {}", handle, label,
               ctype, p_pkt->len);
  /* Handle for AVRCP fragment */
  if (!GET_SYSPROP(A2dp, src_sink_coexist, false))
    is_new_avrcp =
@@ -1238,8 +1240,8 @@ uint16_t AVRC_MsgReq(uint8_t handle, uint8_t label, uint8_t ctype,
      peer_mtu = AVCT_GetPeerMtu(handle);
    }
    if (p_pkt->len > (peer_mtu - AVCT_HDR_LEN_SINGLE)) {
      LOG_ERROR("%s bigger than peer mtu (p_pkt->len(%d) > peer_mtu(%d-%d))",
                __func__, p_pkt->len, peer_mtu, AVCT_HDR_LEN_SINGLE);
      log::error("bigger than peer mtu (p_pkt->len({}) > peer_mtu({}-{}))",
                 p_pkt->len, peer_mtu, AVCT_HDR_LEN_SINGLE);
      osi_free(p_pkt);
      return AVRC_MSG_TOO_BIG;
    }
@@ -1249,7 +1251,7 @@ uint16_t AVRC_MsgReq(uint8_t handle, uint8_t label, uint8_t ctype,
  p_fcb = &avrc_cb.fcb[handle];

  if (p_fcb == NULL) {
    LOG_ERROR("%s p_fcb is NULL", __func__);
    log::error("p_fcb is NULL");
    osi_free(p_pkt);
    return AVRC_NOT_OPEN;
  }
@@ -1291,11 +1293,11 @@ uint16_t AVRC_MsgReq(uint8_t handle, uint8_t label, uint8_t ctype,

        /* prepare the left over for as an end fragment */
        avrc_prep_end_frag(handle);
        LOG_VERBOSE("%s p_pkt len:%d/%d, next len:%d", __func__, p_pkt->len,
                    len, p_fcb->p_fmsg->len);
        log::verbose("p_pkt len:{}/{}, next len:{}", p_pkt->len, len,
                     p_fcb->p_fmsg->len);
      } else {
        /* TODO: Is this "else" block valid? Remove it? */
        LOG_ERROR("%s no buffers for fragmentation", __func__);
        log::error("no buffers for fragmentation");
        osi_free(p_pkt);
        return AVRC_NO_RESOURCES;
      }
@@ -1309,8 +1311,9 @@ uint16_t AVRC_MsgReq(uint8_t handle, uint8_t label, uint8_t ctype,
     * command
     * is received (exception is continuation request command
     * must sent that to get additional response frags) */
    LOG_VERBOSE("AVRC: Enqueuing command 0x%p (handle=0x%02x, label=0x%02x)",
                p_pkt, handle, label);
    log::verbose(
        "AVRC: Enqueuing command 0x{} (handle=0x{:02x}, label=0x{:02x})",
        fmt::ptr(p_pkt), handle, label);

    /* label in BT_HDR (will need this later when the command is dequeued) */
    p_pkt->layer_specific = (label << 8) | (p_pkt->layer_specific & 0xFF);
@@ -1437,21 +1440,21 @@ void AVRC_SaveControllerVersion(const RawAddress& bdaddr,
                          BTIF_STORAGE_KEY_AVRCP_CONTROLLER_VERSION,
                          (uint8_t*)&old_version, &version_value_size) &&
      new_version == old_version) {
    LOG_INFO("AVRC controller version same as cached config");
    log::info("AVRC controller version same as cached config");
  } else if (btif_config_set_bin(
                 bdaddr.ToString(), BTIF_STORAGE_KEY_AVRCP_CONTROLLER_VERSION,
                 (const uint8_t*)&new_version, sizeof(new_version))) {
    LOG_INFO("store AVRC controller version %x for %s into config.",
    log::info("store AVRC controller version {:x} for {} into config.",
              new_version, ADDRESS_TO_LOGGABLE_CSTR(bdaddr));
  } else {
    LOG_WARN("Failed to store AVRC controller version for %s",
    log::warn("Failed to store AVRC controller version for {}",
              ADDRESS_TO_LOGGABLE_CSTR(bdaddr));
  }
}

void AVRC_UpdateCcb(RawAddress* addr, uint32_t company_id) {
  for (uint8_t i = 0; i < AVCT_NUM_CONN; i++) {
    LOG_INFO("%s: handle:%d, update cback:0x%0x", __func__, i, company_id);
    log::info("handle:{}, update cback:0x{:0x}", i, company_id);
    if (avrc_cb.ccb[i].company_id == company_id) {
      avrc_cb.ccb[i].ctrl_cback.Run(i, AVRC_CLOSE_IND_EVT, 0, addr);
    }
+31 −28
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#define LOG_TAG "avrcp"

#include <bluetooth/log.h>
#include <string.h>

#include "avrc_api.h"
@@ -29,6 +30,8 @@
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_types.h"

using namespace bluetooth;

/*****************************************************************************
 *  Global data
 ****************************************************************************/
@@ -46,7 +49,7 @@
static tAVRC_STS avrc_bld_next_cmd(tAVRC_NEXT_CMD* p_cmd, BT_HDR* p_pkt) {
  uint8_t *p_data, *p_start;

  LOG_VERBOSE("avrc_bld_next_cmd");
  log::verbose("avrc_bld_next_cmd");

  /* get the existing length, if any, and also the num attributes */
  p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
@@ -78,7 +81,7 @@ static tAVRC_STS avrc_bld_set_abs_volume_cmd(tAVRC_SET_VOLUME_CMD* p_cmd,
                                             BT_HDR* p_pkt) {
  uint8_t *p_data, *p_start;

  LOG_VERBOSE("avrc_bld_set_abs_volume_cmd");
  log::verbose("avrc_bld_set_abs_volume_cmd");
  /* get the existing length, if any, and also the num attributes */
  p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  p_data = p_start + 2; /* pdu + rsvd */
@@ -103,7 +106,7 @@ static tAVRC_STS avrc_bld_register_notifn(BT_HDR* p_pkt, uint8_t event_id,
                                          uint32_t event_param) {
  uint8_t *p_data, *p_start;

  LOG_VERBOSE("avrc_bld_register_notifn");
  log::verbose("avrc_bld_register_notifn");
  /* get the existing length, if any, and also the num attributes */
  // Set the notify value
  p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
@@ -127,7 +130,7 @@ static tAVRC_STS avrc_bld_register_notifn(BT_HDR* p_pkt, uint8_t event_id,
 *
 ******************************************************************************/
static tAVRC_STS avrc_bld_get_capability_cmd(BT_HDR* p_pkt, uint8_t cap_id) {
  LOG_VERBOSE("avrc_bld_get_capability_cmd");
  log::verbose("avrc_bld_get_capability_cmd");
  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  uint8_t* p_data = p_start + 2; /* pdu + rsvd */
  /* add fixed length 1 -*/
@@ -148,7 +151,7 @@ static tAVRC_STS avrc_bld_get_capability_cmd(BT_HDR* p_pkt, uint8_t cap_id) {
 *
 ******************************************************************************/
static tAVRC_STS avrc_bld_list_player_app_attr_cmd(BT_HDR* p_pkt) {
  LOG_VERBOSE("avrc_bld_list_player_app_attr_cmd");
  log::verbose("avrc_bld_list_player_app_attr_cmd");
  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  uint8_t* p_data = p_start + 2; /* pdu + rsvd */
  /* add fixed length 1 -*/
@@ -169,7 +172,7 @@ static tAVRC_STS avrc_bld_list_player_app_attr_cmd(BT_HDR* p_pkt) {
 ******************************************************************************/
static tAVRC_STS avrc_bld_list_player_app_values_cmd(BT_HDR* p_pkt,
                                                     uint8_t attrib_id) {
  LOG_VERBOSE("avrc_bld_list_player_app_values_cmd");
  log::verbose("avrc_bld_list_player_app_values_cmd");
  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  uint8_t* p_data = p_start + 2; /* pdu + rsvd */
  /* add fixed length 1 -*/
@@ -192,7 +195,7 @@ static tAVRC_STS avrc_bld_list_player_app_values_cmd(BT_HDR* p_pkt,
 ******************************************************************************/
static tAVRC_STS avrc_bld_get_current_player_app_values_cmd(
    BT_HDR* p_pkt, uint8_t num_attrib_id, uint8_t* attrib_ids) {
  LOG_VERBOSE("avrc_bld_get_current_player_app_values_cmd");
  log::verbose("avrc_bld_get_current_player_app_values_cmd");
  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  uint8_t* p_data = p_start + 2; /* pdu + rsvd */
  uint8_t param_len =
@@ -220,7 +223,7 @@ static tAVRC_STS avrc_bld_get_current_player_app_values_cmd(
 ******************************************************************************/
static tAVRC_STS avrc_bld_set_current_player_app_values_cmd(
    BT_HDR* p_pkt, uint8_t num_attrib_id, tAVRC_APP_SETTING* p_val) {
  LOG_VERBOSE("avrc_bld_set_current_player_app_values_cmd");
  log::verbose("avrc_bld_set_current_player_app_values_cmd");
  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  uint8_t* p_data = p_start + 2; /* pdu + rsvd */
  /* we have to store attrib- value pair
@@ -251,7 +254,7 @@ static tAVRC_STS avrc_bld_set_current_player_app_values_cmd(
 ******************************************************************************/
static tAVRC_STS avrc_bld_get_player_app_setting_attr_text_cmd(
    BT_HDR* p_pkt, tAVRC_GET_APP_ATTR_TXT_CMD* p_cmd) {
  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  uint8_t* p_data = p_start + 2; /* pdu + rsvd */
@@ -280,7 +283,7 @@ static tAVRC_STS avrc_bld_get_player_app_setting_attr_text_cmd(
 ******************************************************************************/
static tAVRC_STS avrc_bld_get_player_app_setting_value_text_cmd(
    BT_HDR* p_pkt, tAVRC_GET_APP_VAL_TXT_CMD* p_cmd) {
  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  uint8_t* p_data = p_start + 2; /* pdu + rsvd */
@@ -309,7 +312,7 @@ static tAVRC_STS avrc_bld_get_player_app_setting_value_text_cmd(
static tAVRC_STS avrc_bld_get_element_attr_cmd(BT_HDR* p_pkt,
                                               uint8_t num_attrib,
                                               uint32_t* attrib_ids) {
  LOG_VERBOSE("avrc_bld_get_element_attr_cmd");
  log::verbose("avrc_bld_get_element_attr_cmd");
  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  uint8_t* p_data = p_start + 2; /* pdu + rsvd */
  /* we have to store attrib- value pair
@@ -341,7 +344,7 @@ static tAVRC_STS avrc_bld_get_element_attr_cmd(BT_HDR* p_pkt,
 ******************************************************************************/
static tAVRC_STS avrc_bld_play_item_cmd(BT_HDR* p_pkt, uint8_t scope,
                                        uint8_t* uid, uint16_t uid_counter) {
  LOG_VERBOSE("avrc_bld_get_element_attr_cmd");
  log::verbose("avrc_bld_get_element_attr_cmd");
  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  uint8_t* p_data = p_start + 2; /* pdu + rsvd */
  /* add fixed length 11 */
@@ -367,7 +370,7 @@ static tAVRC_STS avrc_bld_play_item_cmd(BT_HDR* p_pkt, uint8_t scope,
 *
 ******************************************************************************/
static tAVRC_STS avrc_bld_get_play_status_cmd(BT_HDR* p_pkt) {
  LOG_VERBOSE("avrc_bld_list_player_app_attr_cmd");
  log::verbose("avrc_bld_list_player_app_attr_cmd");
  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  uint8_t* p_data = p_start + 2; /* pdu + rsvd */
  /* add fixed length 0 -*/
@@ -388,8 +391,8 @@ static tAVRC_STS avrc_bld_get_play_status_cmd(BT_HDR* p_pkt) {
 ******************************************************************************/
static tAVRC_STS avrc_bld_get_folder_items_cmd(BT_HDR* p_pkt,
                                               const tAVRC_GET_ITEMS_CMD* cmd) {
  LOG_VERBOSE(
      "avrc_bld_get_folder_items_cmd scope %d, start_item %d, end_item %d",
  log::verbose(
      "avrc_bld_get_folder_items_cmd scope {}, start_item {}, end_item {}",
      cmd->scope, cmd->start_item, cmd->end_item);
  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  /* This is where the PDU specific for AVRC starts
@@ -420,7 +423,7 @@ static tAVRC_STS avrc_bld_get_folder_items_cmd(BT_HDR* p_pkt,
 ******************************************************************************/
static tAVRC_STS avrc_bld_change_folder_cmd(BT_HDR* p_pkt,
                                            const tAVRC_CHG_PATH_CMD* cmd) {
  LOG_VERBOSE("avrc_bld_change_folder_cmd");
  log::verbose("avrc_bld_change_folder_cmd");
  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  /* This is where the PDU specific for AVRC starts
   * AVRCP Spec 1.4 section 22.19 */
@@ -438,7 +441,7 @@ static tAVRC_STS avrc_bld_change_folder_cmd(BT_HDR* p_pkt,
}
static tAVRC_STS avrc_bld_get_item_attributes_cmd(
    BT_HDR* p_pkt, const tAVRC_GET_ATTRS_CMD* cmd) {
  LOG_VERBOSE("%s", __func__);
  log::verbose("");
  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  /* This is where the PDU specific for AVRC starts
   * AVRCP Spec 1.4 section 22.19 */
@@ -466,7 +469,7 @@ static tAVRC_STS avrc_bld_get_item_attributes_cmd(
 ******************************************************************************/
static tAVRC_STS avrc_bld_set_browsed_player_cmd(
    BT_HDR* p_pkt, const tAVRC_SET_BR_PLAYER_CMD* cmd) {
  LOG_VERBOSE("%s", __func__);
  log::verbose("");
  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  /* This is where the PDU specific for AVRC starts
   * AVRCP Spec 1.4 section 22.19 */
@@ -493,7 +496,7 @@ static tAVRC_STS avrc_bld_set_browsed_player_cmd(
 ******************************************************************************/
static tAVRC_STS avrc_bld_set_addressed_player_cmd(
    BT_HDR* p_pkt, const tAVRC_SET_ADDR_PLAYER_CMD* cmd) {
  LOG_VERBOSE("%s", __func__);
  log::verbose("");
  /* get the existing length, if any, and also the num attributes */
  uint8_t* p_start = (uint8_t*)(p_pkt + 1) + p_pkt->offset;
  uint8_t* p_data = p_start + 2; /* pdu + rsvd */
@@ -521,7 +524,7 @@ static tAVRC_STS avrc_bld_set_addressed_player_cmd(
static BT_HDR* avrc_bld_init_cmd_buffer(tAVRC_COMMAND* p_cmd) {
  uint16_t chnl = AVCT_DATA_CTRL;
  uint8_t opcode = avrc_opcode_from_pdu(p_cmd->pdu);
  LOG_VERBOSE("avrc_bld_init_cmd_buffer: pdu=%x, opcode=%x", p_cmd->pdu,
  log::verbose("avrc_bld_init_cmd_buffer: pdu={:x}, opcode={:x}", p_cmd->pdu,
               opcode);

  uint16_t offset = 0;
@@ -583,19 +586,19 @@ static BT_HDR* avrc_bld_init_cmd_buffer(tAVRC_COMMAND* p_cmd) {
tAVRC_STS AVRC_BldCommand(tAVRC_COMMAND* p_cmd, BT_HDR** pp_pkt) {
  tAVRC_STS status = AVRC_STS_BAD_PARAM;
  bool alloc = false;
  LOG_VERBOSE("AVRC_BldCommand: pdu=%x status=%x", p_cmd->cmd.pdu,
  log::verbose("AVRC_BldCommand: pdu={:x} status={:x}", p_cmd->cmd.pdu,
               p_cmd->cmd.status);
  if (!p_cmd || !pp_pkt) {
    LOG_VERBOSE(
        "AVRC_BldCommand. Invalid parameters passed. p_cmd=%p, pp_pkt=%p",
        p_cmd, pp_pkt);
    log::verbose(
        "AVRC_BldCommand. Invalid parameters passed. p_cmd={}, pp_pkt={}",
        fmt::ptr(p_cmd), fmt::ptr(pp_pkt));
    return AVRC_STS_BAD_PARAM;
  }

  if (*pp_pkt == NULL) {
    *pp_pkt = avrc_bld_init_cmd_buffer(p_cmd);
    if (*pp_pkt == NULL) {
      LOG_VERBOSE("AVRC_BldCommand: Failed to initialize command buffer");
      log::verbose("AVRC_BldCommand: Failed to initialize command buffer");
      return AVRC_STS_INTERNAL_ERR;
    }
    alloc = true;
@@ -684,6 +687,6 @@ tAVRC_STS AVRC_BldCommand(tAVRC_COMMAND* p_cmd, BT_HDR** pp_pkt) {
    osi_free(p_pkt);
    *pp_pkt = NULL;
  }
  LOG_VERBOSE("AVRC_BldCommand: returning %d", status);
  log::verbose("AVRC_BldCommand: returning {}", status);
  return status;
}
+75 −76

File changed.

Preview size limit exceeded, changes collapsed.

+4 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
 *  Interface to AVRCP optional commands
 *
 ******************************************************************************/
#include <base/logging.h>
#include <bluetooth/log.h>
#include <string.h>

#include "avrc_api.h"
@@ -30,6 +30,8 @@
#include "osi/include/allocator.h"
#include "stack/include/bt_hdr.h"

using namespace bluetooth;

/******************************************************************************
 *
 * Function         avrc_vendor_msg
+74 −84

File changed.

Preview size limit exceeded, changes collapsed.

Loading