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

Commit 622c92b7 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski Committed by Gerrit Code Review
Browse files

Merge changes Ice7bce26,I46be6bc5

* changes:
  LeAudio: Extend the context alignment policy
  LeAudio: Postpone the bidirectional context alignment
parents 606e9ed8 173d931a
Loading
Loading
Loading
Loading
+47 −44
Original line number Original line Diff line number Diff line
@@ -3763,25 +3763,6 @@ class LeAudioClientImpl : public LeAudioClient {
    metadata_context_types_.sink =
    metadata_context_types_.sink =
        ChooseMetadataContextType(metadata_context_types_.sink);
        ChooseMetadataContextType(metadata_context_types_.sink);


    /* Mixed contexts in the voiceback channel scenarios can confuse the remote
     * on how to configure each channel. We should align both direction
     * metadata.
     */
    auto non_mixing_contexts = LeAudioContextType::GAME |
                               LeAudioContextType::LIVE |
                               LeAudioContextType::CONVERSATIONAL |
                               LeAudioContextType::VOICEASSISTANTS;
    if (metadata_context_types_.sink.test_any(non_mixing_contexts)) {
      if (osi_property_get_bool(kAllowMultipleContextsInMetadata, true)) {
        LOG_DEBUG("Aligning remote source metadata to add the sink context");
        metadata_context_types_.source =
            metadata_context_types_.source | metadata_context_types_.sink;
      } else {
        LOG_DEBUG("Replacing remote source metadata to match the sink context");
        metadata_context_types_.source = metadata_context_types_.sink;
      }
    }

    ReconfigureOrUpdateRemoteSink(group);
    ReconfigureOrUpdateRemoteSink(group);
  }
  }


@@ -3815,6 +3796,24 @@ class LeAudioClientImpl : public LeAudioClient {
    /* Start with only this direction context metadata */
    /* Start with only this direction context metadata */
    auto configuration_context_candidates = metadata_context_types_.sink;
    auto configuration_context_candidates = metadata_context_types_.sink;


    /* Mixed contexts in the voiceback channel scenarios can confuse the remote
     * on how to configure each channel. We should align both direction
     * metadata.
     */
    auto bidir_contexts = LeAudioContextType::GAME | LeAudioContextType::LIVE |
                          LeAudioContextType::CONVERSATIONAL |
                          LeAudioContextType::VOICEASSISTANTS;
    if (metadata_context_types_.sink.test_any(bidir_contexts)) {
      if (osi_property_get_bool(kAllowMultipleContextsInMetadata, true)) {
        LOG_DEBUG("Aligning remote source metadata to add the sink context");
        metadata_context_types_.source =
            metadata_context_types_.source | metadata_context_types_.sink;
      } else {
        LOG_DEBUG("Replacing remote source metadata to match the sink context");
        metadata_context_types_.source = metadata_context_types_.sink;
      }
    }

    /* If the local sink is started, ready to start or any direction is
    /* If the local sink is started, ready to start or any direction is
     * reconfiguring when the remote sink configuration is active, then take
     * reconfiguring when the remote sink configuration is active, then take
     * into the account current context type for this direction when
     * into the account current context type for this direction when
@@ -3831,13 +3830,18 @@ class LeAudioClientImpl : public LeAudioClient {
        (audio_receiver_state_ == AudioState::READY_TO_START)) {
        (audio_receiver_state_ == AudioState::READY_TO_START)) {
      LOG_DEBUG("Other direction is streaming. Taking its contexts %s",
      LOG_DEBUG("Other direction is streaming. Taking its contexts %s",
                ToString(metadata_context_types_.source).c_str());
                ToString(metadata_context_types_.source).c_str());

      // If current direction has no valid context or we are in the
      // If current direction has no valid context take the other direction
      // bidirectional scenario, take the other direction context
      // context
      if ((metadata_context_types_.sink.none() &&
      if (metadata_context_types_.sink.none()) {
           metadata_context_types_.source.any()) ||
        if (metadata_context_types_.source.any()) {
          metadata_context_types_.source.test_any(bidir_contexts)) {
        if (osi_property_get_bool(kAllowMultipleContextsInMetadata, true)) {
          LOG_DEBUG("Aligning remote sink metadata to add the source context");
          metadata_context_types_.sink =
              metadata_context_types_.sink | metadata_context_types_.source;
        } else {
          LOG_DEBUG(
          LOG_DEBUG(
              "Aligning remote sink metadata to match the source context");
              "Replacing remote sink metadata to match the source context");
          metadata_context_types_.sink = metadata_context_types_.source;
          metadata_context_types_.sink = metadata_context_types_.source;
        }
        }
      }
      }
@@ -4009,25 +4013,6 @@ class LeAudioClientImpl : public LeAudioClient {
    metadata_context_types_.source =
    metadata_context_types_.source =
        ChooseMetadataContextType(metadata_context_types_.source);
        ChooseMetadataContextType(metadata_context_types_.source);


    /* Mixed contexts in the voiceback channel scenarios can confuse the remote
     * on how to configure each channel. We should align both direction
     * metadata.
     */
    auto non_mixing_contexts = LeAudioContextType::GAME |
                               LeAudioContextType::LIVE |
                               LeAudioContextType::CONVERSATIONAL |
                               LeAudioContextType::VOICEASSISTANTS;
    if (metadata_context_types_.source.test_any(non_mixing_contexts)) {
      if (osi_property_get_bool(kAllowMultipleContextsInMetadata, true)) {
        LOG_DEBUG("Aligning remote sink metadata to add the source context");
        metadata_context_types_.sink =
            metadata_context_types_.sink | metadata_context_types_.source;
      } else {
        LOG_DEBUG("Replacing remote sink metadata to match the source context");
        metadata_context_types_.sink = metadata_context_types_.source;
      }
    }

    /* Reconfigure or update only if the stream is already started
    /* Reconfigure or update only if the stream is already started
     * otherwise wait for the local sink to resume.
     * otherwise wait for the local sink to resume.
     */
     */
@@ -4064,6 +4049,24 @@ class LeAudioClientImpl : public LeAudioClient {
    /* Start with only this direction context metadata */
    /* Start with only this direction context metadata */
    auto configuration_context_candidates = metadata_context_types_.source;
    auto configuration_context_candidates = metadata_context_types_.source;


    /* Mixed contexts in the voiceback channel scenarios can confuse the remote
     * on how to configure each channel. We should align both direction
     * metadata.
     */
    auto bidir_contexts = LeAudioContextType::GAME | LeAudioContextType::LIVE |
                          LeAudioContextType::CONVERSATIONAL |
                          LeAudioContextType::VOICEASSISTANTS;
    if (metadata_context_types_.source.test_any(bidir_contexts)) {
      if (osi_property_get_bool(kAllowMultipleContextsInMetadata, true)) {
        LOG_DEBUG("Aligning remote sink metadata to add the source context");
        metadata_context_types_.sink =
            metadata_context_types_.sink | metadata_context_types_.source;
      } else {
        LOG_DEBUG("Replacing remote sink metadata to match the source context");
        metadata_context_types_.sink = metadata_context_types_.source;
      }
    }

    /* If the local source is started, ready to start or any direction is
    /* If the local source is started, ready to start or any direction is
     * reconfiguring when the remote sink configuration is active, then take
     * reconfiguring when the remote sink configuration is active, then take
     * into the account current context type for this direction when
     * into the account current context type for this direction when