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

Commit 9bfd8965 authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

LeAudio: Minor logging and comments improvement

Bug: 308428860
Bug: 332476151
Flag: EXEMPT; no functional change - logging function verified by the unit test
Test: atest --host bluetooth_le_audio_codec_manager_test --no-bazel-mode -v ; Verify the output for the log messages.
Change-Id: I628564a4fb82f8a065ab5da868eef1b71b81c005
parent dfd5df58
Loading
Loading
Loading
Loading
+33 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <bluetooth/log.h>

#include <bitset>
#include <sstream>

#include "audio_hal_client/audio_hal_client.h"
#include "broadcaster/broadcast_configuration_provider.h"
@@ -225,11 +226,34 @@ struct codec_manager_impl {
        requirements.audio_context_type);
  }

  void PrintDebugState() const {
    for (types::LeAudioContextType ctx_type :
         types::kLeAudioContextAllTypesArray) {
      std::stringstream os;
      os << ctx_type << ": ";
      if (context_type_offload_config_map_.count(ctx_type) == 0) {
        os << "{empty}";
      } else {
        os << "{";
        for (const auto& conf : context_type_offload_config_map_.at(ctx_type)) {
          os << conf->name << ", ";
        }
        os << "}";
      }
      log::info("Offload configs for {}", os.str());
    }
  }

  std::unique_ptr<AudioSetConfiguration> GetCodecConfig(
      const CodecManager::UnicastConfigurationRequirements& requirements,
      CodecManager::UnicastConfigurationVerifier verifier) {
    auto configs = GetSupportedCodecConfigurations(requirements);
    if (configs == nullptr) return nullptr;
    if (configs == nullptr) {
      log::error("No valid configuration matching the requirements: {}",
                 requirements);
      PrintDebugState();
      return nullptr;
    }
    // Note: For the only supported right now legacy software configuration
    //       provider, we use the device group logic to match the proper
    //       configuration with group capabilities. Note that this path only
@@ -902,7 +926,14 @@ struct codec_manager_impl {
  std::vector<btle_audio_codec_config_t> codec_input_capa = {};
  std::vector<btle_audio_codec_config_t> codec_output_capa = {};
  int broadcast_target_config = -1;
};  // namespace bluetooth::le_audio
};

std::ostream& operator<<(
    std::ostream& os,
    const CodecManager::UnicastConfigurationRequirements& req) {
  os << "{audio context type: " << req.audio_context_type << "}";
  return os;
}

struct CodecManager::impl {
  impl(const CodecManager& codec_manager) : codec_manager_(codec_manager) {}
+19 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#pragma once

#include <bluetooth/log.h>

#include <vector>

#include "broadcaster/broadcaster_types.h"
@@ -62,6 +64,12 @@ class CodecManager {
    ::bluetooth::le_audio::types::LeAudioContextType audio_context_type;
  };

  /* The verifier function checks each possible configuration (from the set of
   * all possible, supported configuration acquired from
   * AudioSetConfigurationProvider for the given scenario), to select a single
   * configuration, matching the current streaming audio group requirements.
   * Note: Used only with the legacy AudioSetConfigurationProvider.
   */
  typedef std::function<const set_configurations::AudioSetConfiguration*(
      const UnicastConfigurationRequirements& requirements,
      const set_configurations::AudioSetConfigurations* confs)>
@@ -119,4 +127,15 @@ class CodecManager {
  struct impl;
  std::unique_ptr<impl> pimpl_;
};

std::ostream& operator<<(
    std::ostream& os,
    const CodecManager::UnicastConfigurationRequirements& req);
}  // namespace bluetooth::le_audio

namespace fmt {
template <>
struct formatter<
    bluetooth::le_audio::CodecManager::UnicastConfigurationRequirements>
    : ostream_formatter {};
}  // namespace fmt
+7 −0
Original line number Diff line number Diff line
@@ -143,6 +143,13 @@ void CodecManager::ClearCisConfiguration(uint8_t direction) {
  if (pimpl_) return pimpl_->ClearCisConfiguration(direction);
}

std::ostream& operator<<(
    std::ostream& os,
    const CodecManager::UnicastConfigurationRequirements& req) {
  os << "{audio context type: " << req.audio_context_type << "}";
  return os;
}

// CodecManager::~CodecManager() = default;

}  // namespace bluetooth::le_audio