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

Commit b18bee72 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "audio_hal_interface/a2dp_encoding: Rename BluetoothAudioStatus ->...

Merge "audio_hal_interface/a2dp_encoding: Rename BluetoothAudioStatus -> Status" into main am: 51c3237f

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/3366438



Change-Id: Idee75eb5e0a1123192d2ab40232e2d36fa57afe8
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c33ebe2d 51c3237f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ void end_session() {
  }
}

void ack_stream_started(BluetoothAudioStatus status) {
void ack_stream_started(Status status) {
  if (HalVersionManager::GetHalTransport() == BluetoothAudioHalTransport::HIDL) {
    hidl::a2dp::ack_stream_started(status);
    return;
@@ -107,7 +107,7 @@ void ack_stream_started(BluetoothAudioStatus status) {
  return aidl::a2dp::ack_stream_started(status);
}

void ack_stream_suspended(BluetoothAudioStatus status) {
void ack_stream_suspended(Status status) {
  if (HalVersionManager::GetHalTransport() == BluetoothAudioHalTransport::HIDL) {
    hidl::a2dp::ack_stream_suspended(status);
    return;
+9 −13
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ namespace a2dp {

/// Loosely copied after the definition from the Bluetooth Audio interface:
/// audio/aidl/android/hardware/bluetooth/audio/BluetoothAudioStatus.aidl
enum class BluetoothAudioStatus {
enum class Status {
  SUCCESS = 0,
  UNKNOWN,
  UNSUPPORTED_CODEC_CONFIGURATION,
@@ -51,14 +51,10 @@ enum class BluetoothAudioStatus {
class StreamCallbacks {
public:
  virtual ~StreamCallbacks() {}
  virtual BluetoothAudioStatus StartStream(bool /*low_latency*/) const {
    return BluetoothAudioStatus::FAILURE;
  }
  virtual BluetoothAudioStatus SuspendStream() const { return BluetoothAudioStatus::FAILURE; }
  virtual BluetoothAudioStatus StopStream() const { return SuspendStream(); }
  virtual BluetoothAudioStatus SetLatencyMode(bool /*low_latency*/) const {
    return BluetoothAudioStatus::FAILURE;
  }
  virtual Status StartStream(bool /*low_latency*/) const { return Status::FAILURE; }
  virtual Status SuspendStream() const { return Status::FAILURE; }
  virtual Status StopStream() const { return SuspendStream(); }
  virtual Status SetLatencyMode(bool /*low_latency*/) const { return Status::FAILURE; }
};

bool update_codec_offloading_capabilities(
@@ -89,8 +85,8 @@ void set_audio_low_latency_mode_allowed(bool allowed);
// StreamStarted, StreamSuspended
void start_session();
void end_session();
void ack_stream_started(BluetoothAudioStatus status);
void ack_stream_suspended(BluetoothAudioStatus status);
void ack_stream_started(Status status);
void ack_stream_suspended(Status status);

// Read from the FMQ of BluetoothAudio HAL
size_t read(uint8_t* p_buf, uint32_t len);
@@ -200,6 +196,6 @@ tA2DP_STATUS parse_a2dp_configuration(btav_a2dp_codec_index_t codec_index,

namespace std {
template <>
struct formatter<::bluetooth::audio::a2dp::BluetoothAudioStatus>
    : enum_formatter<::bluetooth::audio::a2dp::BluetoothAudioStatus> {};
struct formatter<::bluetooth::audio::a2dp::Status>
    : enum_formatter<::bluetooth::audio::a2dp::Status> {};
}  // namespace std
+2 −2
Original line number Diff line number Diff line
@@ -278,12 +278,12 @@ void end_session() {

void set_audio_low_latency_mode_allowed(bool /*allowed*/) {}

void ack_stream_started(BluetoothAudioStatus /*ack*/) {
void ack_stream_started(Status /*ack*/) {
  a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE;
  // TODO: Notify server
}

void ack_stream_suspended(BluetoothAudioStatus /*ack*/) {
void ack_stream_suspended(Status /*ack*/) {
  a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE;
  // TODO: Notify server
}
+17 −20
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ namespace a2dp {

namespace {

using ::bluetooth::audio::a2dp::BluetoothAudioStatus;
using ::bluetooth::audio::a2dp::Status;
using ::bluetooth::audio::aidl::a2dp::LatencyMode;

// Provide call-in APIs for the Bluetooth Audio HAL
@@ -64,9 +64,9 @@ class A2dpTransport : public ::bluetooth::audio::aidl::a2dp::IBluetoothTransport
public:
  A2dpTransport(SessionType sessionType);

  BluetoothAudioStatus StartRequest(bool is_low_latency) override;
  Status StartRequest(bool is_low_latency) override;

  BluetoothAudioStatus SuspendRequest() override;
  Status SuspendRequest() override;

  void StopRequest() override;

@@ -95,7 +95,7 @@ private:

}  // namespace

using ::bluetooth::audio::a2dp::BluetoothAudioStatus;
using ::bluetooth::audio::a2dp::Status;
using ::bluetooth::audio::a2dp::StreamCallbacks;

static StreamCallbacks null_stream_callbacks_;
@@ -138,46 +138,44 @@ A2dpTransport::A2dpTransport(SessionType sessionType)
  remote_delay_report_ = 0;
}

BluetoothAudioStatus A2dpTransport::StartRequest(bool is_low_latency) {
Status A2dpTransport::StartRequest(bool is_low_latency) {
  // Check if a previous Start request is ongoing.
  if (a2dp_pending_cmd_ == A2DP_CTRL_CMD_START) {
    log::warn("unable to start stream: already pending");
    return BluetoothAudioStatus::PENDING;
    return Status::PENDING;
  }

  // Check if a different request is ongoing.
  if (a2dp_pending_cmd_ != A2DP_CTRL_CMD_NONE) {
    log::warn("unable to start stream: busy with pending command {}", a2dp_pending_cmd_);
    return BluetoothAudioStatus::FAILURE;
    return Status::FAILURE;
  }

  log::info("");

  auto status = stream_callbacks_->StartStream(is_low_latency);
  a2dp_pending_cmd_ =
          status == BluetoothAudioStatus::PENDING ? A2DP_CTRL_CMD_START : A2DP_CTRL_CMD_NONE;
  a2dp_pending_cmd_ = status == Status::PENDING ? A2DP_CTRL_CMD_START : A2DP_CTRL_CMD_NONE;

  return status;
}

BluetoothAudioStatus A2dpTransport::SuspendRequest() {
Status A2dpTransport::SuspendRequest() {
  // Check if a previous Suspend request is ongoing.
  if (a2dp_pending_cmd_ == A2DP_CTRL_CMD_SUSPEND) {
    log::warn("unable to suspend stream: already pending");
    return BluetoothAudioStatus::PENDING;
    return Status::PENDING;
  }

  // Check if a different request is ongoing.
  if (a2dp_pending_cmd_ != A2DP_CTRL_CMD_NONE) {
    log::warn("unable to suspend stream: busy with pending command {}", a2dp_pending_cmd_);
    return BluetoothAudioStatus::FAILURE;
    return Status::FAILURE;
  }

  log::info("");

  auto status = stream_callbacks_->SuspendStream();
  a2dp_pending_cmd_ =
          status == BluetoothAudioStatus::PENDING ? A2DP_CTRL_CMD_SUSPEND : A2DP_CTRL_CMD_NONE;
  a2dp_pending_cmd_ = status == Status::PENDING ? A2DP_CTRL_CMD_SUSPEND : A2DP_CTRL_CMD_NONE;

  return status;
}
@@ -186,8 +184,7 @@ void A2dpTransport::StopRequest() {
  log::info("");

  auto status = stream_callbacks_->StopStream();
  a2dp_pending_cmd_ =
          status == BluetoothAudioStatus::PENDING ? A2DP_CTRL_CMD_STOP : A2DP_CTRL_CMD_NONE;
  a2dp_pending_cmd_ = status == Status::PENDING ? A2DP_CTRL_CMD_STOP : A2DP_CTRL_CMD_NONE;
}

void A2dpTransport::SetLatencyMode(LatencyMode latency_mode) {
@@ -548,7 +545,7 @@ void end_session() {
          ->ResetPresentationPosition();
}

void ack_stream_started(BluetoothAudioStatus ack) {
void ack_stream_started(Status ack) {
  if (!is_hal_enabled()) {
    log::error("BluetoothAudio HAL is not enabled");
    return;
@@ -562,12 +559,12 @@ void ack_stream_started(BluetoothAudioStatus ack) {
    log::warn("pending={} ignore result={}", pending_cmd, ack);
    return;
  }
  if (ack != BluetoothAudioStatus::PENDING) {
  if (ack != Status::PENDING) {
    a2dp_sink->ResetPendingCmd();
  }
}

void ack_stream_suspended(BluetoothAudioStatus ack) {
void ack_stream_suspended(Status ack) {
  if (!is_hal_enabled()) {
    log::error("BluetoothAudio HAL is not enabled");
    return;
@@ -583,7 +580,7 @@ void ack_stream_suspended(BluetoothAudioStatus ack) {
    log::warn("pending={} ignore result={}", pending_cmd, ack);
    return;
  }
  if (ack != BluetoothAudioStatus::PENDING) {
  if (ack != Status::PENDING) {
    a2dp_sink->ResetPendingCmd();
  }
}
+2 −2
Original line number Diff line number Diff line
@@ -68,8 +68,8 @@ bool setup_codec(A2dpCodecConfig* a2dp_config, uint16_t peer_mtu,
 ***/
void start_session();
void end_session();
void ack_stream_started(::bluetooth::audio::a2dp::BluetoothAudioStatus status);
void ack_stream_suspended(::bluetooth::audio::a2dp::BluetoothAudioStatus status);
void ack_stream_started(::bluetooth::audio::a2dp::Status status);
void ack_stream_suspended(::bluetooth::audio::a2dp::Status status);

/***
 * Read from the FMQ of BluetoothAudio HAL
Loading