Loading system/btif/co/bta_av_co.cc +2 −0 Original line number Diff line number Diff line Loading @@ -906,6 +906,8 @@ static tBTA_AV_CO_SINK* bta_av_co_audio_codec_selected( bta_av_co_save_new_codec_config(p_peer, new_codec_config, p_sink->num_protect, p_sink->protect_info); btif_dispatch_sm_event(BTIF_AV_SOURCE_CONFIG_UPDATED_EVT, NULL, 0); return p_sink; } Loading system/stack/a2dp/a2dp_sbc.cc +35 −40 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ #include <string.h> #include <base/logging.h> #include "a2dp_int.h" #include "a2dp_sbc_encoder.h" #include "bt_utils.h" #include "embdrv/sbc/encoder/include/sbc_encoder.h" Loading Loading @@ -107,8 +106,6 @@ static void A2DP_ParseMplHeaderSbc(uint8_t* p_src, bool* p_frag, bool* p_start, static tA2DP_STATUS A2DP_BuildInfoSbc(uint8_t media_type, const tA2DP_SBC_CIE* p_ie, uint8_t* p_result) { tA2DP_STATUS status; 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) || Loading @@ -121,9 +118,9 @@ static tA2DP_STATUS A2DP_BuildInfoSbc(uint8_t media_type, (p_ie->max_bitpool < A2DP_SBC_IE_MIN_BITPOOL) || (p_ie->max_bitpool > A2DP_SBC_IE_MAX_BITPOOL)) { /* if any unused bit is set */ status = A2DP_INVALID_PARAMS; } else { status = A2DP_SUCCESS; return A2DP_INVALID_PARAMS; } *p_result++ = A2DP_SBC_INFO_LEN; *p_result++ = (media_type << 4); *p_result++ = A2DP_MEDIA_CT_SBC; Loading @@ -135,8 +132,8 @@ static tA2DP_STATUS A2DP_BuildInfoSbc(uint8_t media_type, *p_result++ = p_ie->min_bitpool; *p_result = p_ie->max_bitpool; } return status; return A2DP_SUCCESS; } // Parses the SBC Media Codec Capabilities byte sequence beginning from the Loading @@ -148,7 +145,6 @@ static tA2DP_STATUS A2DP_BuildInfoSbc(uint8_t media_type, static tA2DP_STATUS A2DP_ParseInfoSbc(tA2DP_SBC_CIE* p_ie, const uint8_t* p_codec_info, bool is_capability) { tA2DP_STATUS status = A2DP_SUCCESS; uint8_t losc; uint8_t media_type; tA2DP_CODEC_TYPE codec_type; Loading @@ -174,32 +170,31 @@ static tA2DP_STATUS A2DP_ParseInfoSbc(tA2DP_SBC_CIE* p_ie, p_ie->alloc_method = *p_codec_info & A2DP_SBC_IE_ALLOC_MD_MSK; p_codec_info++; p_ie->min_bitpool = *p_codec_info++; p_ie->max_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) { status = A2DP_BAD_MIN_BITPOOL; return A2DP_BAD_MIN_BITPOOL; } 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) { status = A2DP_BAD_MAX_BITPOOL; return A2DP_BAD_MAX_BITPOOL; } if (is_capability) return status; if (is_capability) return A2DP_SUCCESS; if (A2DP_BitsSet(p_ie->samp_freq) != A2DP_SET_ONE_BIT) status = A2DP_BAD_SAMP_FREQ; if (A2DP_BitsSet(p_ie->ch_mode) != A2DP_SET_ONE_BIT) status = A2DP_BAD_CH_MODE; return A2DP_BAD_SAMP_FREQ; if (A2DP_BitsSet(p_ie->ch_mode) != A2DP_SET_ONE_BIT) return A2DP_BAD_CH_MODE; if (A2DP_BitsSet(p_ie->block_len) != A2DP_SET_ONE_BIT) status = A2DP_BAD_BLOCK_LEN; return A2DP_BAD_BLOCK_LEN; if (A2DP_BitsSet(p_ie->num_subbands) != A2DP_SET_ONE_BIT) status = A2DP_BAD_SUBBANDS; return A2DP_BAD_SUBBANDS; if (A2DP_BitsSet(p_ie->alloc_method) != A2DP_SET_ONE_BIT) status = A2DP_BAD_ALLOC_METHOD; return A2DP_BAD_ALLOC_METHOD; return status; return A2DP_SUCCESS; } // Build the SBC Media Payload Header. Loading Loading @@ -330,19 +325,19 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilitySbc( /* verify that each parameter is in range */ LOG_DEBUG(LOG_TAG, "FREQ peer: 0x%x, capability 0x%x", cfg_cie.samp_freq, p_cap->samp_freq); LOG_DEBUG(LOG_TAG, "CH_MODE peer: 0x%x, capability 0x%x", cfg_cie.ch_mode, p_cap->ch_mode); LOG_DEBUG(LOG_TAG, "BLOCK_LEN peer: 0x%x, capability 0x%x", cfg_cie.block_len, p_cap->block_len); LOG_DEBUG(LOG_TAG, "SUB_BAND peer: 0x%x, capability 0x%x", LOG_DEBUG(LOG_TAG, "%s: FREQ peer: 0x%x, capability 0x%x", __func__, cfg_cie.samp_freq, p_cap->samp_freq); LOG_DEBUG(LOG_TAG, "%s: CH_MODE peer: 0x%x, capability 0x%x", __func__, cfg_cie.ch_mode, p_cap->ch_mode); LOG_DEBUG(LOG_TAG, "%s: BLOCK_LEN peer: 0x%x, capability 0x%x", __func__, cfg_cie.block_len, p_cap->block_len); LOG_DEBUG(LOG_TAG, "%s: SUB_BAND peer: 0x%x, capability 0x%x", __func__, cfg_cie.num_subbands, p_cap->num_subbands); LOG_DEBUG(LOG_TAG, "ALLOC_METHOD peer: 0x%x, capability 0x%x", LOG_DEBUG(LOG_TAG, "%s: ALLOC_METHOD peer: 0x%x, capability 0x%x", __func__, cfg_cie.alloc_method, p_cap->alloc_method); LOG_DEBUG(LOG_TAG, "MIN_BitPool peer: 0x%x, capability 0x%x", LOG_DEBUG(LOG_TAG, "%s: MIN_BitPool peer: 0x%x, capability 0x%x", __func__, cfg_cie.min_bitpool, p_cap->min_bitpool); LOG_DEBUG(LOG_TAG, "MAX_BitPool peer: 0x%x, capability 0x%x", LOG_DEBUG(LOG_TAG, "%s: MAX_BitPool peer: 0x%x, capability 0x%x", __func__, cfg_cie.max_bitpool, p_cap->max_bitpool); /* sampling frequency */ Loading Loading @@ -965,8 +960,8 @@ bool A2DP_AdjustCodecSbc(uint8_t* p_codec_info) { // Updated the max bitpool if (cfg_cie.max_bitpool > A2DP_SBC_MAX_BITPOOL) { LOG_WARN(LOG_TAG, "Updated the SBC codec max bitpool from %d to %d", cfg_cie.max_bitpool, A2DP_SBC_MAX_BITPOOL); LOG_WARN(LOG_TAG, "%s: Updated the SBC codec max bitpool from %d to %d", __func__, cfg_cie.max_bitpool, A2DP_SBC_MAX_BITPOOL); cfg_cie.max_bitpool = A2DP_SBC_MAX_BITPOOL; } Loading system/stack/a2dp/a2dp_vendor_aptx.cc +31 −35 Original line number Diff line number Diff line Loading @@ -87,14 +87,12 @@ UNUSED_ATTR static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityAptx( static tA2DP_STATUS A2DP_BuildInfoAptx(uint8_t media_type, const tA2DP_APTX_CIE* p_ie, uint8_t* p_result) { tA2DP_STATUS status; if (p_ie == NULL || p_result == NULL) { status = A2DP_INVALID_PARAMS; } else { status = A2DP_SUCCESS; return A2DP_INVALID_PARAMS; } *p_result++ = A2DP_APTX_CODEC_LEN; *p_result++ = media_type; *p_result++ = (media_type << 4); *p_result++ = A2DP_MEDIA_CT_NON_A2DP; *p_result++ = (uint8_t)(p_ie->vendorId & 0x000000FF); *p_result++ = (uint8_t)((p_ie->vendorId & 0x0000FF00) >> 8); Loading @@ -103,8 +101,8 @@ static tA2DP_STATUS A2DP_BuildInfoAptx(uint8_t media_type, *p_result++ = (uint8_t)(p_ie->codecId & 0x00FF); *p_result++ = (uint8_t)((p_ie->codecId & 0xFF00) >> 8); *p_result++ = p_ie->sampleRate | p_ie->channelMode; } return status; return A2DP_SUCCESS; } // Parses the aptX Media Codec Capabilities byte sequence beginning from the Loading @@ -116,7 +114,6 @@ static tA2DP_STATUS A2DP_BuildInfoAptx(uint8_t media_type, static tA2DP_STATUS A2DP_ParseInfoAptx(tA2DP_APTX_CIE* p_ie, const uint8_t* p_codec_info, bool is_capability) { tA2DP_STATUS status = A2DP_SUCCESS; uint8_t losc; uint8_t media_type; tA2DP_CODEC_TYPE codec_type; Loading @@ -140,10 +137,10 @@ static tA2DP_STATUS A2DP_ParseInfoAptx(tA2DP_APTX_CIE* p_ie, (*(p_codec_info + 1) << 8 & 0x0000FF00) | (*(p_codec_info + 2) << 16 & 0x00FF0000) | (*(p_codec_info + 3) << 24 & 0xFF000000); p_codec_info = p_codec_info + 4; p_codec_info += 4; p_ie->codecId = (*p_codec_info & 0x00FF) | (*(p_codec_info + 1) << 8 & 0xFF00); p_codec_info = p_codec_info + 2; p_codec_info += 2; if (p_ie->vendorId != A2DP_APTX_VENDOR_ID || p_ie->codecId != A2DP_APTX_CODEC_ID_BLUETOOTH) { return A2DP_WRONG_CODEC; Loading @@ -151,17 +148,16 @@ static tA2DP_STATUS A2DP_ParseInfoAptx(tA2DP_APTX_CIE* p_ie, p_ie->channelMode = *p_codec_info & 0x0F; p_ie->sampleRate = *p_codec_info & 0xF0; p_codec_info++; status = A2DP_SUCCESS; if (is_capability) return status; if (is_capability) return A2DP_SUCCESS; if (A2DP_BitsSet(p_ie->sampleRate) != A2DP_SET_ONE_BIT) status = A2DP_BAD_SAMP_FREQ; return A2DP_BAD_SAMP_FREQ; if (A2DP_BitsSet(p_ie->channelMode) != A2DP_SET_ONE_BIT) status = A2DP_BAD_CH_MODE; return A2DP_BAD_CH_MODE; return status; return A2DP_SUCCESS; } bool A2DP_IsVendorSourceCodecValidAptx(const uint8_t* p_codec_info) { Loading Loading @@ -204,10 +200,10 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityAptx( /* verify that each parameter is in range */ LOG_DEBUG(LOG_TAG, "FREQ peer: 0x%x, capability 0x%x", cfg_cie.sampleRate, p_cap->sampleRate); LOG_DEBUG(LOG_TAG, "CH_MODE peer: 0x%x, capability 0x%x", cfg_cie.channelMode, p_cap->channelMode); LOG_DEBUG(LOG_TAG, "%s: FREQ peer: 0x%x, capability 0x%x", __func__, cfg_cie.sampleRate, p_cap->sampleRate); LOG_DEBUG(LOG_TAG, "%s: CH_MODE peer: 0x%x, capability 0x%x", __func__, cfg_cie.channelMode, p_cap->channelMode); /* sampling frequency */ if ((cfg_cie.sampleRate & p_cap->sampleRate) == 0) return A2DP_NS_SAMP_FREQ; Loading Loading @@ -331,7 +327,7 @@ int A2DP_VendorGetTrackChannelCountAptx(const uint8_t* p_codec_info) { return -1; } bool A2DP_VendorGetPacketTimestampAptx(const uint8_t* p_codec_info, bool A2DP_VendorGetPacketTimestampAptx(UNUSED_ATTR const uint8_t* p_codec_info, const uint8_t* p_data, uint32_t* p_timestamp) { // TODO: Is this function really codec-specific? Loading Loading @@ -359,18 +355,18 @@ void A2DP_VendorDumpCodecInfoAptx(const uint8_t* p_codec_info) { } LOG_DEBUG(LOG_TAG, "\tsamp_freq: 0x%x", aptx_cie.sampleRate); if (aptx_cie.sampleRate == A2DP_APTX_SAMPLERATE_44100) { if (aptx_cie.sampleRate & A2DP_APTX_SAMPLERATE_44100) { LOG_DEBUG(LOG_TAG, "\tsamp_freq: (44100)"); } if (aptx_cie.sampleRate == A2DP_APTX_SAMPLERATE_48000) { if (aptx_cie.sampleRate & A2DP_APTX_SAMPLERATE_48000) { LOG_DEBUG(LOG_TAG, "\tsamp_freq: (48000)"); } LOG_DEBUG(LOG_TAG, "\tch_mode: 0x%x", aptx_cie.channelMode); if (aptx_cie.channelMode == A2DP_APTX_CHANNELS_MONO) { if (aptx_cie.channelMode & A2DP_APTX_CHANNELS_MONO) { LOG_DEBUG(LOG_TAG, "\tch_mode: (Mono)"); } if (aptx_cie.channelMode == A2DP_APTX_CHANNELS_STEREO) { if (aptx_cie.channelMode & A2DP_APTX_CHANNELS_STEREO) { LOG_DEBUG(LOG_TAG, "\tch_mode: (Stereo)"); } } Loading system/stack/a2dp/a2dp_vendor_aptx_encoder.cc +1 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ // // The aptX encoder shared library, and the functions to use // static const char* APTX_ENCODER_LIB_NAME = "libaptX.so"; static const char* APTX_ENCODER_LIB_NAME = "libaptX_encoder.so"; static void* aptx_encoder_lib_handle = NULL; static const char* APTX_ENCODER_INIT_NAME = "aptxbtenc_init"; Loading system/stack/a2dp/a2dp_vendor_aptx_hd.cc +37 −42 Original line number Diff line number Diff line Loading @@ -98,14 +98,12 @@ UNUSED_ATTR static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityAptxHd( static tA2DP_STATUS A2DP_BuildInfoAptxHd(uint8_t media_type, const tA2DP_APTX_HD_CIE* p_ie, uint8_t* p_result) { tA2DP_STATUS status; if (p_ie == NULL || p_result == NULL) { status = A2DP_INVALID_PARAMS; } else { status = A2DP_SUCCESS; return A2DP_INVALID_PARAMS; } *p_result++ = A2DP_APTX_HD_CODEC_LEN; *p_result++ = media_type; *p_result++ = (media_type << 4); *p_result++ = A2DP_MEDIA_CT_NON_A2DP; *p_result++ = (uint8_t)(p_ie->vendorId & 0x000000FF); *p_result++ = (uint8_t)((p_ie->vendorId & 0x0000FF00) >> 8); Loading @@ -118,8 +116,8 @@ static tA2DP_STATUS A2DP_BuildInfoAptxHd(uint8_t media_type, *p_result++ = p_ie->acl_sprint_reserved1; *p_result++ = p_ie->acl_sprint_reserved2; *p_result++ = p_ie->acl_sprint_reserved3; } return status; return A2DP_SUCCESS; } // Parses the aptX-HD Media Codec Capabilities byte sequence beginning from the Loading @@ -131,7 +129,6 @@ static tA2DP_STATUS A2DP_BuildInfoAptxHd(uint8_t media_type, static tA2DP_STATUS A2DP_ParseInfoAptxHd(tA2DP_APTX_HD_CIE* p_ie, const uint8_t* p_codec_info, bool is_capability) { tA2DP_STATUS status = A2DP_SUCCESS; uint8_t losc; uint8_t media_type; tA2DP_CODEC_TYPE codec_type; Loading @@ -155,10 +152,10 @@ static tA2DP_STATUS A2DP_ParseInfoAptxHd(tA2DP_APTX_HD_CIE* p_ie, (*(p_codec_info + 1) << 8 & 0x0000FF00) | (*(p_codec_info + 2) << 16 & 0x00FF0000) | (*(p_codec_info + 3) << 24 & 0xFF000000); p_codec_info = p_codec_info + 4; p_codec_info += 4; p_ie->codecId = (*p_codec_info & 0x00FF) | (*(p_codec_info + 1) << 8 & 0xFF00); p_codec_info = p_codec_info + 2; 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; Loading @@ -166,23 +163,21 @@ static tA2DP_STATUS A2DP_ParseInfoAptxHd(tA2DP_APTX_HD_CIE* p_ie, p_ie->channelMode = *p_codec_info & 0x0F; p_ie->sampleRate = *p_codec_info & 0xF0; p_codec_info++; p_ie->acl_sprint_reserved0 = *(p_codec_info++); p_ie->acl_sprint_reserved1 = *(p_codec_info++); p_ie->acl_sprint_reserved2 = *(p_codec_info++); p_ie->acl_sprint_reserved3 = *(p_codec_info++); status = A2DP_SUCCESS; if (is_capability) return status; if (is_capability) return A2DP_SUCCESS; if (A2DP_BitsSet(p_ie->sampleRate) != A2DP_SET_ONE_BIT) status = A2DP_BAD_SAMP_FREQ; return A2DP_BAD_SAMP_FREQ; if (A2DP_BitsSet(p_ie->channelMode) != A2DP_SET_ONE_BIT) status = A2DP_BAD_CH_MODE; return A2DP_BAD_CH_MODE; return status; return A2DP_SUCCESS; } bool A2DP_IsVendorSourceCodecValidAptxHd(const uint8_t* p_codec_info) { Loading Loading @@ -227,10 +222,10 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityAptxHd( /* verify that each parameter is in range */ LOG_DEBUG(LOG_TAG, "FREQ peer: 0x%x, capability 0x%x", cfg_cie.sampleRate, p_cap->sampleRate); LOG_DEBUG(LOG_TAG, "CH_MODE peer: 0x%x, capability 0x%x", cfg_cie.channelMode, p_cap->channelMode); LOG_DEBUG(LOG_TAG, "%s: FREQ peer: 0x%x, capability 0x%x", __func__, cfg_cie.sampleRate, p_cap->sampleRate); LOG_DEBUG(LOG_TAG, "%s: CH_MODE peer: 0x%x, capability 0x%x", __func__, cfg_cie.channelMode, p_cap->channelMode); /* sampling frequency */ if ((cfg_cie.sampleRate & p_cap->sampleRate) == 0) return A2DP_NS_SAMP_FREQ; Loading Loading @@ -353,8 +348,8 @@ int A2DP_VendorGetTrackChannelCountAptxHd(const uint8_t* p_codec_info) { return -1; } bool A2DP_VendorGetPacketTimestampAptxHd(const uint8_t* p_codec_info, const uint8_t* p_data, bool A2DP_VendorGetPacketTimestampAptxHd( UNUSED_ATTR const uint8_t* p_codec_info, const uint8_t* p_data, uint32_t* p_timestamp) { // TODO: Is this function really codec-specific? *p_timestamp = *(const uint32_t*)p_data; Loading Loading @@ -382,18 +377,18 @@ void A2DP_VendorDumpCodecInfoAptxHd(const uint8_t* p_codec_info) { } LOG_DEBUG(LOG_TAG, "\tsamp_freq: 0x%x", aptx_hd_cie.sampleRate); if (aptx_hd_cie.sampleRate == A2DP_APTX_HD_SAMPLERATE_44100) { if (aptx_hd_cie.sampleRate & A2DP_APTX_HD_SAMPLERATE_44100) { LOG_DEBUG(LOG_TAG, "\tsamp_freq: (44100)"); } if (aptx_hd_cie.sampleRate == A2DP_APTX_HD_SAMPLERATE_48000) { if (aptx_hd_cie.sampleRate & A2DP_APTX_HD_SAMPLERATE_48000) { LOG_DEBUG(LOG_TAG, "\tsamp_freq: (48000)"); } LOG_DEBUG(LOG_TAG, "\tch_mode: 0x%x", aptx_hd_cie.channelMode); if (aptx_hd_cie.channelMode == A2DP_APTX_HD_CHANNELS_MONO) { if (aptx_hd_cie.channelMode & A2DP_APTX_HD_CHANNELS_MONO) { LOG_DEBUG(LOG_TAG, "\tch_mode: (Mono)"); } if (aptx_hd_cie.channelMode == A2DP_APTX_HD_CHANNELS_STEREO) { if (aptx_hd_cie.channelMode & A2DP_APTX_HD_CHANNELS_STEREO) { LOG_DEBUG(LOG_TAG, "\tch_mode: (Stereo)"); } } Loading Loading
system/btif/co/bta_av_co.cc +2 −0 Original line number Diff line number Diff line Loading @@ -906,6 +906,8 @@ static tBTA_AV_CO_SINK* bta_av_co_audio_codec_selected( bta_av_co_save_new_codec_config(p_peer, new_codec_config, p_sink->num_protect, p_sink->protect_info); btif_dispatch_sm_event(BTIF_AV_SOURCE_CONFIG_UPDATED_EVT, NULL, 0); return p_sink; } Loading
system/stack/a2dp/a2dp_sbc.cc +35 −40 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ #include <string.h> #include <base/logging.h> #include "a2dp_int.h" #include "a2dp_sbc_encoder.h" #include "bt_utils.h" #include "embdrv/sbc/encoder/include/sbc_encoder.h" Loading Loading @@ -107,8 +106,6 @@ static void A2DP_ParseMplHeaderSbc(uint8_t* p_src, bool* p_frag, bool* p_start, static tA2DP_STATUS A2DP_BuildInfoSbc(uint8_t media_type, const tA2DP_SBC_CIE* p_ie, uint8_t* p_result) { tA2DP_STATUS status; 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) || Loading @@ -121,9 +118,9 @@ static tA2DP_STATUS A2DP_BuildInfoSbc(uint8_t media_type, (p_ie->max_bitpool < A2DP_SBC_IE_MIN_BITPOOL) || (p_ie->max_bitpool > A2DP_SBC_IE_MAX_BITPOOL)) { /* if any unused bit is set */ status = A2DP_INVALID_PARAMS; } else { status = A2DP_SUCCESS; return A2DP_INVALID_PARAMS; } *p_result++ = A2DP_SBC_INFO_LEN; *p_result++ = (media_type << 4); *p_result++ = A2DP_MEDIA_CT_SBC; Loading @@ -135,8 +132,8 @@ static tA2DP_STATUS A2DP_BuildInfoSbc(uint8_t media_type, *p_result++ = p_ie->min_bitpool; *p_result = p_ie->max_bitpool; } return status; return A2DP_SUCCESS; } // Parses the SBC Media Codec Capabilities byte sequence beginning from the Loading @@ -148,7 +145,6 @@ static tA2DP_STATUS A2DP_BuildInfoSbc(uint8_t media_type, static tA2DP_STATUS A2DP_ParseInfoSbc(tA2DP_SBC_CIE* p_ie, const uint8_t* p_codec_info, bool is_capability) { tA2DP_STATUS status = A2DP_SUCCESS; uint8_t losc; uint8_t media_type; tA2DP_CODEC_TYPE codec_type; Loading @@ -174,32 +170,31 @@ static tA2DP_STATUS A2DP_ParseInfoSbc(tA2DP_SBC_CIE* p_ie, p_ie->alloc_method = *p_codec_info & A2DP_SBC_IE_ALLOC_MD_MSK; p_codec_info++; p_ie->min_bitpool = *p_codec_info++; p_ie->max_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) { status = A2DP_BAD_MIN_BITPOOL; return A2DP_BAD_MIN_BITPOOL; } 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) { status = A2DP_BAD_MAX_BITPOOL; return A2DP_BAD_MAX_BITPOOL; } if (is_capability) return status; if (is_capability) return A2DP_SUCCESS; if (A2DP_BitsSet(p_ie->samp_freq) != A2DP_SET_ONE_BIT) status = A2DP_BAD_SAMP_FREQ; if (A2DP_BitsSet(p_ie->ch_mode) != A2DP_SET_ONE_BIT) status = A2DP_BAD_CH_MODE; return A2DP_BAD_SAMP_FREQ; if (A2DP_BitsSet(p_ie->ch_mode) != A2DP_SET_ONE_BIT) return A2DP_BAD_CH_MODE; if (A2DP_BitsSet(p_ie->block_len) != A2DP_SET_ONE_BIT) status = A2DP_BAD_BLOCK_LEN; return A2DP_BAD_BLOCK_LEN; if (A2DP_BitsSet(p_ie->num_subbands) != A2DP_SET_ONE_BIT) status = A2DP_BAD_SUBBANDS; return A2DP_BAD_SUBBANDS; if (A2DP_BitsSet(p_ie->alloc_method) != A2DP_SET_ONE_BIT) status = A2DP_BAD_ALLOC_METHOD; return A2DP_BAD_ALLOC_METHOD; return status; return A2DP_SUCCESS; } // Build the SBC Media Payload Header. Loading Loading @@ -330,19 +325,19 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilitySbc( /* verify that each parameter is in range */ LOG_DEBUG(LOG_TAG, "FREQ peer: 0x%x, capability 0x%x", cfg_cie.samp_freq, p_cap->samp_freq); LOG_DEBUG(LOG_TAG, "CH_MODE peer: 0x%x, capability 0x%x", cfg_cie.ch_mode, p_cap->ch_mode); LOG_DEBUG(LOG_TAG, "BLOCK_LEN peer: 0x%x, capability 0x%x", cfg_cie.block_len, p_cap->block_len); LOG_DEBUG(LOG_TAG, "SUB_BAND peer: 0x%x, capability 0x%x", LOG_DEBUG(LOG_TAG, "%s: FREQ peer: 0x%x, capability 0x%x", __func__, cfg_cie.samp_freq, p_cap->samp_freq); LOG_DEBUG(LOG_TAG, "%s: CH_MODE peer: 0x%x, capability 0x%x", __func__, cfg_cie.ch_mode, p_cap->ch_mode); LOG_DEBUG(LOG_TAG, "%s: BLOCK_LEN peer: 0x%x, capability 0x%x", __func__, cfg_cie.block_len, p_cap->block_len); LOG_DEBUG(LOG_TAG, "%s: SUB_BAND peer: 0x%x, capability 0x%x", __func__, cfg_cie.num_subbands, p_cap->num_subbands); LOG_DEBUG(LOG_TAG, "ALLOC_METHOD peer: 0x%x, capability 0x%x", LOG_DEBUG(LOG_TAG, "%s: ALLOC_METHOD peer: 0x%x, capability 0x%x", __func__, cfg_cie.alloc_method, p_cap->alloc_method); LOG_DEBUG(LOG_TAG, "MIN_BitPool peer: 0x%x, capability 0x%x", LOG_DEBUG(LOG_TAG, "%s: MIN_BitPool peer: 0x%x, capability 0x%x", __func__, cfg_cie.min_bitpool, p_cap->min_bitpool); LOG_DEBUG(LOG_TAG, "MAX_BitPool peer: 0x%x, capability 0x%x", LOG_DEBUG(LOG_TAG, "%s: MAX_BitPool peer: 0x%x, capability 0x%x", __func__, cfg_cie.max_bitpool, p_cap->max_bitpool); /* sampling frequency */ Loading Loading @@ -965,8 +960,8 @@ bool A2DP_AdjustCodecSbc(uint8_t* p_codec_info) { // Updated the max bitpool if (cfg_cie.max_bitpool > A2DP_SBC_MAX_BITPOOL) { LOG_WARN(LOG_TAG, "Updated the SBC codec max bitpool from %d to %d", cfg_cie.max_bitpool, A2DP_SBC_MAX_BITPOOL); LOG_WARN(LOG_TAG, "%s: Updated the SBC codec max bitpool from %d to %d", __func__, cfg_cie.max_bitpool, A2DP_SBC_MAX_BITPOOL); cfg_cie.max_bitpool = A2DP_SBC_MAX_BITPOOL; } Loading
system/stack/a2dp/a2dp_vendor_aptx.cc +31 −35 Original line number Diff line number Diff line Loading @@ -87,14 +87,12 @@ UNUSED_ATTR static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityAptx( static tA2DP_STATUS A2DP_BuildInfoAptx(uint8_t media_type, const tA2DP_APTX_CIE* p_ie, uint8_t* p_result) { tA2DP_STATUS status; if (p_ie == NULL || p_result == NULL) { status = A2DP_INVALID_PARAMS; } else { status = A2DP_SUCCESS; return A2DP_INVALID_PARAMS; } *p_result++ = A2DP_APTX_CODEC_LEN; *p_result++ = media_type; *p_result++ = (media_type << 4); *p_result++ = A2DP_MEDIA_CT_NON_A2DP; *p_result++ = (uint8_t)(p_ie->vendorId & 0x000000FF); *p_result++ = (uint8_t)((p_ie->vendorId & 0x0000FF00) >> 8); Loading @@ -103,8 +101,8 @@ static tA2DP_STATUS A2DP_BuildInfoAptx(uint8_t media_type, *p_result++ = (uint8_t)(p_ie->codecId & 0x00FF); *p_result++ = (uint8_t)((p_ie->codecId & 0xFF00) >> 8); *p_result++ = p_ie->sampleRate | p_ie->channelMode; } return status; return A2DP_SUCCESS; } // Parses the aptX Media Codec Capabilities byte sequence beginning from the Loading @@ -116,7 +114,6 @@ static tA2DP_STATUS A2DP_BuildInfoAptx(uint8_t media_type, static tA2DP_STATUS A2DP_ParseInfoAptx(tA2DP_APTX_CIE* p_ie, const uint8_t* p_codec_info, bool is_capability) { tA2DP_STATUS status = A2DP_SUCCESS; uint8_t losc; uint8_t media_type; tA2DP_CODEC_TYPE codec_type; Loading @@ -140,10 +137,10 @@ static tA2DP_STATUS A2DP_ParseInfoAptx(tA2DP_APTX_CIE* p_ie, (*(p_codec_info + 1) << 8 & 0x0000FF00) | (*(p_codec_info + 2) << 16 & 0x00FF0000) | (*(p_codec_info + 3) << 24 & 0xFF000000); p_codec_info = p_codec_info + 4; p_codec_info += 4; p_ie->codecId = (*p_codec_info & 0x00FF) | (*(p_codec_info + 1) << 8 & 0xFF00); p_codec_info = p_codec_info + 2; p_codec_info += 2; if (p_ie->vendorId != A2DP_APTX_VENDOR_ID || p_ie->codecId != A2DP_APTX_CODEC_ID_BLUETOOTH) { return A2DP_WRONG_CODEC; Loading @@ -151,17 +148,16 @@ static tA2DP_STATUS A2DP_ParseInfoAptx(tA2DP_APTX_CIE* p_ie, p_ie->channelMode = *p_codec_info & 0x0F; p_ie->sampleRate = *p_codec_info & 0xF0; p_codec_info++; status = A2DP_SUCCESS; if (is_capability) return status; if (is_capability) return A2DP_SUCCESS; if (A2DP_BitsSet(p_ie->sampleRate) != A2DP_SET_ONE_BIT) status = A2DP_BAD_SAMP_FREQ; return A2DP_BAD_SAMP_FREQ; if (A2DP_BitsSet(p_ie->channelMode) != A2DP_SET_ONE_BIT) status = A2DP_BAD_CH_MODE; return A2DP_BAD_CH_MODE; return status; return A2DP_SUCCESS; } bool A2DP_IsVendorSourceCodecValidAptx(const uint8_t* p_codec_info) { Loading Loading @@ -204,10 +200,10 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityAptx( /* verify that each parameter is in range */ LOG_DEBUG(LOG_TAG, "FREQ peer: 0x%x, capability 0x%x", cfg_cie.sampleRate, p_cap->sampleRate); LOG_DEBUG(LOG_TAG, "CH_MODE peer: 0x%x, capability 0x%x", cfg_cie.channelMode, p_cap->channelMode); LOG_DEBUG(LOG_TAG, "%s: FREQ peer: 0x%x, capability 0x%x", __func__, cfg_cie.sampleRate, p_cap->sampleRate); LOG_DEBUG(LOG_TAG, "%s: CH_MODE peer: 0x%x, capability 0x%x", __func__, cfg_cie.channelMode, p_cap->channelMode); /* sampling frequency */ if ((cfg_cie.sampleRate & p_cap->sampleRate) == 0) return A2DP_NS_SAMP_FREQ; Loading Loading @@ -331,7 +327,7 @@ int A2DP_VendorGetTrackChannelCountAptx(const uint8_t* p_codec_info) { return -1; } bool A2DP_VendorGetPacketTimestampAptx(const uint8_t* p_codec_info, bool A2DP_VendorGetPacketTimestampAptx(UNUSED_ATTR const uint8_t* p_codec_info, const uint8_t* p_data, uint32_t* p_timestamp) { // TODO: Is this function really codec-specific? Loading Loading @@ -359,18 +355,18 @@ void A2DP_VendorDumpCodecInfoAptx(const uint8_t* p_codec_info) { } LOG_DEBUG(LOG_TAG, "\tsamp_freq: 0x%x", aptx_cie.sampleRate); if (aptx_cie.sampleRate == A2DP_APTX_SAMPLERATE_44100) { if (aptx_cie.sampleRate & A2DP_APTX_SAMPLERATE_44100) { LOG_DEBUG(LOG_TAG, "\tsamp_freq: (44100)"); } if (aptx_cie.sampleRate == A2DP_APTX_SAMPLERATE_48000) { if (aptx_cie.sampleRate & A2DP_APTX_SAMPLERATE_48000) { LOG_DEBUG(LOG_TAG, "\tsamp_freq: (48000)"); } LOG_DEBUG(LOG_TAG, "\tch_mode: 0x%x", aptx_cie.channelMode); if (aptx_cie.channelMode == A2DP_APTX_CHANNELS_MONO) { if (aptx_cie.channelMode & A2DP_APTX_CHANNELS_MONO) { LOG_DEBUG(LOG_TAG, "\tch_mode: (Mono)"); } if (aptx_cie.channelMode == A2DP_APTX_CHANNELS_STEREO) { if (aptx_cie.channelMode & A2DP_APTX_CHANNELS_STEREO) { LOG_DEBUG(LOG_TAG, "\tch_mode: (Stereo)"); } } Loading
system/stack/a2dp/a2dp_vendor_aptx_encoder.cc +1 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ // // The aptX encoder shared library, and the functions to use // static const char* APTX_ENCODER_LIB_NAME = "libaptX.so"; static const char* APTX_ENCODER_LIB_NAME = "libaptX_encoder.so"; static void* aptx_encoder_lib_handle = NULL; static const char* APTX_ENCODER_INIT_NAME = "aptxbtenc_init"; Loading
system/stack/a2dp/a2dp_vendor_aptx_hd.cc +37 −42 Original line number Diff line number Diff line Loading @@ -98,14 +98,12 @@ UNUSED_ATTR static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityAptxHd( static tA2DP_STATUS A2DP_BuildInfoAptxHd(uint8_t media_type, const tA2DP_APTX_HD_CIE* p_ie, uint8_t* p_result) { tA2DP_STATUS status; if (p_ie == NULL || p_result == NULL) { status = A2DP_INVALID_PARAMS; } else { status = A2DP_SUCCESS; return A2DP_INVALID_PARAMS; } *p_result++ = A2DP_APTX_HD_CODEC_LEN; *p_result++ = media_type; *p_result++ = (media_type << 4); *p_result++ = A2DP_MEDIA_CT_NON_A2DP; *p_result++ = (uint8_t)(p_ie->vendorId & 0x000000FF); *p_result++ = (uint8_t)((p_ie->vendorId & 0x0000FF00) >> 8); Loading @@ -118,8 +116,8 @@ static tA2DP_STATUS A2DP_BuildInfoAptxHd(uint8_t media_type, *p_result++ = p_ie->acl_sprint_reserved1; *p_result++ = p_ie->acl_sprint_reserved2; *p_result++ = p_ie->acl_sprint_reserved3; } return status; return A2DP_SUCCESS; } // Parses the aptX-HD Media Codec Capabilities byte sequence beginning from the Loading @@ -131,7 +129,6 @@ static tA2DP_STATUS A2DP_BuildInfoAptxHd(uint8_t media_type, static tA2DP_STATUS A2DP_ParseInfoAptxHd(tA2DP_APTX_HD_CIE* p_ie, const uint8_t* p_codec_info, bool is_capability) { tA2DP_STATUS status = A2DP_SUCCESS; uint8_t losc; uint8_t media_type; tA2DP_CODEC_TYPE codec_type; Loading @@ -155,10 +152,10 @@ static tA2DP_STATUS A2DP_ParseInfoAptxHd(tA2DP_APTX_HD_CIE* p_ie, (*(p_codec_info + 1) << 8 & 0x0000FF00) | (*(p_codec_info + 2) << 16 & 0x00FF0000) | (*(p_codec_info + 3) << 24 & 0xFF000000); p_codec_info = p_codec_info + 4; p_codec_info += 4; p_ie->codecId = (*p_codec_info & 0x00FF) | (*(p_codec_info + 1) << 8 & 0xFF00); p_codec_info = p_codec_info + 2; 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; Loading @@ -166,23 +163,21 @@ static tA2DP_STATUS A2DP_ParseInfoAptxHd(tA2DP_APTX_HD_CIE* p_ie, p_ie->channelMode = *p_codec_info & 0x0F; p_ie->sampleRate = *p_codec_info & 0xF0; p_codec_info++; p_ie->acl_sprint_reserved0 = *(p_codec_info++); p_ie->acl_sprint_reserved1 = *(p_codec_info++); p_ie->acl_sprint_reserved2 = *(p_codec_info++); p_ie->acl_sprint_reserved3 = *(p_codec_info++); status = A2DP_SUCCESS; if (is_capability) return status; if (is_capability) return A2DP_SUCCESS; if (A2DP_BitsSet(p_ie->sampleRate) != A2DP_SET_ONE_BIT) status = A2DP_BAD_SAMP_FREQ; return A2DP_BAD_SAMP_FREQ; if (A2DP_BitsSet(p_ie->channelMode) != A2DP_SET_ONE_BIT) status = A2DP_BAD_CH_MODE; return A2DP_BAD_CH_MODE; return status; return A2DP_SUCCESS; } bool A2DP_IsVendorSourceCodecValidAptxHd(const uint8_t* p_codec_info) { Loading Loading @@ -227,10 +222,10 @@ static tA2DP_STATUS A2DP_CodecInfoMatchesCapabilityAptxHd( /* verify that each parameter is in range */ LOG_DEBUG(LOG_TAG, "FREQ peer: 0x%x, capability 0x%x", cfg_cie.sampleRate, p_cap->sampleRate); LOG_DEBUG(LOG_TAG, "CH_MODE peer: 0x%x, capability 0x%x", cfg_cie.channelMode, p_cap->channelMode); LOG_DEBUG(LOG_TAG, "%s: FREQ peer: 0x%x, capability 0x%x", __func__, cfg_cie.sampleRate, p_cap->sampleRate); LOG_DEBUG(LOG_TAG, "%s: CH_MODE peer: 0x%x, capability 0x%x", __func__, cfg_cie.channelMode, p_cap->channelMode); /* sampling frequency */ if ((cfg_cie.sampleRate & p_cap->sampleRate) == 0) return A2DP_NS_SAMP_FREQ; Loading Loading @@ -353,8 +348,8 @@ int A2DP_VendorGetTrackChannelCountAptxHd(const uint8_t* p_codec_info) { return -1; } bool A2DP_VendorGetPacketTimestampAptxHd(const uint8_t* p_codec_info, const uint8_t* p_data, bool A2DP_VendorGetPacketTimestampAptxHd( UNUSED_ATTR const uint8_t* p_codec_info, const uint8_t* p_data, uint32_t* p_timestamp) { // TODO: Is this function really codec-specific? *p_timestamp = *(const uint32_t*)p_data; Loading Loading @@ -382,18 +377,18 @@ void A2DP_VendorDumpCodecInfoAptxHd(const uint8_t* p_codec_info) { } LOG_DEBUG(LOG_TAG, "\tsamp_freq: 0x%x", aptx_hd_cie.sampleRate); if (aptx_hd_cie.sampleRate == A2DP_APTX_HD_SAMPLERATE_44100) { if (aptx_hd_cie.sampleRate & A2DP_APTX_HD_SAMPLERATE_44100) { LOG_DEBUG(LOG_TAG, "\tsamp_freq: (44100)"); } if (aptx_hd_cie.sampleRate == A2DP_APTX_HD_SAMPLERATE_48000) { if (aptx_hd_cie.sampleRate & A2DP_APTX_HD_SAMPLERATE_48000) { LOG_DEBUG(LOG_TAG, "\tsamp_freq: (48000)"); } LOG_DEBUG(LOG_TAG, "\tch_mode: 0x%x", aptx_hd_cie.channelMode); if (aptx_hd_cie.channelMode == A2DP_APTX_HD_CHANNELS_MONO) { if (aptx_hd_cie.channelMode & A2DP_APTX_HD_CHANNELS_MONO) { LOG_DEBUG(LOG_TAG, "\tch_mode: (Mono)"); } if (aptx_hd_cie.channelMode == A2DP_APTX_HD_CHANNELS_STEREO) { if (aptx_hd_cie.channelMode & A2DP_APTX_HD_CHANNELS_STEREO) { LOG_DEBUG(LOG_TAG, "\tch_mode: (Stereo)"); } } Loading