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

Commit 7f6436d2 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Automerger Merge Worker
Browse files

bluetooth.audio@2.1: add internal HW offloading data path routing am:...

bluetooth.audio@2.1: add internal HW offloading data path routing am: c8861ece am: 560e842d am: c19e62bf

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1724672

Change-Id: Iadd71bb0f0a907d50b0a9af8bf504da3e2d631a1
parents 85d75262 c19e62bf
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ cc_library_shared {
        "A2dpSoftwareAudioProvider.cpp",
        "A2dpSoftwareAudioProvider.cpp",
        "HearingAidAudioProvider.cpp",
        "HearingAidAudioProvider.cpp",
        "LeAudioAudioProvider.cpp",
        "LeAudioAudioProvider.cpp",
        "LeAudioOffloadAudioProvider.cpp",
    ],
    ],
    header_libs: ["libhardware_headers"],
    header_libs: ["libhardware_headers"],
    shared_libs: [
    shared_libs: [
+10 −0
Original line number Original line Diff line number Diff line
@@ -41,8 +41,12 @@ HearingAidAudioProvider
    BluetoothAudioProvidersFactory::hearing_aid_provider_instance_;
    BluetoothAudioProvidersFactory::hearing_aid_provider_instance_;
LeAudioOutputAudioProvider
LeAudioOutputAudioProvider
    BluetoothAudioProvidersFactory::leaudio_output_provider_instance_;
    BluetoothAudioProvidersFactory::leaudio_output_provider_instance_;
LeAudioOffloadOutputAudioProvider
    BluetoothAudioProvidersFactory::leaudio_offload_output_provider_instance_;
LeAudioInputAudioProvider
LeAudioInputAudioProvider
    BluetoothAudioProvidersFactory::leaudio_input_provider_instance_;
    BluetoothAudioProvidersFactory::leaudio_input_provider_instance_;
LeAudioOffloadInputAudioProvider
    BluetoothAudioProvidersFactory::leaudio_offload_input_provider_instance_;


Return<void> BluetoothAudioProvidersFactory::openProvider(
Return<void> BluetoothAudioProvidersFactory::openProvider(
    const V2_0::SessionType sessionType, openProvider_cb _hidl_cb) {
    const V2_0::SessionType sessionType, openProvider_cb _hidl_cb) {
@@ -90,9 +94,15 @@ Return<void> BluetoothAudioProvidersFactory::openProvider_2_1(
    case SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH:
    case SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH:
      provider = &leaudio_output_provider_instance_;
      provider = &leaudio_output_provider_instance_;
      break;
      break;
    case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH:
      provider = &leaudio_offload_output_provider_instance_;
      break;
    case SessionType::LE_AUDIO_SOFTWARE_DECODED_DATAPATH:
    case SessionType::LE_AUDIO_SOFTWARE_DECODED_DATAPATH:
      provider = &leaudio_input_provider_instance_;
      provider = &leaudio_input_provider_instance_;
      break;
      break;
    case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH:
      provider = &leaudio_offload_input_provider_instance_;
      break;
    default:
    default:
      status = BluetoothAudioStatus::FAILURE;
      status = BluetoothAudioStatus::FAILURE;
  }
  }
+3 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@
#include "BluetoothAudioProvider.h"
#include "BluetoothAudioProvider.h"
#include "HearingAidAudioProvider.h"
#include "HearingAidAudioProvider.h"
#include "LeAudioAudioProvider.h"
#include "LeAudioAudioProvider.h"
#include "LeAudioOffloadAudioProvider.h"


namespace android {
namespace android {
namespace hardware {
namespace hardware {
@@ -55,6 +56,8 @@ class BluetoothAudioProvidersFactory : public IBluetoothAudioProvidersFactory {
  static HearingAidAudioProvider hearing_aid_provider_instance_;
  static HearingAidAudioProvider hearing_aid_provider_instance_;
  static LeAudioOutputAudioProvider leaudio_output_provider_instance_;
  static LeAudioOutputAudioProvider leaudio_output_provider_instance_;
  static LeAudioInputAudioProvider leaudio_input_provider_instance_;
  static LeAudioInputAudioProvider leaudio_input_provider_instance_;
  static LeAudioOffloadOutputAudioProvider leaudio_offload_output_provider_instance_;
  static LeAudioOffloadInputAudioProvider leaudio_offload_input_provider_instance_;
};
};


extern "C" IBluetoothAudioProvidersFactory*
extern "C" IBluetoothAudioProvidersFactory*
+108 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "BTAudioProviderLeAudioOffload"

#include "LeAudioOffloadAudioProvider.h"

#include <android-base/logging.h>

#include "BluetoothAudioSessionReport_2_1.h"
#include "BluetoothAudioSupportedCodecsDB_2_1.h"

namespace android {
namespace hardware {
namespace bluetooth {
namespace audio {
namespace V2_1 {
namespace implementation {

using ::android::bluetooth::audio::BluetoothAudioSessionReport_2_1;
using ::android::hardware::Void;
using ::android::hardware::bluetooth::audio::V2_0::BitsPerSample;
using ::android::hardware::bluetooth::audio::V2_0::ChannelMode;
using ::android::hardware::bluetooth::audio::V2_1::SampleRate;

using DataMQ = MessageQueue<uint8_t, kSynchronizedReadWrite>;

LeAudioOffloadOutputAudioProvider::LeAudioOffloadOutputAudioProvider()
    : LeAudioOffloadAudioProvider() {
  session_type_ = SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH;
}

LeAudioOffloadInputAudioProvider::LeAudioOffloadInputAudioProvider()
    : LeAudioOffloadAudioProvider() {
  session_type_ = SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH;
}

LeAudioOffloadAudioProvider::LeAudioOffloadAudioProvider()
    : BluetoothAudioProvider() {}

bool LeAudioOffloadAudioProvider::isValid(const V2_0::SessionType& sessionType) {
  LOG(ERROR) << __func__ << ", invalid session type for Offloaded Le Audio provider: "
             << toString(sessionType);

  return false;
}

bool LeAudioOffloadAudioProvider::isValid(const SessionType& sessionType) {
  return (sessionType == session_type_);
}

Return<void> LeAudioOffloadAudioProvider::startSession_2_1(
    const sp<V2_0::IBluetoothAudioPort>& hostIf,
    const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
  /**
   * Initialize the audio platform if audioConfiguration is supported.
   * Save the IBluetoothAudioPort interface, so that it can be used
   * later to send stream control commands to the HAL client, based on
   * interaction with Audio framework.
   */
  if (audioConfig.getDiscriminator() !=
      AudioConfiguration::hidl_discriminator::leAudioCodecConfig) {
    LOG(WARNING) << __func__
                 << " - Invalid Audio Configuration=" << toString(audioConfig);
    _hidl_cb(BluetoothAudioStatus::UNSUPPORTED_CODEC_CONFIGURATION,
             DataMQ::Descriptor());
    return Void();
  }

  if (!android::bluetooth::audio::IsOffloadLeAudioConfigurationValid(session_type_,
                 audioConfig.leAudioCodecConfig())) {
    LOG(WARNING) << __func__ << " - Unsupported LC3 Offloaded Configuration="
                 << toString(audioConfig.leAudioCodecConfig());
    _hidl_cb(BluetoothAudioStatus::UNSUPPORTED_CODEC_CONFIGURATION,
             DataMQ::Descriptor());
    return Void();
  }

  return BluetoothAudioProvider::startSession_2_1(hostIf, audioConfig,
                                                  _hidl_cb);
}

Return<void> LeAudioOffloadAudioProvider::onSessionReady(startSession_cb _hidl_cb) {
  BluetoothAudioSessionReport_2_1::OnSessionStarted(session_type_, stack_iface_,
                                                    nullptr, audio_config_);
  _hidl_cb(BluetoothAudioStatus::SUCCESS, DataMQ::Descriptor());
  return Void();
}

}  // namespace implementation
}  // namespace V2_1
}  // namespace audio
}  // namespace bluetooth
}  // namespace hardware
}  // namespace android
+60 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <android/hardware/bluetooth/audio/2.1/types.h>

#include "BluetoothAudioProvider.h"

namespace android {
namespace hardware {
namespace bluetooth {
namespace audio {
namespace V2_1 {
namespace implementation {

class LeAudioOffloadAudioProvider : public BluetoothAudioProvider {
 public:
  LeAudioOffloadAudioProvider();

  bool isValid(const SessionType& sessionType) override;
  bool isValid(const V2_0::SessionType& sessionType) override;

  Return<void> startSession_2_1(const sp<V2_0::IBluetoothAudioPort>& hostIf,
                                const AudioConfiguration& audioConfig,
                                startSession_cb _hidl_cb) override;

 private:
  Return<void> onSessionReady(startSession_cb _hidl_cb) override;
};

class LeAudioOffloadOutputAudioProvider : public LeAudioOffloadAudioProvider {
 public:
  LeAudioOffloadOutputAudioProvider();
};

class LeAudioOffloadInputAudioProvider : public LeAudioOffloadAudioProvider {
 public:
  LeAudioOffloadInputAudioProvider();
};

}  // namespace implementation
}  // namespace V2_1
}  // namespace audio
}  // namespace bluetooth
}  // namespace hardware
}  // namespace android
Loading