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

Commit e44fb9dc authored by Jakub Rotkiewicz's avatar Jakub Rotkiewicz Committed by Gerrit Code Review
Browse files

Merge "a2dp_api: allow binding to tA2DP_FIND_CBACK" into main

parents f62454a0 c59c7513
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -843,8 +843,9 @@ void bta_av_do_disc_a2dp(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
      "Initiate SDP discovery for peer {} : uuid_int=0x{:x} sdp_uuid=0x{:x}",
      ADDRESS_TO_LOGGABLE_CSTR(p_scb->PeerAddress()), p_scb->uuid_int,
      sdp_uuid);
  tA2DP_STATUS find_service_status = A2DP_FindService(
      sdp_uuid, p_scb->PeerAddress(), &db_params, bta_av_a2dp_sdp_cback);
  tA2DP_STATUS find_service_status =
      A2DP_FindService(sdp_uuid, p_scb->PeerAddress(), &db_params,
                       base::Bind(bta_av_a2dp_sdp_cback));
  if (find_service_status != A2DP_SUCCESS) {
    log::error(
        "A2DP_FindService() failed for peer {} uuid_int=0x{:x} sdp_uuid=0x{:x} "
+5 −5
Original line number Diff line number Diff line
@@ -149,8 +149,8 @@ static void a2dp_sdp_cback(UNUSED_ATTR const RawAddress& bd_addr,
  a2dp_cb.find.service_uuid = 0;
  osi_free_and_reset((void**)&a2dp_cb.find.p_db);
  /* return info from sdp record in app callback function */
  if (a2dp_cb.find.p_cback != NULL) {
    (*a2dp_cb.find.p_cback)(found, &a2dp_svc, peer_address);
  if (!a2dp_cb.find.p_cback.is_null()) {
    a2dp_cb.find.p_cback.Run(found, &a2dp_svc, peer_address);
  }

  return;
@@ -305,10 +305,10 @@ tA2DP_STATUS A2DP_AddRecord(uint16_t service_uuid, char* p_service_name,
 *****************************************************************************/
tA2DP_STATUS A2DP_FindService(uint16_t service_uuid, const RawAddress& bd_addr,
                              tA2DP_SDP_DB_PARAMS* p_db,
                              tA2DP_FIND_CBACK* p_cback) {
                              tA2DP_FIND_CBACK p_cback) {
  if ((service_uuid != UUID_SERVCLASS_AUDIO_SOURCE &&
       service_uuid != UUID_SERVCLASS_AUDIO_SINK) ||
      p_db == NULL || p_cback == NULL) {
      p_db == NULL || p_cback.is_null()) {
    log::error(
        "Cannot find service for peer {} UUID 0x{:04x}: invalid parameters",
        ADDRESS_TO_LOGGABLE_CSTR(bd_addr), service_uuid);
@@ -348,7 +348,7 @@ tA2DP_STATUS A2DP_FindService(uint16_t service_uuid, const RawAddress& bd_addr,
  if (!get_legacy_stack_sdp_api()->service.SDP_ServiceSearchAttributeRequest(
          bd_addr, a2dp_cb.find.p_db, a2dp_sdp_cback)) {
    a2dp_cb.find.service_uuid = 0;
    a2dp_cb.find.p_cback = NULL;
    a2dp_cb.find.p_cback.Reset();
    osi_free_and_reset((void**)&a2dp_cb.find.p_db);
    log::error("Cannot find service for peer {} UUID 0x{:04x}: SDP error",
               ADDRESS_TO_LOGGABLE_CSTR(bd_addr), service_uuid);
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@

/* Control block used by A2DP_FindService(). */
typedef struct {
  tA2DP_FIND_CBACK* p_cback; /* pointer to application callback */
  tA2DP_FIND_CBACK p_cback;  /* application callback */
  tSDP_DISCOVERY_DB* p_db;   /* pointer to discovery database */
  uint16_t service_uuid;     /* service UUID of search */
} tA2DP_FIND_CB;
+5 −3
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@
#ifndef A2DP_API_H
#define A2DP_API_H

#include <base/functional/callback.h>

#include <cstdint>

#include "stack/include/a2dp_constants.h"
@@ -83,8 +85,8 @@ typedef struct {
} tA2DP_Service;

/* This is the callback to notify the result of the SDP discovery process. */
typedef void(tA2DP_FIND_CBACK)(bool found, tA2DP_Service* p_service,
                               const RawAddress& peer_address);
using tA2DP_FIND_CBACK = base::Callback<void(
    bool found, tA2DP_Service* p_service, const RawAddress& peer_address)>;

/*****************************************************************************
 *  external function declarations
@@ -160,7 +162,7 @@ tA2DP_STATUS A2DP_AddRecord(uint16_t service_uuid, char* p_service_name,
 *****************************************************************************/
tA2DP_STATUS A2DP_FindService(uint16_t service_uuid, const RawAddress& bd_addr,
                              tA2DP_SDP_DB_PARAMS* p_db,
                              tA2DP_FIND_CBACK* p_cback);
                              tA2DP_FIND_CBACK p_cback);

/******************************************************************************
 *
+3 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <vector>

#include "a2dp_api.h"
#include "base/functional/bind.h"
#include "fuzzers/a2dp/a2dpFuzzHelpers.h"
#include "fuzzers/common/commonFuzzHelpers.h"
#include "fuzzers/sdp/sdpFuzzFunctions.h"
@@ -71,7 +72,8 @@ std::vector<std::function<void(FuzzedDataProvider*)>> a2dp_operations = {
      const RawAddress bd_addr = generateRawAddress(fdp);
      uint16_t service_uuid = fdp->ConsumeBool() ? UUID_SERVCLASS_AUDIO_SOURCE
                                                 : UUID_SERVCLASS_AUDIO_SINK;
      A2DP_FindService(service_uuid, bd_addr, &p_db, a2dp_find_callback);
      A2DP_FindService(service_uuid, bd_addr, &p_db,
                       base::Bind(a2dp_find_callback));
    },

    // A2DP_GetAvdtpVersion
Loading