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

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

Merge "Replace CodecType bitmask with set"

parents 61713020 03c7b6a8
Loading
Loading
Loading
Loading
+11 −9
Original line number Original line Diff line number Diff line
@@ -18,6 +18,8 @@


#include "codec_status.h"
#include "codec_status.h"


#include <unordered_set>

#include "a2dp_aac_constants.h"
#include "a2dp_aac_constants.h"
#include "a2dp_sbc_constants.h"
#include "a2dp_sbc_constants.h"
#include "a2dp_vendor_aptx_constants.h"
#include "a2dp_vendor_aptx_constants.h"
@@ -456,23 +458,23 @@ bool UpdateOffloadingCapabilities(
  audio_hal_capabilities =
  audio_hal_capabilities =
      BluetoothAudioSinkClientInterface::GetAudioCapabilities(
      BluetoothAudioSinkClientInterface::GetAudioCapabilities(
          SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH);
          SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH);
  uint32_t codec_type_masks = static_cast<uint32_t>(CodecType::UNKNOWN);
  std::unordered_set<CodecType> codec_type_set;
  for (auto preference : framework_preference) {
  for (auto preference : framework_preference) {
    switch (preference.codec_type) {
    switch (preference.codec_type) {
      case BTAV_A2DP_CODEC_INDEX_SOURCE_SBC:
      case BTAV_A2DP_CODEC_INDEX_SOURCE_SBC:
        codec_type_masks |= static_cast<uint32_t>(CodecType::SBC);
        codec_type_set.insert(CodecType::SBC);
        break;
        break;
      case BTAV_A2DP_CODEC_INDEX_SOURCE_AAC:
      case BTAV_A2DP_CODEC_INDEX_SOURCE_AAC:
        codec_type_masks |= static_cast<uint32_t>(CodecType::AAC);
        codec_type_set.insert(CodecType::AAC);
        break;
        break;
      case BTAV_A2DP_CODEC_INDEX_SOURCE_APTX:
      case BTAV_A2DP_CODEC_INDEX_SOURCE_APTX:
        codec_type_masks |= static_cast<uint32_t>(CodecType::APTX);
        codec_type_set.insert(CodecType::APTX);
        break;
        break;
      case BTAV_A2DP_CODEC_INDEX_SOURCE_APTX_HD:
      case BTAV_A2DP_CODEC_INDEX_SOURCE_APTX_HD:
        codec_type_masks |= static_cast<uint32_t>(CodecType::APTX_HD);
        codec_type_set.insert(CodecType::APTX_HD);
        break;
        break;
      case BTAV_A2DP_CODEC_INDEX_SOURCE_LDAC:
      case BTAV_A2DP_CODEC_INDEX_SOURCE_LDAC:
        codec_type_masks |= static_cast<uint32_t>(CodecType::LDAC);
        codec_type_set.insert(CodecType::LDAC);
        break;
        break;
      case BTAV_A2DP_CODEC_INDEX_SINK_SBC:
      case BTAV_A2DP_CODEC_INDEX_SINK_SBC:
        [[fallthrough]];
        [[fallthrough]];
@@ -492,9 +494,9 @@ bool UpdateOffloadingCapabilities(
  }
  }
  offloading_preference.clear();
  offloading_preference.clear();
  for (auto capability : audio_hal_capabilities) {
  for (auto capability : audio_hal_capabilities) {
    if ((static_cast<uint32_t>(
    auto codec_type =
             capability.get<AudioCapabilities::a2dpCapabilities>().codecType) &
        capability.get<AudioCapabilities::a2dpCapabilities>().codecType;
         codec_type_masks) != 0) {
    if (codec_type_set.find(codec_type) != codec_type_set.end()) {
      LOG(INFO) << __func__
      LOG(INFO) << __func__
                << ": enabled offloading capability=" << capability.toString();
                << ": enabled offloading capability=" << capability.toString();
      offloading_preference.push_back(capability);
      offloading_preference.push_back(capability);