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

Commit 9237cb85 authored by Jeremy Wu's avatar Jeremy Wu Committed by Gerrit Code Review
Browse files

Merge "Floss: fix HFP codec types around `set_codec_datapath`"

parents bff282cb 7dcb2583
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -535,7 +535,7 @@ static void bta_ag_create_pending_sco(tBTA_AG_SCB* p_scb, bool is_local) {
    /* Bypass voice settings if enhanced SCO setup command is supported */
    if (!(controller_get_interface()
              ->supports_enhanced_setup_synchronous_connection())) {
      if (esco_codec == BTM_SCO_CODEC_MSBC) {
      if (esco_codec == UUID_CODEC_MSBC || esco_codec == UUID_CODEC_LC3) {
        BTM_WriteVoiceSettings(BTM_VOICE_SETTING_TRANS);
      } else {
        BTM_WriteVoiceSettings(BTM_VOICE_SETTING_CVSD);
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ bool enable_offload(bool enable) {
}

// On Android, this is a no-op because the settings default to offloaded case.
void set_codec_datapath(esco_coding_format_t coding_format) {}
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; }
+1 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ bool get_offload_enabled();
bool enable_offload(bool enable);

// Notify the codec datapath to lower layer for offload mode.
void set_codec_datapath(esco_coding_format_t coding_format);
void set_codec_datapath(int codec_uuid);

// Get the maximum supported packet size from the lower layer.
int get_packet_size(int codec);
+14 −16
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include "osi/include/log.h"
#include "stack/acl/acl.h"
#include "stack/include/acl_api.h"
#include "stack/include/sdpdefs.h"

namespace hfp_hal_interface {
namespace {
@@ -354,49 +355,46 @@ static bool get_single_codec(int codec, bt_codec** out) {
constexpr uint8_t OFFLOAD_DATAPATH = 0x01;

// Notify the codec datapath to lower layer for offload mode
void set_codec_datapath(esco_coding_format_t coding_format) {
void set_codec_datapath(int codec_uuid) {
  bool found;
  bt_codec* codec;
  uint8_t codec_id;

  switch (coding_format) {
    case BTM_SCO_CODEC_CVSD:
  switch (codec_uuid) {
    case UUID_CODEC_CVSD:
      codec_id = codec::CVSD;
      break;
    case BTM_SCO_CODEC_MSBC:
    case UUID_CODEC_MSBC:
      codec_id = get_offload_enabled() ? codec::MSBC : codec::MSBC_TRANSPARENT;
      break;
    default:
      LOG_WARN("Unsupported format (%u). Won't set datapath.", coding_format);
      LOG_WARN("Unsupported codec (%d). Won't set datapath.", codec_uuid);
      return;
  }

  found = get_single_codec(codec_id, &codec);
  if (!found) {
    LOG_ERROR(
        "Failed to find codec config for format (%u). Won't set datapath.",
        coding_format);
    LOG_ERROR("Failed to find codec config for codec (%d). Won't set datapath.",
              codec_uuid);
    return;
  }

  LOG_INFO("Configuring datapath for codec (%u)", codec->codec);
  LOG_INFO("Configuring datapath for codec (%d)", codec_uuid);
  if (codec->codec == codec::MSBC && !get_offload_enabled()) {
    LOG_ERROR(
        "Tried to configure offload data path for format (%u) with offload "
        "Tried to configure offload data path for format (%d) with offload "
        "disabled. Won't set datapath.",
        coding_format);
        codec_uuid);
    return;
  }

  if (get_offload_enabled()) {
    /* TODO(b/237373343): expect the data content to be represented differently
     */
    std::vector<uint8_t> data;
    switch (coding_format) {
      case BTM_SCO_CODEC_CVSD:
    switch (codec_uuid) {
      case UUID_CODEC_CVSD:
        data = {0x00};
        break;
      case BTM_SCO_CODEC_MSBC:
      case UUID_CODEC_MSBC:
        data = {0x01};
        break;
      default: