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

Commit 90101ec3 authored by Alice Kuo's avatar Alice Kuo
Browse files

Refine the map between audio attribute and LE audio context type

The audio attribute content type is not clear for the usage. So the
patch remove content check as the stream not configured to
conversational, and based on the usage to set the LE audio context type
only. It contains the following setting,
1. Add support navigation audio to Instructional
2. Add support calll assistant to Conversationoal
3. only check the USAGE_MEDIA for Media
4. If the usage is UNKOWN, set it default too Meida

Bug: 228924591
Test: start navigation as music streaming, all the sound could be heard
Change-Id: I84e9bdeb27c18f3f81422726f6a4e47cb7fbd6da
parent e487d777
Loading
Loading
Loading
Loading
+9 −39
Original line number Diff line number Diff line
@@ -2939,44 +2939,13 @@ class LeAudioClientImpl : public LeAudioClient {
  LeAudioContextType AudioContentToLeAudioContext(
      LeAudioContextType current_context_type,
      audio_content_type_t content_type, audio_usage_t usage) {
    /* Let's stay on the Conversational context type in case it is already
     * configured to conversational.
     */
    if (current_context_type == LeAudioContextType::CONVERSATIONAL) {
      switch (content_type) {
        case AUDIO_CONTENT_TYPE_SONIFICATION:
        case AUDIO_CONTENT_TYPE_SPEECH:
          return LeAudioContextType::CONVERSATIONAL;
        default:
          break;
      }

    /* Check audio attribute usage of stream */
    switch (usage) {
        case AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE:
        case AUDIO_USAGE_NOTIFICATION:
        case AUDIO_USAGE_ALARM:
        case AUDIO_USAGE_EMERGENCY:
        case AUDIO_USAGE_VOICE_COMMUNICATION:
          return LeAudioContextType::CONVERSATIONAL;
        default:
          break;
      }
    }

    switch (content_type) {
      case AUDIO_CONTENT_TYPE_SPEECH:
        return LeAudioContextType::CONVERSATIONAL;
      case AUDIO_CONTENT_TYPE_MUSIC:
      case AUDIO_CONTENT_TYPE_MOVIE:
      case AUDIO_CONTENT_TYPE_SONIFICATION:
      case AUDIO_USAGE_MEDIA:
        return LeAudioContextType::MEDIA;
      default:
        break;
    }

    /* Context is not clear, consider also usage of stream */
    switch (usage) {
      case AUDIO_USAGE_VOICE_COMMUNICATION:
      case AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING:
      case AUDIO_USAGE_CALL_ASSISTANT:
        return LeAudioContextType::CONVERSATIONAL;
      case AUDIO_USAGE_GAME:
        return LeAudioContextType::GAME;
@@ -2988,6 +2957,8 @@ class LeAudioClientImpl : public LeAudioClient {
        return LeAudioContextType::ALERTS;
      case AUDIO_USAGE_EMERGENCY:
        return LeAudioContextType::EMERGENCYALARM;
      case AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
        return LeAudioContextType::INSTRUCTIONAL;
      default:
        break;
    }
@@ -3046,9 +3017,8 @@ class LeAudioClientImpl : public LeAudioClient {
        continue;
      }

      DLOG(INFO) << __func__ << ": usage=" << tracks->usage
                 << ", content_type=" << tracks->content_type
                 << ", gain=" << tracks->gain;
      LOG_INFO("%s: usage=%d, content_type=%d, gain=%f", __func__,
               tracks->usage, tracks->content_type, tracks->gain);

      auto new_context = AudioContentToLeAudioContext(
          current_context_type_, tracks->content_type, tracks->usage);