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

Commit 850f3d9f authored by Himanshu Rawat's avatar Himanshu Rawat
Browse files

Reconfigure if DSA mode is requested during media streaming

Reconfigure the stream if DSA mode is requested but is not active during
media streaming session.

Test: mmm packages/modules/Bluetooth
Test: Manual | LE audio streaming with device supporting DSA
Bug: 324953838
Bug: 309665975
Change-Id: I8fc46d996779ce3751c8da5cdd566207148a2555
parent ee587cf3
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
@@ -3907,6 +3907,10 @@ class LeAudioClientImpl : public LeAudioClient {
      sink_cfg_available = false;
    }

    if (DsaReconfigureNeeded(group, context_type)) {
      reconfiguration_needed = true;
    }

    LOG_DEBUG(
        " Context: %s Reconfiguration_needed = %d, sink_cfg_available = %d, "
        "source_cfg_available = %d",
@@ -5063,11 +5067,36 @@ class LeAudioClientImpl : public LeAudioClient {
                                       remote_metadata);
  }

  bool DsaReconfigureNeeded(LeAudioDeviceGroup* group,
                            LeAudioContextType context) {
    if (!IS_FLAG_ENABLED(leaudio_dynamic_spatial_audio)) {
      return false;
    }

    // Reconfigure if DSA mode changed for media streaming
    if (context != le_audio::types::LeAudioContextType::MEDIA) {
      return false;
    }

    if (group->dsa_.mode != DsaMode::ISO_SW &&
        group->dsa_.mode != DsaMode::ISO_HW) {
      return false;
    }

    if (group->dsa_.active) {
      return false;
    }

    LOG_INFO("DSA mode %d requested but not active", group->dsa_.mode);
    return true;
  }

  /* Return true if stream is started */
  bool ReconfigureOrUpdateMetadata(
      LeAudioDeviceGroup* group, LeAudioContextType new_configuration_context,
      BidirectionalPair<AudioContexts> remote_contexts) {
    if (new_configuration_context != configuration_context_type_) {
    if (new_configuration_context != configuration_context_type_ ||
        DsaReconfigureNeeded(group, new_configuration_context)) {
      LOG_INFO("Checking whether to change configuration context from %s to %s",
               ToString(configuration_context_type_).c_str(),
               ToString(new_configuration_context).c_str());