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

Commit 38922935 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "LeAudio: Fix passing invalid ccid list" am: d89f5e09 am: b6eacc6a

parents e6ddd99f b6eacc6a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1555,6 +1555,7 @@ bool LeAudioDeviceGroup::ConfigureAses(
            << " configuration: " << audio_set_conf->name;

  active_context_type_ = context_type;
  metadata_context_type_ = metadata_context_type;
  return true;
}

+6 −0
Original line number Diff line number Diff line
@@ -211,6 +211,7 @@ class LeAudioDeviceGroup {
        transport_latency_mtos_us_(0),
        transport_latency_stom_us_(0),
        active_context_type_(types::LeAudioContextType::UNINITIALIZED),
        metadata_context_type_(0),
        pending_update_available_contexts_(std::nullopt),
        target_state_(types::AseState::BTA_LE_AUDIO_ASE_STATE_IDLE),
        current_state_(types::AseState::BTA_LE_AUDIO_ASE_STATE_IDLE),
@@ -321,6 +322,10 @@ class LeAudioDeviceGroup {
    pending_update_available_contexts_ = audio_contexts;
  }

  inline types::AudioContexts GetMetadataContextType(void) const {
    return metadata_context_type_;
  }

  bool IsInTransition(void);
  bool IsReleasing(void);
  void Dump(int fd);
@@ -343,6 +348,7 @@ class LeAudioDeviceGroup {

  /* Mask and table of currently supported contexts */
  types::LeAudioContextType active_context_type_;
  types::AudioContexts metadata_context_type_;
  types::AudioContexts active_contexts_mask_;
  std::optional<types::AudioContexts> pending_update_available_contexts_;
  std::map<types::LeAudioContextType,
+8 −1
Original line number Diff line number Diff line
@@ -144,9 +144,16 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
    }

    auto context_type = group->GetCurrentContextType();
    auto metadata_context_type = group->GetMetadataContextType();

    auto ccid = le_audio::ContentControlIdKeeper::GetInstance()->GetCcid(
        static_cast<uint16_t>(context_type));
    if (!group->Configure(context_type, ccid)) {
    std::vector<uint8_t> ccids;
    if (ccid != -1) {
      ccids.push_back(static_cast<uint8_t>(ccid));
    }

    if (!group->Configure(context_type, metadata_context_type, ccids)) {
      LOG_ERROR(" failed to set ASE configuration");
      return false;
    }
+11 −43
Original line number Diff line number Diff line
@@ -2762,49 +2762,6 @@ TEST_F(StateMachineTest, testAttachDeviceToTheStream) {

  lastDevice->conn_id_ = 3;
  group->UpdateActiveContextsMap();
  auto* stream_conf = &group->stream_conf;

  /* Second device got reconnect. Try to get it to the stream seamlessly
   * Code take from client.cc
   */
  le_audio::types::AudioLocations sink_group_audio_locations = 0;
  uint8_t sink_num_of_active_ases = 0;

  for (auto [cis_handle, audio_location] : stream_conf->sink_streams) {
    sink_group_audio_locations |= audio_location;
    sink_num_of_active_ases++;
  }

  le_audio::types::AudioLocations source_group_audio_locations = 0;
  uint8_t source_num_of_active_ases = 0;

  for (auto [cis_handle, audio_location] : stream_conf->source_streams) {
    source_group_audio_locations |= audio_location;
    source_num_of_active_ases++;
  }

  std::vector<uint8_t> ccid_list;
  for (auto& ent : stream_conf->conf->confs) {
    if (ent.direction == le_audio::types::kLeAudioDirectionSink) {
      /* Sink*/
      if (!lastDevice->ConfigureAses(
              ent, group->GetCurrentContextType(), &sink_num_of_active_ases,
              sink_group_audio_locations, source_group_audio_locations, true, 0,
              ccid_list)) {
        FAIL() << __func__ << " Could not set sink configuration of "
               << stream_conf->conf->name;
      }
    } else {
      /* Source*/
      if (!lastDevice->ConfigureAses(
              ent, group->GetCurrentContextType(), &source_num_of_active_ases,
              sink_group_audio_locations, source_group_audio_locations, true, 0,
              ccid_list)) {
        FAIL() << __func__ << " Could not set source configuration of "
               << stream_conf->conf->name;
      }
    }
  }

  EXPECT_CALL(gatt_queue, WriteCharacteristic(lastDevice->conn_id_,
                                              lastDevice->ctp_hdls_.val_hdl, _,
@@ -2816,6 +2773,17 @@ TEST_F(StateMachineTest, testAttachDeviceToTheStream) {
  // Check if group keeps streaming
  ASSERT_EQ(group->GetState(),
            types::AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING);

  // Verify that the joining device receives the right CCID list
  auto lastMeta = lastDevice->GetFirstActiveAse()->metadata;
  bool parsedOk = false;
  auto ltv = le_audio::types::LeAudioLtvMap::Parse(lastMeta.data(),
                                                   lastMeta.size(), parsedOk);
  ASSERT_TRUE(parsedOk);

  auto ccids = ltv.Find(le_audio::types::kLeAudioMetadataTypeCcidList);
  ASSERT_TRUE(ccids.has_value());
  ASSERT_NE(std::find(ccids->begin(), ccids->end(), media_ccid), ccids->end());
}

}  // namespace internal