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

Commit 6e41c252 authored by Dylan Tian's avatar Dylan Tian Committed by Android Build Coastguard Worker
Browse files

Add OPUS support property check.

Tag: #feature
Bug: 254609888
Ignore-AOSP-First: tm-qpr feature
Test: atest net_test_stack:A2dpCodecConfigTest#init
Change-Id: I5e19883310be7119f777f823e6963465b5bc1a2b
(cherry picked from commit 780a0eee)
Merged-In: I5e19883310be7119f777f823e6963465b5bc1a2b
parent e0fd13ef
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -559,6 +559,9 @@ bool A2dpCodecs::init() {
  LOG_INFO("%s", __func__);
  std::lock_guard<std::recursive_mutex> lock(codec_mutex_);

  bool opus_enabled =
      osi_property_get_bool("persist.bluetooth.opus.enabled", false);

  for (int i = BTAV_A2DP_CODEC_INDEX_MIN; i < BTAV_A2DP_CODEC_INDEX_MAX; i++) {
    btav_a2dp_codec_index_t codec_index =
        static_cast<btav_a2dp_codec_index_t>(i);
@@ -571,6 +574,13 @@ bool A2dpCodecs::init() {
      codec_priority = cp_iter->second;
    }

    // If OPUS is not supported it is disabled
    if (codec_index == BTAV_A2DP_CODEC_INDEX_SOURCE_OPUS && !opus_enabled) {
      codec_priority = BTAV_A2DP_CODEC_PRIORITY_DISABLED;
      LOG_INFO("%s: OPUS codec disabled, updated priority to %d", __func__,
               codec_priority);
    }

    A2dpCodecConfig* codec_config =
        A2dpCodecConfig::createCodec(codec_index, codec_priority);
    if (codec_config == nullptr) continue;