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

Commit d19a2fa2 authored by Hsin-chen Chuang's avatar Hsin-chen Chuang
Browse files

btm_sco_hfp_hal: Change get_packet_size() return type to size_t

The users of get_packet_size() (bluetooth::audio::sco::(wbs|swb)::init)
actually accept the packet size as size_t, and in kernel wbs_pkt_len is
also defined as an unsigned value. There's no reason to define its
return type as signed int.

Bug: 327547486
Tag: #floss
Test: mmm packages/modules/Bluetooth
Flag: EXEMPT, only type change and get_packet_size() always returns 0 on
      Android.

Change-Id: I658014a992308cd1f95fa74bda07cecc99348e1a
parent 780e89f6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ bool enable_offload(bool enable) {
void set_codec_datapath(int codec_uuid) {}

// No packet size limits on Android since it will be offloaded.
int get_packet_size(int codec) { return kDefaultPacketSize; }
size_t get_packet_size(int codec) { return kDefaultPacketSize; }

void notify_sco_connection_change(RawAddress device, bool is_connected,
                                  int codec) {
+2 −2
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ struct bt_codecs {
};

// Use default packet size for codec if this value is given.
constexpr int kDefaultPacketSize = 0;
constexpr size_t kDefaultPacketSize = 0;

constexpr inline int esco_coding_to_codec(esco_coding_format_t esco_coding) {
  switch (esco_coding) {
@@ -94,7 +94,7 @@ bool enable_offload(bool enable);
void set_codec_datapath(int codec_uuid);

// Get the maximum supported packet size from the lower layer.
int get_packet_size(int codec);
size_t get_packet_size(int codec);

// Notify the lower layer about SCO connection change.
void notify_sco_connection_change(RawAddress device, bool is_connected,
+2 −2
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ struct mgmt_bt_codec {

typedef struct cached_codec_info {
  struct bt_codec inner;
  uint8_t pkt_size;
  size_t pkt_size;
} cached_codec_info;

std::vector<cached_codec_info> cached_codecs;
@@ -451,7 +451,7 @@ void set_codec_datapath(int codec_uuid) {
  }
}

int get_packet_size(int codec) {
size_t get_packet_size(int codec) {
  for (const cached_codec_info& c : cached_codecs) {
    if (c.inner.codec == codec) {
      return c.pkt_size;
+2 −2
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ bool enable_offload::return_value = false;
hfp_hal_interface::bt_codecs get_codec_capabilities::return_value = {};
bool get_offload_enabled::return_value = false;
bool get_offload_supported::return_value = false;
int get_packet_size::return_value = 0;
size_t get_packet_size::return_value = 0;
bool get_wbs_supported::return_value = false;
bool get_swb_supported::return_value = false;
bool is_coding_format_supported::return_value = false;
@@ -90,7 +90,7 @@ bool get_offload_supported() {
  inc_func_call_count(__func__);
  return test::mock::stack_btm_sco_hfp_hal::get_offload_supported();
}
int get_packet_size(int codec) {
size_t get_packet_size(int codec) {
  inc_func_call_count(__func__);
  return test::mock::stack_btm_sco_hfp_hal::get_packet_size(codec);
}
+4 −4
Original line number Diff line number Diff line
@@ -85,12 +85,12 @@ extern struct get_offload_supported get_offload_supported;

// Name: get_packet_size
// Params: int codec
// Return: int
// Return: size_t
struct get_packet_size {
  static int return_value;
  std::function<int(int /* codec */)> body{
  static size_t return_value;
  std::function<size_t(int /* codec */)> body{
      [](int /* codec */) { return return_value; }};
  int operator()(int codec) { return body(codec); };
  size_t operator()(int codec) { return body(codec); };
};
extern struct get_packet_size get_packet_size;