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

Commit 103cb2ad authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

LeAudio: Fix timing issue on state machine reconfigure

There was a chance that during the consecutive reconfigurations,
state machine receives the previous configuration notification from
the ASE and considered it as part of current reconfiguration process.
It would skipp this ASE configuration which resulted in a mixed,
half-previous, half-new configuration (often asymmetric) that was a
problem to some devices.

Bug: 261417889
Bug: 229041682
Tag: #feature
Test: atest --host bluetooth_le_audio_test bluetooth_le_audio_client_test --no-bazel-mode & tested manually
Change-Id: I43b6377ef9c1403b0a52dcd2a0a583caf6249b74
Merged-In: I43b6377ef9c1403b0a52dcd2a0a583caf6249b74
(cherry picked from commit 35ec2e21)
parent a279ce41
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -1469,8 +1469,18 @@ bool LeAudioDevice::ConfigureAses(
    types::AudioLocations& group_src_audio_locations, bool reuse_cis_id,
    AudioContexts metadata_context_type,
    const std::vector<uint8_t>& ccid_list) {
  struct ase* ase = GetFirstInactiveAse(ent.direction, reuse_cis_id);
  if (!ase) return false;
  /* First try to use the already configured ASE */
  auto ase = GetFirstActiveAseByDirection(ent.direction);
  if (ase) {
    LOG_INFO("Using an already active ASE id=%d", ase->id);
  } else {
    ase = GetFirstInactiveAse(ent.direction, reuse_cis_id);
  }

  if (!ase) {
    LOG_ERROR("Unable to find an ASE to configure");
    return false;
  }

  uint8_t active_ases = *number_of_already_active_group_ase;
  uint8_t max_required_ase_per_dev =
@@ -1542,8 +1552,12 @@ bool LeAudioDevice::ConfigureAses(
               << ", cis_id=" << +ase->cis_id
               << ", target_latency=" << +ent.target_latency;

    /* Try to use the already active ASE */
    ase = GetNextActiveAseWithSameDirection(ase);
    if (ase == nullptr) {
      ase = GetFirstInactiveAse(ent.direction, reuse_cis_id);
    }
  }

  *number_of_already_active_group_ase = active_ases;
  return true;
@@ -1593,12 +1607,6 @@ bool LeAudioDeviceGroup::ConfigureAses(
    for (auto* device = GetFirstDeviceWithActiveContext(context_type);
         device != nullptr && required_device_cnt > 0;
         device = GetNextDeviceWithActiveContext(device, context_type)) {
      /* Skip if device has ASE configured in this direction already */
      if (device->GetFirstActiveAseByDirection(ent.direction)) {
        required_device_cnt--;
        continue;
      }

      /* For the moment, we configure only connected devices and when it is
       * ready to stream i.e. All ASEs are discovered and device is reported as
       * connected