diff options
author | 2024-07-12 22:12:56 +0000 | |
---|---|---|
committer | 2024-07-12 23:58:18 +0000 | |
commit | ac521a2a7457a76b216711f7f6733265d9011f92 (patch) | |
tree | 1fa7ca9840c7a50d954bcd88767061c0bf58ccf2 | |
parent | 3fa8128d5220e2412c6554926c9744fa3c7f9b5e (diff) |
stack/a2dp: Improve the declaration of tA2Dp_STATUS
- add error codes from AVDTP and GAVDTP specifications
- document the source specification for each range of constants
- rename the error codes to match the specifications
Bug: 331817295
Test: m com.android.btservices
Flag: EXEMPT, no logical change
Change-Id: Ie9dc7a889bd2b299acfb9284378c3af8347a1b23
-rw-r--r-- | system/audio_hal_interface/a2dp_encoding.h | 2 | ||||
-rw-r--r-- | system/bta/av/bta_av_int.h | 2 | ||||
-rw-r--r-- | system/bta/include/bta_av_co.h | 2 | ||||
-rw-r--r-- | system/btif/co/bta_av_co.cc | 8 | ||||
-rw-r--r-- | system/stack/a2dp/a2dp_aac.cc | 68 | ||||
-rw-r--r-- | system/stack/a2dp/a2dp_api.cc | 16 | ||||
-rw-r--r-- | system/stack/a2dp/a2dp_sbc.cc | 94 | ||||
-rw-r--r-- | system/stack/a2dp/a2dp_vendor_aptx.cc | 51 | ||||
-rw-r--r-- | system/stack/a2dp/a2dp_vendor_aptx_hd.cc | 54 | ||||
-rw-r--r-- | system/stack/a2dp/a2dp_vendor_ldac.cc | 62 | ||||
-rw-r--r-- | system/stack/a2dp/a2dp_vendor_opus.cc | 66 | ||||
-rw-r--r-- | system/stack/include/a2dp_api.h | 11 | ||||
-rw-r--r-- | system/stack/include/a2dp_constants.h | 67 | ||||
-rw-r--r-- | system/stack/include/a2dp_error_codes.h | 136 | ||||
-rw-r--r-- | system/stack/include/avdt_api.h | 14 | ||||
-rw-r--r-- | system/test/mock/mock_btif_co_bta_av_co.h | 2 | ||||
-rw-r--r-- | system/test/mock/mock_stack_a2dp_api.cc | 6 |
17 files changed, 273 insertions, 388 deletions
diff --git a/system/audio_hal_interface/a2dp_encoding.h b/system/audio_hal_interface/a2dp_encoding.h index e9fa447f5d..1e2d299610 100644 --- a/system/audio_hal_interface/a2dp_encoding.h +++ b/system/audio_hal_interface/a2dp_encoding.h @@ -20,7 +20,7 @@ #include <sstream> #include <vector> -#include "a2dp_error_codes.h" +#include "a2dp_constants.h" #include "avdt_api.h" #include "common/message_loop_thread.h" #include "hardware/bt_av.h" diff --git a/system/bta/av/bta_av_int.h b/system/bta/av/bta_av_int.h index c0856ca308..4b559ef59a 100644 --- a/system/bta/av/bta_av_int.h +++ b/system/bta/av/bta_av_int.h @@ -36,7 +36,7 @@ #include "internal_include/bt_target.h" #include "macros.h" #include "osi/include/list.h" -#include "stack/include/a2dp_error_codes.h" +#include "stack/include/a2dp_constants.h" #include "stack/include/avdt_api.h" #include "stack/include/bt_hdr.h" #include "stack/include/hci_error_code.h" diff --git a/system/bta/include/bta_av_co.h b/system/bta/include/bta_av_co.h index ccf7f09164..cd3cee8139 100644 --- a/system/bta/include/bta_av_co.h +++ b/system/bta/include/bta_av_co.h @@ -28,7 +28,7 @@ #include "bta/include/bta_av_api.h" #include "include/hardware/bt_av.h" -#include "stack/include/a2dp_error_codes.h" +#include "stack/include/a2dp_constants.h" #include "stack/include/avdt_api.h" #include "stack/include/bt_hdr.h" #include "types/raw_address.h" diff --git a/system/btif/co/bta_av_co.cc b/system/btif/co/bta_av_co.cc index 801f07e702..3b66ced0d2 100644 --- a/system/btif/co/bta_av_co.cc +++ b/system/btif/co/bta_av_co.cc @@ -45,7 +45,7 @@ #include "internal_include/bt_trace.h" #include "osi/include/allocator.h" #include "stack/include/a2dp_codec_api.h" -#include "stack/include/a2dp_error_codes.h" +#include "stack/include/a2dp_constants.h" #include "stack/include/a2dp_ext.h" #include "stack/include/avdt_api.h" #include "stack/include/bt_hdr.h" @@ -463,13 +463,13 @@ void BtaAvCo::ProcessSetConfig(tBTA_AV_HNDL bta_av_handle, const RawAddress& pee if (ContentProtectEnabled()) { if ((num_protect != 1) || !ContentProtectIsScmst(p_protect_info)) { log::error("wrong CP configuration for peer {}", p_peer->addr); - status = A2DP_BAD_CP_TYPE; + status = A2DP_INVALID_CP_TYPE; category = AVDT_ASC_PROTECT; } } else { // Do not support content protection for the time being log::error("wrong CP configuration for peer {}", p_peer->addr); - status = A2DP_BAD_CP_TYPE; + status = A2DP_INVALID_CP_TYPE; category = AVDT_ASC_PROTECT; } } @@ -508,7 +508,7 @@ void BtaAvCo::ProcessSetConfig(tBTA_AV_HNDL bta_av_handle, const RawAddress& pee // Check if codec configuration is supported if (!codec_config_supported) { category = AVDT_ASC_CODEC; - status = A2DP_WRONG_CODEC; + status = AVDTP_UNSUPPORTED_CONFIGURATION; } } diff --git a/system/stack/a2dp/a2dp_aac.cc b/system/stack/a2dp/a2dp_aac.cc index ae9fb9a8bd..6db89087d9 100644 --- a/system/stack/a2dp/a2dp_aac.cc +++ b/system/stack/a2dp/a2dp_aac.cc @@ -141,10 +141,9 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityAac(const tA2DP_AAC_CIE* p_ca // |p_ie| is a pointer to the AAC Codec Information Element information. // The result is stored in |p_result|. Returns A2DP_SUCCESS on success, // otherwise the corresponding A2DP error status code. -static tA2DP_STATUS A2DP_BuildInfoAac(uint8_t media_type, const tA2DP_AAC_CIE* p_ie, - uint8_t* p_result) { +static bool A2DP_BuildInfoAac(uint8_t media_type, const tA2DP_AAC_CIE* p_ie, uint8_t* p_result) { if (p_ie == NULL || p_result == NULL) { - return A2DP_INVALID_PARAMS; + return false; } *p_result++ = A2DP_AAC_CODEC_LEN; @@ -153,20 +152,20 @@ static tA2DP_STATUS A2DP_BuildInfoAac(uint8_t media_type, const tA2DP_AAC_CIE* p // Object Type if (p_ie->objectType == 0) { - return A2DP_INVALID_PARAMS; + return false; } *p_result++ = p_ie->objectType; // Sampling Frequency if (p_ie->sampleRate == 0) { - return A2DP_INVALID_PARAMS; + return false; } *p_result++ = (uint8_t)(p_ie->sampleRate & A2DP_AAC_SAMPLING_FREQ_MASK0); *p_result = (uint8_t)((p_ie->sampleRate & A2DP_AAC_SAMPLING_FREQ_MASK1) >> 8); // Channel Mode if (p_ie->channelMode == 0) { - return A2DP_INVALID_PARAMS; + return false; } *p_result++ |= (p_ie->channelMode & A2DP_AAC_CHANNEL_MODE_MASK); @@ -178,7 +177,7 @@ static tA2DP_STATUS A2DP_BuildInfoAac(uint8_t media_type, const tA2DP_AAC_CIE* p *p_result++ = (uint8_t)((p_ie->bitRate & A2DP_AAC_BIT_RATE_MASK1) >> 8); *p_result++ = (uint8_t)(p_ie->bitRate & A2DP_AAC_BIT_RATE_MASK2); - return A2DP_SUCCESS; + return true; } // Parses the AAC Media Codec Capabilities byte sequence beginning from the @@ -194,20 +193,20 @@ static tA2DP_STATUS A2DP_ParseInfoAac(tA2DP_AAC_CIE* p_ie, const uint8_t* p_code tA2DP_CODEC_TYPE codec_type; if (p_ie == NULL || p_codec_info == NULL) { - return A2DP_INVALID_PARAMS; + return AVDTP_UNSUPPORTED_CONFIGURATION; } // Check the codec capability length losc = *p_codec_info++; if (losc != A2DP_AAC_CODEC_LEN) { - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } media_type = (*p_codec_info++) >> 4; codec_type = static_cast<tA2DP_CODEC_TYPE>(*p_codec_info++); /* Check the Media Type and Media Codec Type */ if (media_type != AVDT_MEDIA_TYPE_AUDIO || codec_type != A2DP_MEDIA_CT_AAC) { - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } p_ie->objectType = *p_codec_info++; @@ -228,26 +227,26 @@ static tA2DP_STATUS A2DP_ParseInfoAac(tA2DP_AAC_CIE* p_ie, const uint8_t* p_code // NOTE: The checks here are very liberal. We should be using more // pedantic checks specific to the SRC or SNK as specified in the spec. if (A2DP_BitsSet(p_ie->objectType) == A2DP_SET_ZERO_BIT) { - return A2DP_BAD_OBJ_TYPE; + return A2DP_INVALID_OBJECT_TYPE; } if (A2DP_BitsSet(p_ie->sampleRate) == A2DP_SET_ZERO_BIT) { - return A2DP_BAD_SAMP_FREQ; + return A2DP_INVALID_SAMPLING_FREQUENCY; } if (A2DP_BitsSet(p_ie->channelMode) == A2DP_SET_ZERO_BIT) { - return A2DP_BAD_CH_MODE; + return A2DP_INVALID_CHANNEL_MODE; } return A2DP_SUCCESS; } if (A2DP_BitsSet(p_ie->objectType) != A2DP_SET_ONE_BIT) { - return A2DP_BAD_OBJ_TYPE; + return A2DP_INVALID_OBJECT_TYPE; } if (A2DP_BitsSet(p_ie->sampleRate) != A2DP_SET_ONE_BIT) { - return A2DP_BAD_SAMP_FREQ; + return A2DP_INVALID_SAMPLING_FREQUENCY; } if (A2DP_BitsSet(p_ie->channelMode) != A2DP_SET_ONE_BIT) { - return A2DP_BAD_CH_MODE; + return A2DP_INVALID_CHANNEL_MODE; } return A2DP_SUCCESS; @@ -298,17 +297,17 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityAac(const tA2DP_AAC_CIE* p_ca /* Object Type */ if ((cfg_cie.objectType & p_cap->objectType) == 0) { - return A2DP_BAD_OBJ_TYPE; + return A2DP_INVALID_OBJECT_TYPE; } /* Sample Rate */ if ((cfg_cie.sampleRate & p_cap->sampleRate) == 0) { - return A2DP_BAD_SAMP_FREQ; + return A2DP_INVALID_SAMPLING_FREQUENCY; } /* Channel Mode */ if ((cfg_cie.channelMode & p_cap->channelMode) == 0) { - return A2DP_NS_CH_MODE; + return A2DP_NOT_SUPPORTED_CHANNEL_MODE; } return A2DP_SUCCESS; @@ -690,17 +689,11 @@ static void aac_source_caps_initialize() { bool A2DP_InitCodecConfigAac(AvdtpSepConfig* p_cfg) { aac_source_caps_initialize(); - if (A2DP_BuildInfoAac(AVDT_MEDIA_TYPE_AUDIO, &a2dp_aac_source_caps, p_cfg->codec_info) != - A2DP_SUCCESS) { - return false; - } - - return true; + return A2DP_BuildInfoAac(AVDT_MEDIA_TYPE_AUDIO, &a2dp_aac_source_caps, p_cfg->codec_info); } bool A2DP_InitCodecConfigAacSink(AvdtpSepConfig* p_cfg) { - return A2DP_BuildInfoAac(AVDT_MEDIA_TYPE_AUDIO, &a2dp_aac_sink_caps, p_cfg->codec_info) == - A2DP_SUCCESS; + return A2DP_BuildInfoAac(AVDT_MEDIA_TYPE_AUDIO, &a2dp_aac_sink_caps, p_cfg->codec_info); } A2dpCodecConfigAacSource::A2dpCodecConfigAacSource(btav_a2dp_codec_priority_t codec_priority) @@ -1292,21 +1285,23 @@ bool A2dpCodecConfigAacBase::setCodecConfig(const uint8_t* p_peer_codec_info, bo codec_config_.codec_specific_4 = codec_user_config_.codec_specific_4; } - if (A2DP_BuildInfoAac(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, p_result_codec_config) != - A2DP_SUCCESS) { + if (!A2DP_BuildInfoAac(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, p_result_codec_config)) { goto fail; } // Create a local copy of the peer codec capability/config, and the // result codec config. if (is_capability) { - status = A2DP_BuildInfoAac(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_); + log::assert_that( + A2DP_BuildInfoAac(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_), + "Failed to build media codec capabilities"); } else { - status = A2DP_BuildInfoAac(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_config_); + log::assert_that( + A2DP_BuildInfoAac(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_config_), + "Failed to build media codec capabilities"); } - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); - status = A2DP_BuildInfoAac(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, ota_codec_config_); - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); + log::assert_that(A2DP_BuildInfoAac(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, ota_codec_config_), + "Failed to build media codec capabilities"); return true; fail: @@ -1381,8 +1376,9 @@ bool A2dpCodecConfigAacBase::setPeerCodecCapabilities(const uint8_t* p_peer_code static_cast<int64_t>(AacEncoderBitrateMode::AACENC_BR_MODE_CBR); } - status = A2DP_BuildInfoAac(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_); - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); + log::assert_that( + A2DP_BuildInfoAac(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_), + "Failed to build media codec capabilities"); return true; fail: diff --git a/system/stack/a2dp/a2dp_api.cc b/system/stack/a2dp/a2dp_api.cc index f32f7a3d42..b0c43ea709 100644 --- a/system/stack/a2dp/a2dp_api.cc +++ b/system/stack/a2dp/a2dp_api.cc @@ -178,13 +178,12 @@ static void a2dp_sdp_cback(const RawAddress& /* bd_addr */, tSDP_STATUS status) * Output Parameters: * None. * - * Returns A2DP_SUCCESS if function execution succeeded, - * A2DP_INVALID_PARAMS if bad parameters are given. - * A2DP_FAIL if function execution failed. + * Returns true if function execution succeeded, + * false if bad parameters are given or execution failed. * *****************************************************************************/ -tA2DP_STATUS A2DP_AddRecord(uint16_t service_uuid, char* p_service_name, char* p_provider_name, - uint16_t features, uint32_t sdp_handle) { +bool A2DP_AddRecord(uint16_t service_uuid, char* p_service_name, char* p_provider_name, + uint16_t features, uint32_t sdp_handle) { uint16_t browse_list[1]; bool result = true; uint8_t temp[8]; @@ -195,7 +194,7 @@ tA2DP_STATUS A2DP_AddRecord(uint16_t service_uuid, char* p_service_name, char* p if ((sdp_handle == 0) || (service_uuid != UUID_SERVCLASS_AUDIO_SOURCE && service_uuid != UUID_SERVCLASS_AUDIO_SINK)) { - return A2DP_INVALID_PARAMS; + return false; } /* add service class id list */ @@ -246,7 +245,7 @@ tA2DP_STATUS A2DP_AddRecord(uint16_t service_uuid, char* p_service_name, char* p result &= get_legacy_stack_sdp_api()->handle.SDP_AddUuidSequence( sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, browse_list); - return result ? A2DP_SUCCESS : A2DP_FAIL; + return result; } /****************************************************************************** @@ -279,7 +278,6 @@ tA2DP_STATUS A2DP_AddRecord(uint16_t service_uuid, char* p_service_name, char* p * None. * * Returns A2DP_SUCCESS if function execution succeeded, - * A2DP_INVALID_PARAMS if bad parameters are given. * A2DP_BUSY if discovery is already in progress. * A2DP_FAIL if function execution failed. * @@ -290,7 +288,7 @@ tA2DP_STATUS A2DP_FindService(uint16_t service_uuid, const RawAddress& bd_addr, p_db == NULL || p_cback.is_null()) { log::error("Cannot find service for peer {} UUID 0x{:04x}: invalid parameters", bd_addr, service_uuid); - return A2DP_INVALID_PARAMS; + return A2DP_FAIL; } if (a2dp_cb.find.service_uuid == UUID_SERVCLASS_AUDIO_SOURCE || diff --git a/system/stack/a2dp/a2dp_sbc.cc b/system/stack/a2dp/a2dp_sbc.cc index f56aa46ede..2aed0546eb 100644 --- a/system/stack/a2dp/a2dp_sbc.cc +++ b/system/stack/a2dp/a2dp_sbc.cc @@ -121,8 +121,7 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilitySbc(const tA2DP_SBC_CIE* p_ca // |p_ie| is a pointer to the SBC Codec Information Element information. // The result is stored in |p_result|. Returns A2DP_SUCCESS on success, // otherwise the corresponding A2DP error status code. -static tA2DP_STATUS A2DP_BuildInfoSbc(uint8_t media_type, const tA2DP_SBC_CIE* p_ie, - uint8_t* p_result) { +static bool A2DP_BuildInfoSbc(uint8_t media_type, const tA2DP_SBC_CIE* p_ie, uint8_t* p_result) { if (p_ie == NULL || p_result == NULL || (p_ie->samp_freq & ~A2DP_SBC_IE_SAMP_FREQ_MSK) || (p_ie->ch_mode & ~A2DP_SBC_IE_CH_MD_MSK) || (p_ie->block_len & ~A2DP_SBC_IE_BLOCKS_MSK) || (p_ie->num_subbands & ~A2DP_SBC_IE_SUBBAND_MSK) || @@ -132,7 +131,7 @@ static tA2DP_STATUS A2DP_BuildInfoSbc(uint8_t media_type, const tA2DP_SBC_CIE* p (p_ie->max_bitpool < A2DP_SBC_IE_MIN_BITPOOL) || (p_ie->max_bitpool > A2DP_SBC_IE_MAX_BITPOOL)) { /* if any unused bit is set */ - return A2DP_INVALID_PARAMS; + return false; } *p_result++ = A2DP_SBC_INFO_LEN; @@ -147,7 +146,7 @@ static tA2DP_STATUS A2DP_BuildInfoSbc(uint8_t media_type, const tA2DP_SBC_CIE* p *p_result++ = p_ie->min_bitpool; *p_result = p_ie->max_bitpool; - return A2DP_SUCCESS; + return true; } // Parses the SBC Media Codec Capabilities byte sequence beginning from the @@ -163,20 +162,20 @@ static tA2DP_STATUS A2DP_ParseInfoSbc(tA2DP_SBC_CIE* p_ie, const uint8_t* p_code tA2DP_CODEC_TYPE codec_type; if (p_ie == NULL || p_codec_info == NULL) { - return A2DP_INVALID_PARAMS; + return AVDTP_UNSUPPORTED_CONFIGURATION; } // Check the codec capability length losc = *p_codec_info++; if (losc != A2DP_SBC_INFO_LEN) { - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } media_type = (*p_codec_info++) >> 4; codec_type = static_cast<tA2DP_CODEC_TYPE>(*p_codec_info++); /* Check the Media Type and Media Codec Type */ if (media_type != AVDT_MEDIA_TYPE_AUDIO || codec_type != A2DP_MEDIA_CT_SBC) { - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } p_ie->samp_freq = *p_codec_info & A2DP_SBC_IE_SAMP_FREQ_MSK; @@ -189,50 +188,50 @@ static tA2DP_STATUS A2DP_ParseInfoSbc(tA2DP_SBC_CIE* p_ie, const uint8_t* p_code p_ie->min_bitpool = *p_codec_info++; p_ie->max_bitpool = *p_codec_info++; if (p_ie->min_bitpool < A2DP_SBC_IE_MIN_BITPOOL || p_ie->min_bitpool > A2DP_SBC_IE_MAX_BITPOOL) { - return A2DP_BAD_MIN_BITPOOL; + return A2DP_INVALID_MINIMUM_BITPOOL_VALUE; } if (p_ie->max_bitpool < A2DP_SBC_IE_MIN_BITPOOL || p_ie->max_bitpool > A2DP_SBC_IE_MAX_BITPOOL || p_ie->max_bitpool < p_ie->min_bitpool) { - return A2DP_BAD_MAX_BITPOOL; + return A2DP_INVALID_MAXIMUM_BITPOOL_VALUE; } if (is_capability) { // NOTE: The checks here are very liberal. We should be using more // pedantic checks specific to the SRC or SNK as specified in the spec. if (A2DP_BitsSet(p_ie->samp_freq) == A2DP_SET_ZERO_BIT) { - return A2DP_BAD_SAMP_FREQ; + return A2DP_INVALID_SAMPLING_FREQUENCY; } if (A2DP_BitsSet(p_ie->ch_mode) == A2DP_SET_ZERO_BIT) { - return A2DP_BAD_CH_MODE; + return A2DP_INVALID_CHANNEL_MODE; } if (A2DP_BitsSet(p_ie->block_len) == A2DP_SET_ZERO_BIT) { - return A2DP_BAD_BLOCK_LEN; + return A2DP_INVALID_BLOCK_LENGTH; } if (A2DP_BitsSet(p_ie->num_subbands) == A2DP_SET_ZERO_BIT) { - return A2DP_BAD_SUBBANDS; + return A2DP_INVALID_SUBBANDS; } if (A2DP_BitsSet(p_ie->alloc_method) == A2DP_SET_ZERO_BIT) { - return A2DP_BAD_ALLOC_METHOD; + return A2DP_INVALID_ALLOCATION_METHOD; } return A2DP_SUCCESS; } if (A2DP_BitsSet(p_ie->samp_freq) != A2DP_SET_ONE_BIT) { - return A2DP_BAD_SAMP_FREQ; + return A2DP_INVALID_SAMPLING_FREQUENCY; } if (A2DP_BitsSet(p_ie->ch_mode) != A2DP_SET_ONE_BIT) { - return A2DP_BAD_CH_MODE; + return A2DP_INVALID_CHANNEL_MODE; } if (A2DP_BitsSet(p_ie->block_len) != A2DP_SET_ONE_BIT) { - return A2DP_BAD_BLOCK_LEN; + return A2DP_INVALID_BLOCK_LENGTH; } if (A2DP_BitsSet(p_ie->num_subbands) != A2DP_SET_ONE_BIT) { - return A2DP_BAD_SUBBANDS; + return A2DP_INVALID_SUBBANDS; } if (A2DP_BitsSet(p_ie->alloc_method) != A2DP_SET_ONE_BIT) { - return A2DP_BAD_ALLOC_METHOD; + return A2DP_INVALID_ALLOCATION_METHOD; } return A2DP_SUCCESS; @@ -280,10 +279,8 @@ bool A2DP_IsSinkCodecSupportedSbc(const uint8_t* p_codec_info) { } void A2DP_InitDefaultCodecSbc(uint8_t* p_codec_info) { - if (A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &a2dp_sbc_default_config, p_codec_info) != - A2DP_SUCCESS) { - log::error("A2DP_BuildInfoSbc failed"); - } + log::assert_that(A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &a2dp_sbc_default_config, p_codec_info), + "Failed to build default media codec capabilities"); } // Checks whether A2DP SBC codec configuration matches with a device's codec @@ -321,37 +318,37 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilitySbc(const tA2DP_SBC_CIE* p_ca /* sampling frequency */ if ((cfg_cie.samp_freq & p_cap->samp_freq) == 0) { - return A2DP_NS_SAMP_FREQ; + return A2DP_NOT_SUPPORTED_SAMPLING_FREQUENCY; } /* channel mode */ if ((cfg_cie.ch_mode & p_cap->ch_mode) == 0) { - return A2DP_NS_CH_MODE; + return A2DP_NOT_SUPPORTED_CHANNEL_MODE; } /* block length */ if ((cfg_cie.block_len & p_cap->block_len) == 0) { - return A2DP_BAD_BLOCK_LEN; + return A2DP_INVALID_BLOCK_LENGTH; } /* subbands */ if ((cfg_cie.num_subbands & p_cap->num_subbands) == 0) { - return A2DP_NS_SUBBANDS; + return A2DP_NOT_SUPPORTED_SUBBANDS; } /* allocation method */ if ((cfg_cie.alloc_method & p_cap->alloc_method) == 0) { - return A2DP_NS_ALLOC_METHOD; + return A2DP_NOT_SUPPORTED_ALLOCATION_METHOD; } /* min bitpool */ if (cfg_cie.min_bitpool > p_cap->max_bitpool) { - return A2DP_NS_MIN_BITPOOL; + return A2DP_NOT_SUPPORTED_MINIMUM_BITPOOL_VALUE; } /* max bitpool */ if (cfg_cie.max_bitpool < p_cap->min_bitpool) { - return A2DP_NS_MAX_BITPOOL; + return A2DP_NOT_SUPPORTED_MAXIMUM_BITPOOL_VALUE; } return A2DP_SUCCESS; @@ -756,7 +753,7 @@ bool A2DP_AdjustCodecSbc(uint8_t* p_codec_info) { cfg_cie.max_bitpool = A2DP_SBC_MAX_BITPOOL; } - return A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &cfg_cie, p_codec_info) == A2DP_SUCCESS; + return A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &cfg_cie, p_codec_info); } btav_a2dp_codec_index_t A2DP_SourceCodecIndexSbc(const uint8_t* /* p_codec_info */) { @@ -772,21 +769,11 @@ const char* A2DP_CodecIndexStrSbc(void) { return "SBC"; } const char* A2DP_CodecIndexStrSbcSink(void) { return "SBC SINK"; } bool A2DP_InitCodecConfigSbc(AvdtpSepConfig* p_cfg) { - if (A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &a2dp_sbc_source_caps, p_cfg->codec_info) != - A2DP_SUCCESS) { - return false; - } - - return true; + return A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &a2dp_sbc_source_caps, p_cfg->codec_info); } bool A2DP_InitCodecConfigSbcSink(AvdtpSepConfig* p_cfg) { - if (A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &a2dp_sbc_sink_caps, p_cfg->codec_info) != - A2DP_SUCCESS) { - return false; - } - - return true; + return A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &a2dp_sbc_sink_caps, p_cfg->codec_info); } A2dpCodecConfigSbcSource::A2dpCodecConfigSbcSource(btav_a2dp_codec_priority_t codec_priority) @@ -1322,8 +1309,7 @@ bool A2dpCodecConfigSbcBase::setCodecConfig(const uint8_t* p_peer_codec_info, bo goto fail; } - if (A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, p_result_codec_config) != - A2DP_SUCCESS) { + if (!A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, p_result_codec_config)) { goto fail; } @@ -1346,13 +1332,16 @@ bool A2dpCodecConfigSbcBase::setCodecConfig(const uint8_t* p_peer_codec_info, bo // Create a local copy of the peer codec capability/config, and the // result codec config. if (is_capability) { - status = A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_); + log::assert_that( + A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_), + "Failed to build media codec capabilities"); } else { - status = A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_config_); + log::assert_that( + A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_config_), + "Failed to build media codec capabilities"); } - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); - status = A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, ota_codec_config_); - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); + log::assert_that(A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, ota_codec_config_), + "Failed to build media codec capabilities"); return true; fail: @@ -1415,8 +1404,9 @@ bool A2dpCodecConfigSbcBase::setPeerCodecCapabilities(const uint8_t* p_peer_code codec_selectable_capability_.channel_mode |= BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO; } - status = A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_); - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); + log::assert_that( + A2DP_BuildInfoSbc(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_), + "Failed to build media codec capabilities"); return true; fail: diff --git a/system/stack/a2dp/a2dp_vendor_aptx.cc b/system/stack/a2dp/a2dp_vendor_aptx.cc index ad3d03e36a..f2cd57b77f 100644 --- a/system/stack/a2dp/a2dp_vendor_aptx.cc +++ b/system/stack/a2dp/a2dp_vendor_aptx.cc @@ -86,10 +86,9 @@ static const tA2DP_ENCODER_INTERFACE a2dp_encoder_interface_aptx = { // |p_ie| is a pointer to the aptX Codec Information Element information. // The result is stored in |p_result|. Returns A2DP_SUCCESS on success, // otherwise the corresponding A2DP error status code. -static tA2DP_STATUS A2DP_BuildInfoAptx(uint8_t media_type, const tA2DP_APTX_CIE* p_ie, - uint8_t* p_result) { +static bool A2DP_BuildInfoAptx(uint8_t media_type, const tA2DP_APTX_CIE* p_ie, uint8_t* p_result) { if (p_ie == NULL || p_result == NULL) { - return A2DP_INVALID_PARAMS; + return false; } *p_result++ = A2DP_APTX_CODEC_LEN; @@ -103,7 +102,7 @@ static tA2DP_STATUS A2DP_BuildInfoAptx(uint8_t media_type, const tA2DP_APTX_CIE* *p_result++ = (uint8_t)((p_ie->codecId & 0xFF00) >> 8); *p_result++ = p_ie->sampleRate | p_ie->channelMode; - return A2DP_SUCCESS; + return true; } // Parses the aptX Media Codec Capabilities byte sequence beginning from the @@ -119,20 +118,20 @@ static tA2DP_STATUS A2DP_ParseInfoAptx(tA2DP_APTX_CIE* p_ie, const uint8_t* p_co tA2DP_CODEC_TYPE codec_type; if (p_ie == NULL || p_codec_info == NULL) { - return A2DP_INVALID_PARAMS; + return AVDTP_UNSUPPORTED_CONFIGURATION; } // Check the codec capability length losc = *p_codec_info++; if (losc != A2DP_APTX_CODEC_LEN) { - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } media_type = (*p_codec_info++) >> 4; codec_type = static_cast<tA2DP_CODEC_TYPE>(*p_codec_info++); /* Check the Media Type and Media Codec Type */ if (media_type != AVDT_MEDIA_TYPE_AUDIO || codec_type != A2DP_MEDIA_CT_NON_A2DP) { - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } // Check the Vendor ID and Codec ID */ @@ -143,7 +142,7 @@ static tA2DP_STATUS A2DP_ParseInfoAptx(tA2DP_APTX_CIE* p_ie, const uint8_t* p_co p_ie->codecId = (*p_codec_info & 0x00FF) | (*(p_codec_info + 1) << 8 & 0xFF00); p_codec_info += 2; if (p_ie->vendorId != A2DP_APTX_VENDOR_ID || p_ie->codecId != A2DP_APTX_CODEC_ID_BLUETOOTH) { - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } p_ie->channelMode = *p_codec_info & 0x0F; @@ -154,20 +153,20 @@ static tA2DP_STATUS A2DP_ParseInfoAptx(tA2DP_APTX_CIE* p_ie, const uint8_t* p_co // NOTE: The checks here are very liberal. We should be using more // pedantic checks specific to the SRC or SNK as specified in the spec. if (A2DP_BitsSet(p_ie->sampleRate) == A2DP_SET_ZERO_BIT) { - return A2DP_BAD_SAMP_FREQ; + return A2DP_INVALID_SAMPLING_FREQUENCY; } if (A2DP_BitsSet(p_ie->channelMode) == A2DP_SET_ZERO_BIT) { - return A2DP_BAD_CH_MODE; + return A2DP_INVALID_CHANNEL_MODE; } return A2DP_SUCCESS; } if (A2DP_BitsSet(p_ie->sampleRate) != A2DP_SET_ONE_BIT) { - return A2DP_BAD_SAMP_FREQ; + return A2DP_INVALID_SAMPLING_FREQUENCY; } if (A2DP_BitsSet(p_ie->channelMode) != A2DP_SET_ONE_BIT) { - return A2DP_BAD_CH_MODE; + return A2DP_INVALID_CHANNEL_MODE; } return A2DP_SUCCESS; @@ -360,12 +359,7 @@ btav_a2dp_codec_index_t A2DP_VendorSourceCodecIndexAptx(const uint8_t* /* p_code const char* A2DP_VendorCodecIndexStrAptx(void) { return "aptX"; } bool A2DP_VendorInitCodecConfigAptx(AvdtpSepConfig* p_cfg) { - if (A2DP_BuildInfoAptx(AVDT_MEDIA_TYPE_AUDIO, &a2dp_aptx_source_caps, p_cfg->codec_info) != - A2DP_SUCCESS) { - return false; - } - - return true; + return A2DP_BuildInfoAptx(AVDT_MEDIA_TYPE_AUDIO, &a2dp_aptx_source_caps, p_cfg->codec_info); } A2dpCodecConfigAptx::A2dpCodecConfigAptx(btav_a2dp_codec_priority_t codec_priority) @@ -782,8 +776,7 @@ bool A2dpCodecConfigAptx::setCodecConfig(const uint8_t* p_peer_codec_info, bool result_config_cie.future1 = a2dp_aptx_source_caps.future1 & peer_info_cie.future1; result_config_cie.future2 = a2dp_aptx_source_caps.future2 & peer_info_cie.future2; - if (A2DP_BuildInfoAptx(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, p_result_codec_config) != - A2DP_SUCCESS) { + if (!A2DP_BuildInfoAptx(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, p_result_codec_config)) { goto fail; } @@ -806,13 +799,16 @@ bool A2dpCodecConfigAptx::setCodecConfig(const uint8_t* p_peer_codec_info, bool // Create a local copy of the peer codec capability/config, and the // result codec config. if (is_capability) { - status = A2DP_BuildInfoAptx(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_); + log::assert_that( + A2DP_BuildInfoAptx(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_), + "Failed to build media codec capabilities"); } else { - status = A2DP_BuildInfoAptx(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_config_); + log::assert_that( + A2DP_BuildInfoAptx(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_config_), + "Failed to build media codec capabilities"); } - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); - status = A2DP_BuildInfoAptx(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, ota_codec_config_); - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); + log::assert_that(A2DP_BuildInfoAptx(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, ota_codec_config_), + "Failed to build media codec capabilities"); return true; @@ -869,8 +865,9 @@ bool A2dpCodecConfigAptx::setPeerCodecCapabilities(const uint8_t* p_peer_codec_c codec_selectable_capability_.channel_mode |= BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO; } - status = A2DP_BuildInfoAptx(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_); - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); + log::assert_that( + A2DP_BuildInfoAptx(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_), + "Failed to build media codec capabilities"); return true; fail: diff --git a/system/stack/a2dp/a2dp_vendor_aptx_hd.cc b/system/stack/a2dp/a2dp_vendor_aptx_hd.cc index 9c42b6c5e2..c793fd9a51 100644 --- a/system/stack/a2dp/a2dp_vendor_aptx_hd.cc +++ b/system/stack/a2dp/a2dp_vendor_aptx_hd.cc @@ -93,10 +93,10 @@ static const tA2DP_ENCODER_INTERFACE a2dp_encoder_interface_aptx_hd = { // |p_ie| is a pointer to the aptX-HD Codec Information Element information. // The result is stored in |p_result|. Returns A2DP_SUCCESS on success, // otherwise the corresponding A2DP error status code. -static tA2DP_STATUS A2DP_BuildInfoAptxHd(uint8_t media_type, const tA2DP_APTX_HD_CIE* p_ie, - uint8_t* p_result) { +static bool A2DP_BuildInfoAptxHd(uint8_t media_type, const tA2DP_APTX_HD_CIE* p_ie, + uint8_t* p_result) { if (p_ie == NULL || p_result == NULL) { - return A2DP_INVALID_PARAMS; + return false; } *p_result++ = A2DP_APTX_HD_CODEC_LEN; @@ -114,7 +114,7 @@ static tA2DP_STATUS A2DP_BuildInfoAptxHd(uint8_t media_type, const tA2DP_APTX_HD *p_result++ = p_ie->acl_sprint_reserved2; *p_result++ = p_ie->acl_sprint_reserved3; - return A2DP_SUCCESS; + return true; } // Parses the aptX-HD Media Codec Capabilities byte sequence beginning from the @@ -130,20 +130,20 @@ static tA2DP_STATUS A2DP_ParseInfoAptxHd(tA2DP_APTX_HD_CIE* p_ie, const uint8_t* tA2DP_CODEC_TYPE codec_type; if (p_ie == NULL || p_codec_info == NULL) { - return A2DP_INVALID_PARAMS; + return AVDTP_UNSUPPORTED_CONFIGURATION; } // Check the codec capability length losc = *p_codec_info++; if (losc != A2DP_APTX_HD_CODEC_LEN) { - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } media_type = (*p_codec_info++) >> 4; codec_type = static_cast<tA2DP_CODEC_TYPE>(*p_codec_info++); /* Check the Media Type and Media Codec Type */ if (media_type != AVDT_MEDIA_TYPE_AUDIO || codec_type != A2DP_MEDIA_CT_NON_A2DP) { - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } // Check the Vendor ID and Codec ID */ @@ -155,7 +155,7 @@ static tA2DP_STATUS A2DP_ParseInfoAptxHd(tA2DP_APTX_HD_CIE* p_ie, const uint8_t* p_codec_info += 2; if (p_ie->vendorId != A2DP_APTX_HD_VENDOR_ID || p_ie->codecId != A2DP_APTX_HD_CODEC_ID_BLUETOOTH) { - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } p_ie->channelMode = *p_codec_info & 0x0F; @@ -171,20 +171,20 @@ static tA2DP_STATUS A2DP_ParseInfoAptxHd(tA2DP_APTX_HD_CIE* p_ie, const uint8_t* // NOTE: The checks here are very liberal. We should be using more // pedantic checks specific to the SRC or SNK as specified in the spec. if (A2DP_BitsSet(p_ie->sampleRate) == A2DP_SET_ZERO_BIT) { - return A2DP_BAD_SAMP_FREQ; + return A2DP_INVALID_SAMPLING_FREQUENCY; } if (A2DP_BitsSet(p_ie->channelMode) == A2DP_SET_ZERO_BIT) { - return A2DP_BAD_CH_MODE; + return A2DP_INVALID_CHANNEL_MODE; } return A2DP_SUCCESS; } if (A2DP_BitsSet(p_ie->sampleRate) != A2DP_SET_ONE_BIT) { - return A2DP_BAD_SAMP_FREQ; + return A2DP_INVALID_SAMPLING_FREQUENCY; } if (A2DP_BitsSet(p_ie->channelMode) != A2DP_SET_ONE_BIT) { - return A2DP_BAD_CH_MODE; + return A2DP_INVALID_CHANNEL_MODE; } return A2DP_SUCCESS; @@ -377,12 +377,7 @@ btav_a2dp_codec_index_t A2DP_VendorSourceCodecIndexAptxHd(const uint8_t* p_codec const char* A2DP_VendorCodecIndexStrAptxHd(void) { return "aptX-HD"; } bool A2DP_VendorInitCodecConfigAptxHd(AvdtpSepConfig* p_cfg) { - if (A2DP_BuildInfoAptxHd(AVDT_MEDIA_TYPE_AUDIO, &a2dp_aptx_hd_source_caps, p_cfg->codec_info) != - A2DP_SUCCESS) { - return false; - } - - return true; + return A2DP_BuildInfoAptxHd(AVDT_MEDIA_TYPE_AUDIO, &a2dp_aptx_hd_source_caps, p_cfg->codec_info); } A2dpCodecConfigAptxHd::A2dpCodecConfigAptxHd(btav_a2dp_codec_priority_t codec_priority) @@ -803,8 +798,7 @@ bool A2dpCodecConfigAptxHd::setCodecConfig(const uint8_t* p_peer_codec_info, boo result_config_cie.acl_sprint_reserved3 = a2dp_aptx_hd_source_caps.acl_sprint_reserved3 & peer_info_cie.acl_sprint_reserved3; - if (A2DP_BuildInfoAptxHd(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, p_result_codec_config) != - A2DP_SUCCESS) { + if (!A2DP_BuildInfoAptxHd(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, p_result_codec_config)) { goto fail; } @@ -827,14 +821,17 @@ bool A2dpCodecConfigAptxHd::setCodecConfig(const uint8_t* p_peer_codec_info, boo // Create a local copy of the peer codec capability/config, and the // result codec config. if (is_capability) { - status = - A2DP_BuildInfoAptxHd(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_); + log::assert_that( + A2DP_BuildInfoAptxHd(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_), + "Failed to build media codec capabilities"); } else { - status = A2DP_BuildInfoAptxHd(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_config_); + log::assert_that( + A2DP_BuildInfoAptxHd(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_config_), + "Failed to build media codec capabilities"); } - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); - status = A2DP_BuildInfoAptxHd(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, ota_codec_config_); - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); + log::assert_that( + A2DP_BuildInfoAptxHd(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, ota_codec_config_), + "Failed to build media codec capabilities"); return true; fail: @@ -890,8 +887,9 @@ bool A2dpCodecConfigAptxHd::setPeerCodecCapabilities(const uint8_t* p_peer_codec codec_selectable_capability_.channel_mode |= BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO; } - status = A2DP_BuildInfoAptxHd(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_); - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); + log::assert_that( + A2DP_BuildInfoAptxHd(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_), + "Failed to build media codec capabilities"); return true; fail: diff --git a/system/stack/a2dp/a2dp_vendor_ldac.cc b/system/stack/a2dp/a2dp_vendor_ldac.cc index 1189ba456f..5a11e86507 100644 --- a/system/stack/a2dp/a2dp_vendor_ldac.cc +++ b/system/stack/a2dp/a2dp_vendor_ldac.cc @@ -108,10 +108,9 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityLdac(const tA2DP_LDAC_CIE* p_ // |p_ie| is a pointer to the LDAC Codec Information Element information. // The result is stored in |p_result|. Returns A2DP_SUCCESS on success, // otherwise the corresponding A2DP error status code. -static tA2DP_STATUS A2DP_BuildInfoLdac(uint8_t media_type, const tA2DP_LDAC_CIE* p_ie, - uint8_t* p_result) { +static bool A2DP_BuildInfoLdac(uint8_t media_type, const tA2DP_LDAC_CIE* p_ie, uint8_t* p_result) { if (p_ie == NULL || p_result == NULL) { - return A2DP_INVALID_PARAMS; + return false; } *p_result++ = A2DP_LDAC_CODEC_LEN; @@ -129,17 +128,17 @@ static tA2DP_STATUS A2DP_BuildInfoLdac(uint8_t media_type, const tA2DP_LDAC_CIE* // Sampling Frequency *p_result = (uint8_t)(p_ie->sampleRate & A2DP_LDAC_SAMPLING_FREQ_MASK); if (*p_result == 0) { - return A2DP_INVALID_PARAMS; + return false; } p_result++; // Channel Mode *p_result = (uint8_t)(p_ie->channelMode & A2DP_LDAC_CHANNEL_MODE_MASK); if (*p_result == 0) { - return A2DP_INVALID_PARAMS; + return false; } - return A2DP_SUCCESS; + return true; } // Parses the LDAC Media Codec Capabilities byte sequence beginning from the @@ -155,20 +154,20 @@ static tA2DP_STATUS A2DP_ParseInfoLdac(tA2DP_LDAC_CIE* p_ie, const uint8_t* p_co tA2DP_CODEC_TYPE codec_type; if (p_ie == NULL || p_codec_info == NULL) { - return A2DP_INVALID_PARAMS; + return AVDTP_UNSUPPORTED_CONFIGURATION; } // Check the codec capability length losc = *p_codec_info++; if (losc != A2DP_LDAC_CODEC_LEN) { - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } media_type = (*p_codec_info++) >> 4; codec_type = static_cast<tA2DP_CODEC_TYPE>(*p_codec_info++); /* Check the Media Type and Media Codec Type */ if (media_type != AVDT_MEDIA_TYPE_AUDIO || codec_type != A2DP_MEDIA_CT_NON_A2DP) { - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } // Check the Vendor ID and Codec ID */ @@ -179,7 +178,7 @@ static tA2DP_STATUS A2DP_ParseInfoLdac(tA2DP_LDAC_CIE* p_ie, const uint8_t* p_co p_ie->codecId = (*p_codec_info & 0x00FF) | (*(p_codec_info + 1) << 8 & 0xFF00); p_codec_info += 2; if (p_ie->vendorId != A2DP_LDAC_VENDOR_ID || p_ie->codecId != A2DP_LDAC_CODEC_ID) { - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } p_ie->sampleRate = *p_codec_info++ & A2DP_LDAC_SAMPLING_FREQ_MASK; @@ -189,20 +188,20 @@ static tA2DP_STATUS A2DP_ParseInfoLdac(tA2DP_LDAC_CIE* p_ie, const uint8_t* p_co // NOTE: The checks here are very liberal. We should be using more // pedantic checks specific to the SRC or SNK as specified in the spec. if (A2DP_BitsSet(p_ie->sampleRate) == A2DP_SET_ZERO_BIT) { - return A2DP_BAD_SAMP_FREQ; + return A2DP_INVALID_SAMPLING_FREQUENCY; } if (A2DP_BitsSet(p_ie->channelMode) == A2DP_SET_ZERO_BIT) { - return A2DP_BAD_CH_MODE; + return A2DP_INVALID_CHANNEL_MODE; } return A2DP_SUCCESS; } if (A2DP_BitsSet(p_ie->sampleRate) != A2DP_SET_ONE_BIT) { - return A2DP_BAD_SAMP_FREQ; + return A2DP_INVALID_SAMPLING_FREQUENCY; } if (A2DP_BitsSet(p_ie->channelMode) != A2DP_SET_ONE_BIT) { - return A2DP_BAD_CH_MODE; + return A2DP_INVALID_CHANNEL_MODE; } return A2DP_SUCCESS; @@ -276,12 +275,12 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityLdac(const tA2DP_LDAC_CIE* p_ /* sampling frequency */ if ((cfg_cie.sampleRate & p_cap->sampleRate) == 0) { - return A2DP_NS_SAMP_FREQ; + return A2DP_NOT_SUPPORTED_SAMPLING_FREQUENCY; } /* channel mode */ if ((cfg_cie.channelMode & p_cap->channelMode) == 0) { - return A2DP_NS_CH_MODE; + return A2DP_NOT_SUPPORTED_CHANNEL_MODE; } return A2DP_SUCCESS; @@ -592,17 +591,11 @@ const char* A2DP_VendorCodecIndexStrLdac(void) { return "LDAC"; } const char* A2DP_VendorCodecIndexStrLdacSink(void) { return "LDAC SINK"; } bool A2DP_VendorInitCodecConfigLdac(AvdtpSepConfig* p_cfg) { - if (A2DP_BuildInfoLdac(AVDT_MEDIA_TYPE_AUDIO, &a2dp_ldac_source_caps, p_cfg->codec_info) != - A2DP_SUCCESS) { - return false; - } - - return true; + return A2DP_BuildInfoLdac(AVDT_MEDIA_TYPE_AUDIO, &a2dp_ldac_source_caps, p_cfg->codec_info); } bool A2DP_VendorInitCodecConfigLdacSink(AvdtpSepConfig* p_cfg) { - return A2DP_BuildInfoLdac(AVDT_MEDIA_TYPE_AUDIO, &a2dp_ldac_sink_caps, p_cfg->codec_info) == - A2DP_SUCCESS; + return A2DP_BuildInfoLdac(AVDT_MEDIA_TYPE_AUDIO, &a2dp_ldac_sink_caps, p_cfg->codec_info); } A2dpCodecConfigLdacSource::A2dpCodecConfigLdacSource(btav_a2dp_codec_priority_t codec_priority) @@ -1197,8 +1190,7 @@ bool A2dpCodecConfigLdacBase::setCodecConfig(const uint8_t* p_peer_codec_info, b goto fail; } - if (A2DP_BuildInfoLdac(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, p_result_codec_config) != - A2DP_SUCCESS) { + if (!A2DP_BuildInfoLdac(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, p_result_codec_config)) { goto fail; } @@ -1221,13 +1213,16 @@ bool A2dpCodecConfigLdacBase::setCodecConfig(const uint8_t* p_peer_codec_info, b // Create a local copy of the peer codec capability, and the // result codec config. if (is_capability) { - status = A2DP_BuildInfoLdac(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_); + log::assert_that( + A2DP_BuildInfoLdac(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_), + "Failed to build media codec capabilities"); } else { - status = A2DP_BuildInfoLdac(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_config_); + log::assert_that( + A2DP_BuildInfoLdac(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_config_), + "Failed to build media codec capabilities"); } - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); - status = A2DP_BuildInfoLdac(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, ota_codec_config_); - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); + log::assert_that(A2DP_BuildInfoLdac(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, ota_codec_config_), + "Failed to build media codec capabilities"); return true; fail: @@ -1300,8 +1295,9 @@ bool A2dpCodecConfigLdacBase::setPeerCodecCapabilities(const uint8_t* p_peer_cod codec_selectable_capability_.channel_mode |= BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO; } - status = A2DP_BuildInfoLdac(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_); - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); + log::assert_that( + A2DP_BuildInfoLdac(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_), + "Failed to build media codec capabilities"); return true; fail: diff --git a/system/stack/a2dp/a2dp_vendor_opus.cc b/system/stack/a2dp/a2dp_vendor_opus.cc index b27eb63077..feb8ba1407 100644 --- a/system/stack/a2dp/a2dp_vendor_opus.cc +++ b/system/stack/a2dp/a2dp_vendor_opus.cc @@ -124,11 +124,10 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityOpus(const tA2DP_OPUS_CIE* p_ // |p_ie| is a pointer to the Opus Codec Information Element information. // The result is stored in |p_result|. Returns A2DP_SUCCESS on success, // otherwise the corresponding A2DP error status code. -static tA2DP_STATUS A2DP_BuildInfoOpus(uint8_t media_type, const tA2DP_OPUS_CIE* p_ie, - uint8_t* p_result) { +static bool A2DP_BuildInfoOpus(uint8_t media_type, const tA2DP_OPUS_CIE* p_ie, uint8_t* p_result) { if (p_ie == NULL || p_result == NULL) { log::error("invalid information element"); - return A2DP_INVALID_PARAMS; + return false; } *p_result++ = A2DP_OPUS_CODEC_LEN; @@ -147,24 +146,24 @@ static tA2DP_STATUS A2DP_BuildInfoOpus(uint8_t media_type, const tA2DP_OPUS_CIE* *p_result |= (uint8_t)(p_ie->channelMode) & A2DP_OPUS_CHANNEL_MODE_MASK; if ((*p_result & A2DP_OPUS_CHANNEL_MODE_MASK) == 0) { log::error("channelmode 0x{:X} setting failed", p_ie->channelMode); - return A2DP_INVALID_PARAMS; + return false; } *p_result |= ((uint8_t)(p_ie->future1) & A2DP_OPUS_FRAMESIZE_MASK); if ((*p_result & A2DP_OPUS_FRAMESIZE_MASK) == 0) { log::error("frameSize 0x{:X} setting failed", p_ie->future1); - return A2DP_INVALID_PARAMS; + return false; } *p_result |= ((uint8_t)(p_ie->sampleRate) & A2DP_OPUS_SAMPLING_FREQ_MASK); if ((*p_result & A2DP_OPUS_SAMPLING_FREQ_MASK) == 0) { log::error("samplerate 0x{:X} setting failed", p_ie->sampleRate); - return A2DP_INVALID_PARAMS; + return false; } p_result++; - return A2DP_SUCCESS; + return true; } // Parses the Opus Media Codec Capabilities byte sequence beginning from the @@ -181,14 +180,14 @@ static tA2DP_STATUS A2DP_ParseInfoOpus(tA2DP_OPUS_CIE* p_ie, const uint8_t* p_co if (p_ie == NULL || p_codec_info == NULL) { log::error("unable to parse information element"); - return A2DP_INVALID_PARAMS; + return AVDTP_UNSUPPORTED_CONFIGURATION; } // Check the codec capability length losc = *p_codec_info++; if (losc != A2DP_OPUS_CODEC_LEN) { log::error("invalid codec ie length {}", losc); - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } media_type = (*p_codec_info++) >> 4; @@ -196,7 +195,7 @@ static tA2DP_STATUS A2DP_ParseInfoOpus(tA2DP_OPUS_CIE* p_ie, const uint8_t* p_co /* Check the Media Type and Media Codec Type */ if (media_type != AVDT_MEDIA_TYPE_AUDIO || codec_type != A2DP_MEDIA_CT_NON_A2DP) { log::error("invalid codec"); - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } // Check the Vendor ID and Codec ID */ @@ -208,7 +207,7 @@ static tA2DP_STATUS A2DP_ParseInfoOpus(tA2DP_OPUS_CIE* p_ie, const uint8_t* p_co p_codec_info += 2; if (p_ie->vendorId != A2DP_OPUS_VENDOR_ID || p_ie->codecId != A2DP_OPUS_CODEC_ID) { log::error("wrong vendor or codec id"); - return A2DP_WRONG_CODEC; + return AVDTP_UNSUPPORTED_CONFIGURATION; } p_ie->channelMode = *p_codec_info & A2DP_OPUS_CHANNEL_MODE_MASK; @@ -221,11 +220,11 @@ static tA2DP_STATUS A2DP_ParseInfoOpus(tA2DP_OPUS_CIE* p_ie, const uint8_t* p_co // pedantic checks specific to the SRC or SNK as specified in the spec. if (A2DP_BitsSet(p_ie->sampleRate) == A2DP_SET_ZERO_BIT) { log::error("invalid sample rate 0x{:X}", p_ie->sampleRate); - return A2DP_BAD_SAMP_FREQ; + return A2DP_INVALID_SAMPLING_FREQUENCY; } if (A2DP_BitsSet(p_ie->channelMode) == A2DP_SET_ZERO_BIT) { log::error("invalid channel mode"); - return A2DP_BAD_CH_MODE; + return A2DP_INVALID_CHANNEL_MODE; } return A2DP_SUCCESS; @@ -233,11 +232,11 @@ static tA2DP_STATUS A2DP_ParseInfoOpus(tA2DP_OPUS_CIE* p_ie, const uint8_t* p_co if (A2DP_BitsSet(p_ie->sampleRate) != A2DP_SET_ONE_BIT) { log::error("invalid sampling frequency 0x{:X}", p_ie->sampleRate); - return A2DP_BAD_SAMP_FREQ; + return A2DP_INVALID_SAMPLING_FREQUENCY; } if (A2DP_BitsSet(p_ie->channelMode) != A2DP_SET_ONE_BIT) { log::error("invalid channel mode."); - return A2DP_BAD_CH_MODE; + return A2DP_INVALID_CHANNEL_MODE; } return A2DP_SUCCESS; @@ -313,17 +312,17 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityOpus(const tA2DP_OPUS_CIE* p_ /* sampling frequency */ if ((cfg_cie.sampleRate & p_cap->sampleRate) == 0) { - return A2DP_NS_SAMP_FREQ; + return A2DP_NOT_SUPPORTED_SAMPLING_FREQUENCY; } /* channel mode */ if ((cfg_cie.channelMode & p_cap->channelMode) == 0) { - return A2DP_NS_CH_MODE; + return A2DP_NOT_SUPPORTED_CHANNEL_MODE; } /* frameSize */ if ((cfg_cie.future1 & p_cap->future1) == 0) { - return A2DP_NS_FRAMESIZE; + return A2DP_INVALID_CODEC_PARAMETER; } return A2DP_SUCCESS; @@ -625,17 +624,11 @@ const char* A2DP_VendorCodecIndexStrOpus(void) { return "Opus"; } const char* A2DP_VendorCodecIndexStrOpusSink(void) { return "Opus SINK"; } bool A2DP_VendorInitCodecConfigOpus(AvdtpSepConfig* p_cfg) { - if (A2DP_BuildInfoOpus(AVDT_MEDIA_TYPE_AUDIO, &a2dp_opus_source_caps, p_cfg->codec_info) != - A2DP_SUCCESS) { - return false; - } - - return true; + return A2DP_BuildInfoOpus(AVDT_MEDIA_TYPE_AUDIO, &a2dp_opus_source_caps, p_cfg->codec_info); } bool A2DP_VendorInitCodecConfigOpusSink(AvdtpSepConfig* p_cfg) { - return A2DP_BuildInfoOpus(AVDT_MEDIA_TYPE_AUDIO, &a2dp_opus_sink_caps, p_cfg->codec_info) == - A2DP_SUCCESS; + return A2DP_BuildInfoOpus(AVDT_MEDIA_TYPE_AUDIO, &a2dp_opus_sink_caps, p_cfg->codec_info); } A2dpCodecConfigOpusSource::A2dpCodecConfigOpusSource(btav_a2dp_codec_priority_t codec_priority) @@ -1117,8 +1110,7 @@ bool A2dpCodecConfigOpusBase::setCodecConfig(const uint8_t* p_peer_codec_info, b goto fail; } - if (A2DP_BuildInfoOpus(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, p_result_codec_config) != - A2DP_SUCCESS) { + if (!A2DP_BuildInfoOpus(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, p_result_codec_config)) { log::error("failed to BuildInfoOpus for result_config_cie"); goto fail; } @@ -1142,14 +1134,17 @@ bool A2dpCodecConfigOpusBase::setCodecConfig(const uint8_t* p_peer_codec_info, b // Create a local copy of the peer codec capability, and the // result codec config. if (is_capability) { - status = A2DP_BuildInfoOpus(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_); + log::assert_that( + A2DP_BuildInfoOpus(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_), + "failed to build media codec capabilities"); } else { - status = A2DP_BuildInfoOpus(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_config_); + log::assert_that( + A2DP_BuildInfoOpus(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_config_), + "failed to build media codec capabilities"); } - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); - status = A2DP_BuildInfoOpus(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, ota_codec_config_); - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); + log::assert_that(A2DP_BuildInfoOpus(AVDT_MEDIA_TYPE_AUDIO, &result_config_cie, ota_codec_config_), + "failed to build media codec capabilities"); return true; fail: @@ -1205,8 +1200,9 @@ bool A2dpCodecConfigOpusBase::setPeerCodecCapabilities(const uint8_t* p_peer_cod } log::info("BuildInfoOpus for peer info cie for ota caps"); - status = A2DP_BuildInfoOpus(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_); - log::assert_that(status == A2DP_SUCCESS, "assert failed: status == A2DP_SUCCESS"); + log::assert_that( + A2DP_BuildInfoOpus(AVDT_MEDIA_TYPE_AUDIO, &peer_info_cie, ota_codec_peer_capability_), + "failed to build media codec capabilities"); return true; fail: diff --git a/system/stack/include/a2dp_api.h b/system/stack/include/a2dp_api.h index d5ca12571d..6e4f747c6c 100644 --- a/system/stack/include/a2dp_api.h +++ b/system/stack/include/a2dp_api.h @@ -28,7 +28,6 @@ #include <cstdint> #include "stack/include/a2dp_constants.h" -#include "stack/include/a2dp_error_codes.h" #include "stack/include/sdp_api.h" #include "types/raw_address.h" @@ -116,13 +115,12 @@ using tA2DP_FIND_CBACK = * Output Parameters: * None. * - * Returns A2DP_SUCCESS if function execution succeeded, - * A2DP_INVALID_PARAMS if bad parameters are given. - * A2DP_FAIL if function execution failed. + * Returns true if function execution succeeded, + * false if bad parameters are given or function execution failed. * *****************************************************************************/ -tA2DP_STATUS A2DP_AddRecord(uint16_t service_uuid, char* p_service_name, char* p_provider_name, - uint16_t features, uint32_t sdp_handle); +bool A2DP_AddRecord(uint16_t service_uuid, char* p_service_name, char* p_provider_name, + uint16_t features, uint32_t sdp_handle); /****************************************************************************** * @@ -154,7 +152,6 @@ tA2DP_STATUS A2DP_AddRecord(uint16_t service_uuid, char* p_service_name, char* p * None. * * Returns A2DP_SUCCESS if function execution succeeded, - * A2DP_INVALID_PARAMS if bad parameters are given. * A2DP_BUSY if discovery is already in progress. * A2DP_FAIL if function execution failed. * diff --git a/system/stack/include/a2dp_constants.h b/system/stack/include/a2dp_constants.h index 91203603f1..325fc2119f 100644 --- a/system/stack/include/a2dp_constants.h +++ b/system/stack/include/a2dp_constants.h @@ -59,7 +59,74 @@ enum tA2DP_CODEC_ID : uint64_t { A2DP_CODEC_ID_OPUS = 0x000100e0ff, }; +// Error codes returned in AVDTP reject signalling messages. +// The codes are specified from multiple sources as documented in the enum. +enum tA2DP_STATUS : uint8_t { + A2DP_SUCCESS = 0, + + // Custom error codes. + A2DP_FAIL = 0x0A, + A2DP_BUSY = 0x0B, + + // [AVDTP_1.3] 8.20.6.2 ERROR_CODE tables. + AVDTP_BAD_HEADER_FORMAT = 0x01, + AVDTP_BAD_LENGTH = 0x11, + AVDTP_BAD_ACP_SEID = 0x12, + AVDTP_SEP_IN_USE = 0x13, + AVDTP_SEP_NOT_IN_USE = 0x14, + AVDTP_BAD_SERV_CATEGORY = 0x17, + AVDTP_BAD_PAYLOAD_FORMAT = 0x18, + AVDTP_NOT_SUPPORTED_COMMAND = 0x19, + AVDTP_INVALID_CAPABILITIES = 0x1A, + AVDTP_BAD_RECOVERY_TYPE = 0x22, + AVDTP_BAD_MEDIA_TRANSPORT_FORMAT = 0x23, + AVDTP_BAD_RECOVERY_FORMAT = 0x25, + AVDTP_BAD_ROHC_FORMAT = 0x26, + AVDTP_BAD_CP_FORMAT = 0x27, + AVDTP_BAD_MULTIPLEXING_FORMAT = 0x28, + AVDTP_UNSUPPORTED_CONFIGURATION = 0x29, + AVDTP_BAD_STATE = 0x31, + + // [GAVDTP_1.3] 3.3 Error codes. + GAVDTP_BAD_SERVICE = 0x80, + GAVDTP_INSUFFICIENT_RESOURCES = 0x81, + + // [A2DP_1.3.2] 5.1.3 Error Codes. + A2DP_INVALID_CODEC_TYPE = 0xC1, + A2DP_NOT_SUPPORTED_CODEC_TYPE = 0xC2, + A2DP_INVALID_SAMPLING_FREQUENCY = 0xC3, + A2DP_NOT_SUPPORTED_SAMPLING_FREQUENCY = 0xC4, + A2DP_INVALID_CHANNEL_MODE = 0xC5, + A2DP_NOT_SUPPORTED_CHANNEL_MODE = 0xC6, + A2DP_INVALID_SUBBANDS = 0xC7, + A2DP_NOT_SUPPORTED_SUBBANDS = 0xC8, + A2DP_INVALID_ALLOCATION_METHOD = 0xC9, + A2DP_NOT_SUPPORTED_ALLOCATION_METHOD = 0xCA, + A2DP_INVALID_MINIMUM_BITPOOL_VALUE = 0xCB, + A2DP_NOT_SUPPORTED_MINIMUM_BITPOOL_VALUE = 0xCC, + A2DP_INVALID_MAXIMUM_BITPOOL_VALUE = 0xCD, + A2DP_NOT_SUPPORTED_MAXIMUM_BITPOOL_VALUE = 0xCE, + A2DP_INVALID_LAYER = 0xCF, + A2DP_NOT_SUPPORTED_LAYER = 0xD0, + A2DP_NOT_SUPPORTED_CRC = 0xD1, + A2DP_NOT_SUPPORTED_MPF = 0xD2, + A2DP_NOT_SUPPORTED_VBR = 0xD3, + A2DP_INVALID_BIT_RATE = 0xD4, + A2DP_NOT_SUPPORTED_BIT_RATE = 0xD5, + A2DP_INVALID_OBJECT_TYPE = 0xD6, + A2DP_NOT_SUPPORTED_OBJECT_TYPE = 0xD7, + A2DP_INVALID_CHANNELS = 0xD8, + A2DP_NOT_SUPPORTED_CHANNELS = 0xD9, + A2DP_INVALID_BLOCK_LENGTH = 0xDD, + A2DP_INVALID_CP_TYPE = 0xE0, + A2DP_INVALID_CP_FORMAT = 0xE1, + A2DP_INVALID_CODEC_PARAMETER = 0xE2, + A2DP_NOT_SUPPORTED_CODEC_PARAMETER = 0xE3, +}; + namespace fmt { template <> struct formatter<tA2DP_CODEC_TYPE> : enum_formatter<tA2DP_CODEC_TYPE> {}; +template <> +struct formatter<tA2DP_STATUS> : enum_formatter<tA2DP_STATUS> {}; } // namespace fmt diff --git a/system/stack/include/a2dp_error_codes.h b/system/stack/include/a2dp_error_codes.h deleted file mode 100644 index 298304684a..0000000000 --- a/system/stack/include/a2dp_error_codes.h +++ /dev/null @@ -1,136 +0,0 @@ -/****************************************************************************** - * - * Copyright 2000-2012 Broadcom Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ - -#pragma once - -#include <bluetooth/log.h> - -#include <cstdint> - -enum tA2DP_STATUS : uint8_t { - /* Success */ - A2DP_SUCCESS = 0, - - /* Failed */ - A2DP_FAIL = 0x0A, - - /* A2DP_FindService is already in progress */ - A2DP_BUSY = 0x0B, - - /* Bad parameters */ - A2DP_INVALID_PARAMS = 0x0C, - - /* Wrong codec info */ - A2DP_WRONG_CODEC = 0x0D, - - /* Media Codec Type is not valid */ - A2DP_BAD_CODEC_TYPE = 0xC1, - - /* Media Codec Type is not supported */ - A2DP_NS_CODEC_TYPE = 0xC2, - - /* Sampling Frequency is not valid or multiple values have been selected */ - A2DP_BAD_SAMP_FREQ = 0xC3, - - /* Sampling Frequency is not supported */ - A2DP_NS_SAMP_FREQ = 0xC4, - - /* Channel Mode is not valid or multiple values * have been selected */ - A2DP_BAD_CH_MODE = 0xC5, - - /* Channel Mode is not supported */ - A2DP_NS_CH_MODE = 0xC6, - - /* None or multiple values have been selected for Number of Subbands */ - A2DP_BAD_SUBBANDS = 0xC7, - - /* Number of Subbands is not supported */ - A2DP_NS_SUBBANDS = 0xC8, - - /* None or multiple values have been selected for Allocation Method */ - A2DP_BAD_ALLOC_METHOD = 0xC9, - - /* Allocation Method is not supported */ - A2DP_NS_ALLOC_METHOD = 0xCA, - - /* Minimum Bitpool Value is not valid */ - A2DP_BAD_MIN_BITPOOL = 0xCB, - - /* Minimum Bitpool Value is not supported */ - A2DP_NS_MIN_BITPOOL = 0xCC, - - /* Maximum Bitpool Value is not valid */ - A2DP_BAD_MAX_BITPOOL = 0xCD, - - /* Maximum Bitpool Value is not supported */ - A2DP_NS_MAX_BITPOOL = 0xCE, - - /* None or multiple values have been selected for Layer */ - A2DP_BAD_LAYER = 0xCF, - - /* Layer is not supported */ - A2DP_NS_LAYER = 0xD0, - - /* CRC is not supported */ - A2DP_NS_CRC = 0xD1, - - /* MPF-2 is not supported */ - A2DP_NS_MPF = 0xD2, - - /* VBR is not supported */ - A2DP_NS_VBR = 0xD3, - - /* None or multiple values have been selected for Bit Rate */ - A2DP_BAD_BIT_RATE = 0xD4, - - /* Bit Rate is not supported */ - A2DP_NS_BIT_RATE = 0xD5, - - /* Either 1) Object type is not valid (b3-b0) or 2) None or multiple values - * have been * selected for Object Type - */ - A2DP_BAD_OBJ_TYPE = 0xD6, - - /* Object type is not supported */ - A2DP_NS_OBJ_TYPE = 0xD7, - - /* None or multiple values have been selected for Channels */ - A2DP_BAD_CHANNEL = 0xD8, - - /* Channels is not supported */ - A2DP_NS_CHANNEL = 0xD9, - - /* None or multiple values have been selected for Block Length */ - A2DP_BAD_BLOCK_LEN = 0xDD, - - /* The requested CP Type is not supported. */ - A2DP_BAD_CP_TYPE = 0xE0, - - /* The format of Content Protection Service Capability/Content Protection - * Scheme Dependent Data is not correct. - */ - A2DP_BAD_CP_FORMAT = 0xE1, - - /* Invalid framesize */ - A2DP_NS_FRAMESIZE = 0xE2, -}; - -namespace fmt { -template <> -struct formatter<tA2DP_STATUS> : enum_formatter<tA2DP_STATUS> {}; -} // namespace fmt diff --git a/system/stack/include/avdt_api.h b/system/stack/include/avdt_api.h index 3a58796574..cb1a5846f4 100644 --- a/system/stack/include/avdt_api.h +++ b/system/stack/include/avdt_api.h @@ -226,20 +226,6 @@ typedef uint8_t AVDT_REPORT_TYPE; #define AVDT_ERR_REPORT_FMT 0x65 /* Invalid service category */ #define AVDT_ERR_SERVICE 0x80 -/* Insufficient resources */ -#define AVDT_ERR_RESOURCE 0x81 -/* Invalid Media Codec Type */ -#define AVDT_ERR_INVALID_MCT 0xC1 -/* Unsupported Media Codec Type */ -#define AVDT_ERR_UNSUP_MCT 0xC2 -/* Invalid Level */ -#define AVDT_ERR_INVALID_LEVEL 0xC3 -/* Unsupported Level */ -#define AVDT_ERR_UNSUP_LEVEL 0xC4 -/* Invalid Content Protection Type */ -#define AVDT_ERR_INVALID_CP 0xE0 -/* Invalid Content Protection format */ -#define AVDT_ERR_INVALID_FORMAT 0xE1 /* Additional error codes. This indicates error codes used by AVDTP * in addition to the ones defined in the specifications. diff --git a/system/test/mock/mock_btif_co_bta_av_co.h b/system/test/mock/mock_btif_co_bta_av_co.h index fefec8b5d8..b52c91ed86 100644 --- a/system/test/mock/mock_btif_co_bta_av_co.h +++ b/system/test/mock/mock_btif_co_bta_av_co.h @@ -31,7 +31,7 @@ #include "bta/include/bta_av_api.h" #include "include/hardware/bt_av.h" #include "stack/include/a2dp_codec_api.h" -#include "stack/include/a2dp_error_codes.h" +#include "stack/include/a2dp_constants.h" #include "stack/include/avdt_api.h" #include "stack/include/bt_hdr.h" #include "types/raw_address.h" diff --git a/system/test/mock/mock_stack_a2dp_api.cc b/system/test/mock/mock_stack_a2dp_api.cc index 23c71ae4f3..b62eed415d 100644 --- a/system/test/mock/mock_stack_a2dp_api.cc +++ b/system/test/mock/mock_stack_a2dp_api.cc @@ -24,9 +24,9 @@ #include "test/common/mock_functions.h" #include "types/raw_address.h" -tA2DP_STATUS A2DP_AddRecord(uint16_t /* service_uuid */, char* /* p_service_name */, - char* /* p_provider_name */, uint16_t /* features */, - uint32_t /* sdp_handle */) { +bool A2DP_AddRecord(uint16_t /* service_uuid */, char* /* p_service_name */, + char* /* p_provider_name */, uint16_t /* features */, + uint32_t /* sdp_handle */) { inc_func_call_count(__func__); return A2DP_SUCCESS; } |