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

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

Merge "LeAudio: Fix running configuration matcher on nullptr" into main

parents bbd13a86 9e42a0e9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -229,6 +229,7 @@ struct codec_manager_impl {
      const CodecManager::UnicastConfigurationRequirements& requirements,
      CodecManager::UnicastConfigurationVerifier verifier) {
    auto configs = GetSupportedCodecConfigurations(requirements);
    if (configs == nullptr) 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
+9 −2
Original line number Diff line number Diff line
@@ -389,10 +389,15 @@ TEST_F(CodecManagerTestAdsp, test_capabilities_none) {
      offloading_preference(0);
  codec_manager->Start(offloading_preference);

  bool has_null_config = false;
  auto match_first_config =
      [](const CodecManager::UnicastConfigurationRequirements& requirements,
      [&](const CodecManager::UnicastConfigurationRequirements& requirements,
          const set_configurations::AudioSetConfigurations* confs)
      -> const set_configurations::AudioSetConfiguration* {
    // Don't expect the matcher being called on nullptr
    if (confs == nullptr) {
      has_null_config = true;
    }
    if (confs && confs->size()) {
      // For simplicity return the first element, the real matcher should
      // check the group capabilities.
@@ -404,11 +409,13 @@ TEST_F(CodecManagerTestAdsp, test_capabilities_none) {
  // Verify every context
  for (::bluetooth::le_audio::types::LeAudioContextType ctx_type :
       ::bluetooth::le_audio::types::kLeAudioContextAllTypesArray) {
    has_null_config = false;
    CodecManager::UnicastConfigurationRequirements requirements = {
        .audio_context_type = ctx_type,
    };
    ASSERT_EQ(nullptr,
              codec_manager->GetCodecConfig(requirements, match_first_config));
    ASSERT_FALSE(has_null_config);
  }
}