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

Commit 51c3237f authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

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

parents e99aa764 dc3fbdce
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line 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) {
  if (HalVersionManager::GetHalTransport() == BluetoothAudioHalTransport::HIDL) {
    hidl::a2dp::ack_stream_started(status);
    hidl::a2dp::ack_stream_started(status);
    return;
    return;
@@ -107,7 +107,7 @@ void ack_stream_started(BluetoothAudioStatus status) {
  return aidl::a2dp::ack_stream_started(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) {
  if (HalVersionManager::GetHalTransport() == BluetoothAudioHalTransport::HIDL) {
    hidl::a2dp::ack_stream_suspended(status);
    hidl::a2dp::ack_stream_suspended(status);
    return;
    return;
+9 −13
Original line number Original line Diff line number Diff line
@@ -32,7 +32,7 @@ namespace a2dp {


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


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


// Read from the FMQ of BluetoothAudio HAL
// Read from the FMQ of BluetoothAudio HAL
size_t read(uint8_t* p_buf, uint32_t len);
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 {
namespace std {
template <>
template <>
struct formatter<::bluetooth::audio::a2dp::BluetoothAudioStatus>
struct formatter<::bluetooth::audio::a2dp::Status>
    : enum_formatter<::bluetooth::audio::a2dp::BluetoothAudioStatus> {};
    : enum_formatter<::bluetooth::audio::a2dp::Status> {};
}  // namespace std
}  // namespace std
+2 −2
Original line number Original line Diff line number Diff line
@@ -278,12 +278,12 @@ void end_session() {


void set_audio_low_latency_mode_allowed(bool /*allowed*/) {}
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;
  a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE;
  // TODO: Notify server
  // TODO: Notify server
}
}


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


namespace {
namespace {


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


// Provide call-in APIs for the Bluetooth Audio HAL
// Provide call-in APIs for the Bluetooth Audio HAL
@@ -64,9 +64,9 @@ class A2dpTransport : public ::bluetooth::audio::aidl::a2dp::IBluetoothTransport
public:
public:
  A2dpTransport(SessionType sessionType);
  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;
  void StopRequest() override;


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


}  // namespace
}  // namespace


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


static StreamCallbacks null_stream_callbacks_;
static StreamCallbacks null_stream_callbacks_;
@@ -138,46 +138,44 @@ A2dpTransport::A2dpTransport(SessionType sessionType)
  remote_delay_report_ = 0;
  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.
  // Check if a previous Start request is ongoing.
  if (a2dp_pending_cmd_ == A2DP_CTRL_CMD_START) {
  if (a2dp_pending_cmd_ == A2DP_CTRL_CMD_START) {
    log::warn("unable to start stream: already pending");
    log::warn("unable to start stream: already pending");
    return BluetoothAudioStatus::PENDING;
    return Status::PENDING;
  }
  }


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


  log::info("");
  log::info("");


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


  return status;
  return status;
}
}


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


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


  log::info("");
  log::info("");


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


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


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


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


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


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


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