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

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

Merge "LE audio hardware offload session switch for encode direction"

parents 438f4877 422f55d1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1005,6 +1005,10 @@ int BluetoothAudioClientInterface::EndSession() {
}

void BluetoothAudioClientInterface::FlushAudioData() {
  if (transport_->GetSessionType_2_1() ==
      SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH)
    return;

  if (mDataMQ == nullptr || !mDataMQ->isValid()) {
    LOG(WARNING) << __func__ << ", mDataMQ invalid";
    return;
+22 −6
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <unordered_map>
#include <vector>

#include "bta/le_audio/codec_manager.h"
#include "client_interface.h"
#include "codec_status.h"
#include "hal_version_manager.h"
@@ -37,6 +38,7 @@ using ::android::hardware::bluetooth::audio::V2_1::Lc3FrameDuration;
using ::android::hardware::bluetooth::audio::V2_1::Lc3Parameters;
using ::android::hardware::bluetooth::audio::V2_1::PcmParameters;
using ::android::hardware::bluetooth::audio::V2_2::AudioLocation;
using ::android::hardware::bluetooth::audio::V2_2::LeAudioConfiguration;
using ::bluetooth::audio::AudioConfiguration_2_2;
using ::bluetooth::audio::BluetoothAudioCtrlAck;
using ::bluetooth::audio::SampleRate_2_1;
@@ -48,9 +50,11 @@ using AudioCapabilities_2_2 =
    ::android::hardware::bluetooth::audio::V2_2::AudioCapabilities;
using android::hardware::bluetooth::audio::V2_2::LeAudioCodecCapability;

using ::le_audio::CodecManager;
using ::le_audio::set_configurations::AudioSetConfiguration;
using ::le_audio::set_configurations::CodecCapabilitySetting;
using ::le_audio::set_configurations::SetConfiguration;
using ::le_audio::types::CodecLocation;
using ::le_audio::types::LeAudioLc3Config;

bluetooth::audio::BluetoothAudioSinkClientInterface*
@@ -200,9 +204,8 @@ static void flush_sink() {
class LeAudioSinkTransport
    : public bluetooth::audio::IBluetoothSinkTransportInstance {
 public:
  LeAudioSinkTransport(StreamCallbacks stream_cb)
      : IBluetoothSinkTransportInstance(
            SessionType_2_1::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH,
  LeAudioSinkTransport(SessionType_2_1 session_type, StreamCallbacks stream_cb)
      : IBluetoothSinkTransportInstance(session_type,
                                        (AudioConfiguration_2_2){}) {
    transport_ =
        new LeAudioTransport(flush_sink, std::move(stream_cb),
@@ -587,7 +590,14 @@ void LeAudioClientInterface::Sink::StartSession() {
    return;
  }
  AudioConfiguration_2_2 audio_config;
  if (le_audio_sink_hal_clientinterface->GetTransportInstance()
          ->GetSessionType_2_1() ==
      SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
    LeAudioConfiguration le_audio_config = {};
    audio_config.leAudioConfig(le_audio_config);
  } else {
    audio_config.pcmConfig(le_audio_sink->LeAudioGetSelectedHalPcmConfig());
  }
  if (!le_audio_sink_hal_clientinterface->UpdateAudioConfig_2_2(audio_config)) {
    LOG(ERROR) << __func__ << ": cannot update audio config to HAL";
    return;
@@ -726,7 +736,13 @@ LeAudioClientInterface::Sink* LeAudioClientInterface::GetSink(

  LOG(INFO) << __func__;

  le_audio_sink = new LeAudioSinkTransport(std::move(stream_cb));
  SessionType_2_1 session_type =
      SessionType_2_1::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH;
  if (CodecManager::GetInstance()->GetCodecLocation() != CodecLocation::HOST) {
    session_type = SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH;
  }

  le_audio_sink = new LeAudioSinkTransport(session_type, std::move(stream_cb));
  le_audio_sink_hal_clientinterface =
      new bluetooth::audio::BluetoothAudioSinkClientInterface(le_audio_sink,
                                                              message_loop);
+5 −1
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ cc_library_static {
        "vc/device.cc",
        "vc/vc.cc",
        "le_audio/client.cc",
        "le_audio/codec_manager.cc",
        "le_audio/devices.cc",
        "le_audio/hal_verifier.cc",
        "le_audio/state_machine.cc",
@@ -435,6 +436,7 @@ cc_test {
    ],
    srcs : [
        ":TestStubOsi",
        ":TestMockBtaLeAudioHalVerifier",
        "test/common/bta_gatt_api_mock.cc",
        "test/common/bta_gatt_queue_mock.cc",
        "test/common/btm_api_mock.cc",
@@ -449,7 +451,8 @@ cc_test {
        "le_audio/mock_iso_manager.cc",
        "test/common/mock_controller.cc",
        "le_audio/state_machine.cc",
        "le_audio/state_machine_test.cc"
        "le_audio/state_machine_test.cc",
        "le_audio/mock_codec_manager.cc",
    ],
    shared_libs: [
        "libprotobuf-cpp-lite",
@@ -500,6 +503,7 @@ cc_test {
        "test/common/mock_csis_client.cc",
        "test/common/mock_controller.cc",
        "test/common/mock_device_groups.cc",
        "le_audio/mock_codec_manager.cc",
    ],
    shared_libs: [
        "android.hardware.bluetooth.audio@2.0",
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
class LeAudioHalVerifier {
 public:
  static bool SupportsLeAudio();
  static bool SupportsLeAudioHardwareOffload();
};

/* Interface class */
+4 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include "btm_iso_api.h"
#include "client_audio.h"
#include "client_parser.h"
#include "codec_manager.h"
#include "common/time_util.h"
#include "device/include/controller.h"
#include "devices.h"
@@ -56,6 +57,7 @@ using bluetooth::le_audio::ConnectionState;
using bluetooth::le_audio::GroupNodeStatus;
using bluetooth::le_audio::GroupStatus;
using bluetooth::le_audio::GroupStreamStatus;
using le_audio::CodecManager;
using le_audio::LeAudioDevice;
using le_audio::LeAudioDeviceGroup;
using le_audio::LeAudioDeviceGroups;
@@ -3303,6 +3305,7 @@ void LeAudioClient::Initialize(
  instance = new LeAudioClientImpl(callbacks_, stateMachineCallbacks, initCb);

  IsoManager::GetInstance()->RegisterCigCallbacks(stateMachineHciCallbacks);
  CodecManager::GetInstance()->Start();
}

void LeAudioClient::DebugDump(int fd) {
@@ -3330,6 +3333,7 @@ void LeAudioClient::Cleanup(void) {
  ptr->Cleanup();
  delete ptr;

  CodecManager::GetInstance()->Stop();
  LeAudioGroupStateMachine::Cleanup();
  IsoManager::GetInstance()->Stop();
}
Loading