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

Commit b4db205c authored by Henri Chataing's avatar Henri Chataing Committed by Gerrit Code Review
Browse files

Merge "audio_hal_interfacce/a2dp_encoding: Rename BluetoothAudioPort -> StreamCallbacks" into main

parents 68f3daec f5f3062f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -54,11 +54,11 @@ bool is_hal_offloading() {

// Initialize BluetoothAudio HAL: openProvider
bool init(bluetooth::common::MessageLoopThread* message_loop,
          bluetooth::audio::a2dp::BluetoothAudioPort const* audio_port, bool offload_enabled) {
          bluetooth::audio::a2dp::StreamCallbacks const* stream_callbacks, bool offload_enabled) {
  if (HalVersionManager::GetHalTransport() == BluetoothAudioHalTransport::HIDL) {
    return hidl::a2dp::init(message_loop, audio_port, offload_enabled);
    return hidl::a2dp::init(message_loop, stream_callbacks, offload_enabled);
  }
  return aidl::a2dp::init(message_loop, audio_port, offload_enabled);
  return aidl::a2dp::init(message_loop, stream_callbacks, offload_enabled);
}

// Clean up BluetoothAudio HAL
+4 −4
Original line number Diff line number Diff line
@@ -48,9 +48,9 @@ enum class BluetoothAudioStatus {
/// by the methods ack_stream_started, ack_stream_suspended.
///
/// The callbacks are always invoked from one of the binder threads.
class BluetoothAudioPort {
class StreamCallbacks {
public:
  virtual ~BluetoothAudioPort() {}
  virtual ~StreamCallbacks() {}
  virtual BluetoothAudioStatus StartStream(bool /*low_latency*/) const {
    return BluetoothAudioStatus::FAILURE;
  }
@@ -72,8 +72,8 @@ bool is_hal_enabled();
bool is_hal_offloading();

// Initialize BluetoothAudio HAL: openProvider
bool init(bluetooth::common::MessageLoopThread* message_loop, BluetoothAudioPort const* audio_port,
          bool offload_enabled);
bool init(bluetooth::common::MessageLoopThread* message_loop,
          StreamCallbacks const* strean_callbacks, bool offload_enabled);

// Clean up BluetoothAudio HAL
void cleanup();
+5 −5
Original line number Diff line number Diff line
@@ -226,12 +226,12 @@ bool is_hal_enabled() { return true; }
// Check if new bluetooth_audio is running with offloading encoders
bool is_hal_offloading() { return false; }

static BluetoothAudioPort null_audio_port;
static BluetoothAudioPort const* bluetooth_audio_port = &null_audio_port;
static StreamCallbacks null_stream_callbacks_;
static StreamCallbacks const* stream_callbacks_ = &null_stream_callbacks_;

// Initialize BluetoothAudio HAL: openProvider
bool init(bluetooth::common::MessageLoopThread* /*message_loop*/,
          BluetoothAudioPort const* audio_port, bool /*offload_enabled*/) {
          StreamCallbacks const* strean_callbacks, bool /*offload_enabled*/) {
  if (a2dp_uipc != nullptr) {
    log::warn("Re-init-ing UIPC that is already running");
    cleanup();
@@ -240,7 +240,7 @@ bool init(bluetooth::common::MessageLoopThread* /*message_loop*/,
  total_bytes_read_ = 0;
  data_position_ = {};
  remote_delay_report_ = 0;
  bluetooth_audio_port = audio_port;
  stream_callbacks_ = strean_callbacks;

  return true;
}
@@ -248,7 +248,7 @@ bool init(bluetooth::common::MessageLoopThread* /*message_loop*/,
// Clean up BluetoothAudio HAL
void cleanup() {
  end_session();
  bluetooth_audio_port = &null_audio_port;
  stream_callbacks_ = &null_stream_callbacks_;

  if (a2dp_uipc != nullptr) {
    UIPC_Close(*a2dp_uipc, UIPC_CH_ID_ALL);
+11 −11
Original line number Diff line number Diff line
@@ -95,11 +95,11 @@ private:

}  // namespace

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

static BluetoothAudioPort null_audio_port;
static BluetoothAudioPort const* bluetooth_audio_port_ = &null_audio_port;
static StreamCallbacks null_stream_callbacks_;
static StreamCallbacks const* stream_callbacks_ = &null_stream_callbacks_;

namespace {

@@ -153,7 +153,7 @@ BluetoothAudioStatus A2dpTransport::StartRequest(bool is_low_latency) {

  log::info("");

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

@@ -175,7 +175,7 @@ BluetoothAudioStatus A2dpTransport::SuspendRequest() {

  log::info("");

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

@@ -185,13 +185,13 @@ BluetoothAudioStatus A2dpTransport::SuspendRequest() {
void A2dpTransport::StopRequest() {
  log::info("");

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

void A2dpTransport::SetLatencyMode(LatencyMode latency_mode) {
  bluetooth_audio_port_->SetLatencyMode(latency_mode == LatencyMode::LOW_LATENCY);
  stream_callbacks_->SetLatencyMode(latency_mode == LatencyMode::LOW_LATENCY);
}

bool A2dpTransport::GetPresentationPosition(uint64_t* remote_delay_report_ns,
@@ -369,9 +369,9 @@ static void delete_hal_interface(BluetoothAudioClientInterface* hal_interface) {

// Initialize BluetoothAudio HAL: openProvider
bool init(bluetooth::common::MessageLoopThread* /*message_loop*/,
          BluetoothAudioPort const* audio_port, bool offload_enabled) {
          StreamCallbacks const* stream_callbacks, bool offload_enabled) {
  log::info("");
  log::assert_that(audio_port != nullptr, "audio_port != nullptr");
  log::assert_that(stream_callbacks != nullptr, "stream_callbacks != nullptr");

  if (software_hal_interface != nullptr) {
    return true;
@@ -397,7 +397,7 @@ bool init(bluetooth::common::MessageLoopThread* /*message_loop*/,
    }
  }

  bluetooth_audio_port_ = audio_port;
  stream_callbacks_ = stream_callbacks;
  active_hal_interface =
          (offloading_hal_interface != nullptr ? offloading_hal_interface : software_hal_interface);

@@ -433,7 +433,7 @@ void cleanup() {
    delete a2dp_sink;
  }

  bluetooth_audio_port_ = &null_audio_port;
  stream_callbacks_ = &null_stream_callbacks_;
  remote_delay = 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ bool is_hal_offloading();
 * Initialize BluetoothAudio HAL: openProvider
 ***/
bool init(bluetooth::common::MessageLoopThread* message_loop,
          bluetooth::audio::a2dp::BluetoothAudioPort const* audio_port, bool offload_enabled);
          bluetooth::audio::a2dp::StreamCallbacks const* stream_callbacks, bool offload_enabled);

/***
 * Clean up BluetoothAudio HAL
Loading