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

Commit d681f564 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

leaudio: Don't adjust metadata when choosing configuration

Le audio code maintain configuration_context_type_ and
metadata_context_types_.
The configuration_context_type_ is choosen based on the
metadata_context_types_, which contains a list of all the mixed streams.
This patch fixes that.

Bug: 251803434
Test: atest BluetoothInstrumentationTests
Test manual: Media stream + notification - make sure configuratin is not
changed
Tag: #feature

Merged-In: Icc5b134abe39170882705a0f0bb261eb300eaf76
Change-Id: Icc5b134abe39170882705a0f0bb261eb300eaf76
(cherry picked from commit 87137387)
parent 7ee6f114
Loading
Loading
Loading
Loading
+12 −14
Original line number Original line Diff line number Diff line
@@ -3337,22 +3337,20 @@ class LeAudioClientImpl : public LeAudioClient {
      return LeAudioContextType::UNSPECIFIED;
      return LeAudioContextType::UNSPECIFIED;
    }
    }


    auto adjusted_contexts = adjustMetadataContexts(available_contexts);

    using T = std::underlying_type<LeAudioContextType>::type;
    using T = std::underlying_type<LeAudioContextType>::type;


    /* Mini policy. Voice is prio 1, game prio 2, media is prio 3 */
    /* Mini policy. Voice is prio 1, game prio 2, media is prio 3 */
    if ((adjusted_contexts &
    if ((available_contexts &
         AudioContexts(static_cast<T>(LeAudioContextType::CONVERSATIONAL)))
         AudioContexts(static_cast<T>(LeAudioContextType::CONVERSATIONAL)))
            .any())
            .any())
      return LeAudioContextType::CONVERSATIONAL;
      return LeAudioContextType::CONVERSATIONAL;


    if ((adjusted_contexts &
    if ((available_contexts &
         AudioContexts(static_cast<T>(LeAudioContextType::GAME)))
         AudioContexts(static_cast<T>(LeAudioContextType::GAME)))
            .any())
            .any())
      return LeAudioContextType::GAME;
      return LeAudioContextType::GAME;


    if ((adjusted_contexts &
    if ((available_contexts &
         AudioContexts(static_cast<T>(LeAudioContextType::RINGTONE)))
         AudioContexts(static_cast<T>(LeAudioContextType::RINGTONE)))
            .any()) {
            .any()) {
      if (!in_call_) {
      if (!in_call_) {
@@ -3361,7 +3359,7 @@ class LeAudioClientImpl : public LeAudioClient {
      return LeAudioContextType::RINGTONE;
      return LeAudioContextType::RINGTONE;
    }
    }


    if ((adjusted_contexts &
    if ((available_contexts &
         AudioContexts(static_cast<T>(LeAudioContextType::MEDIA)))
         AudioContexts(static_cast<T>(LeAudioContextType::MEDIA)))
            .any())
            .any())
      return LeAudioContextType::MEDIA;
      return LeAudioContextType::MEDIA;
@@ -3369,8 +3367,8 @@ class LeAudioClientImpl : public LeAudioClient {
    /*TODO do something smarter here */
    /*TODO do something smarter here */
    /* Get context for the first non-zero bit */
    /* Get context for the first non-zero bit */
    uint16_t context_type = 0b1;
    uint16_t context_type = 0b1;
    while (adjusted_contexts != 0b1) {
    while (available_contexts != 0b1) {
      adjusted_contexts = adjusted_contexts >> 1;
      available_contexts = available_contexts >> 1;
      context_type = context_type << 1;
      context_type = context_type << 1;
    }
    }


@@ -3428,7 +3426,7 @@ class LeAudioClientImpl : public LeAudioClient {
        (group->GetTargetState() == AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING);
        (group->GetTargetState() == AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING);


    if (audio_receiver_state_ == AudioState::STARTED) {
    if (audio_receiver_state_ == AudioState::STARTED) {
      /* If the receiver is starte. Take into account current context type */
      /* If the receiver is started. Take into account current context type */
      metadata_context_types_ = adjustMetadataContexts(metadata_context_types_);
      metadata_context_types_ = adjustMetadataContexts(metadata_context_types_);
    } else {
    } else {
      metadata_context_types_ = 0;
      metadata_context_types_ = 0;
@@ -3478,13 +3476,13 @@ class LeAudioClientImpl : public LeAudioClient {


    if (new_configuration_context == configuration_context_type_) {
    if (new_configuration_context == configuration_context_type_) {
      LOG_INFO("Context did not changed.");
      LOG_INFO("Context did not changed.");
      return;
    }


    } else {
      configuration_context_type_ = new_configuration_context;
      configuration_context_type_ = new_configuration_context;
      if (StopStreamIfNeeded(group, new_configuration_context)) {
      if (StopStreamIfNeeded(group, new_configuration_context)) {
        return;
        return;
      }
      }
    }


    if (is_group_streaming) {
    if (is_group_streaming) {
      /* Configuration is the same for new context, just will do update
      /* Configuration is the same for new context, just will do update