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

Commit 52462362 authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Do not reject valid SBC codec parameters

Fixes logic in A2DP_CodecInfoMatchesCapabilitySbc that could otherwise
reject valid SBC codec parameters, leading to A2DP being disconnected.

Example:
Tesla Model S - min bitpool = 2; max bitpool = 60
Android - min bitpool = 2; max bitpool = 53

Bug: 32688022
Test: Added test to test_a2dp_is_source_codec_supported to cover this bug
Change-Id: If02bab1c47f926f82a636184cf3cbd1edbbe223a
parent ecefb405
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ static const tA2DP_SBC_CIE a2dp_sbc_sink_caps = {
    (A2DP_SBC_IE_SUBBAND_4 | A2DP_SBC_IE_SUBBAND_8),   /* num_subbands */
    (A2DP_SBC_IE_ALLOC_MD_L | A2DP_SBC_IE_ALLOC_MD_S), /* alloc_method */
    A2DP_SBC_IE_MIN_BITPOOL,                           /* min_bitpool */
    A2DP_SBC_IE_MAX_BITPOOL                            /* max_bitpool */
    A2DP_SBC_MAX_BITPOOL                               /* max_bitpool */
};

/* Default SBC codec configuration */
@@ -476,10 +476,10 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilitySbc(
    return A2DP_NS_ALLOC_METHOD;

  /* min bitpool */
  if (cfg_cie.min_bitpool < p_cap->min_bitpool) return A2DP_NS_MIN_BITPOOL;
  if (cfg_cie.min_bitpool > p_cap->max_bitpool) return A2DP_NS_MIN_BITPOOL;

  /* max bitpool */
  if (cfg_cie.max_bitpool > p_cap->max_bitpool) return A2DP_NS_MAX_BITPOOL;
  if (cfg_cie.max_bitpool < p_cap->min_bitpool) return A2DP_NS_MAX_BITPOOL;

  return A2DP_SUCCESS;
}
+3 −0
Original line number Diff line number Diff line
@@ -133,16 +133,19 @@ TEST(StackA2dpTest, test_a2dp_get_codec_type) {

TEST(StackA2dpTest, test_a2dp_is_source_codec_supported) {
  EXPECT_TRUE(A2DP_IsSourceCodecSupported(codec_info_sbc));
  EXPECT_TRUE(A2DP_IsSourceCodecSupported(codec_info_sbc_sink));
  EXPECT_FALSE(A2DP_IsSourceCodecSupported(codec_info_non_a2dp));
}

TEST(StackA2dpTest, test_a2dp_is_sink_codec_supported) {
  EXPECT_TRUE(A2DP_IsSinkCodecSupported(codec_info_sbc));
  EXPECT_TRUE(A2DP_IsSinkCodecSupported(codec_info_sbc_sink));
  EXPECT_FALSE(A2DP_IsSinkCodecSupported(codec_info_non_a2dp));
}

TEST(StackA2dpTest, test_a2dp_is_peer_source_codec_supported) {
  EXPECT_TRUE(A2DP_IsPeerSourceCodecSupported(codec_info_sbc));
  EXPECT_TRUE(A2DP_IsPeerSourceCodecSupported(codec_info_sbc_sink));
  EXPECT_FALSE(A2DP_IsPeerSourceCodecSupported(codec_info_non_a2dp));
}