(*(p_codec_info + 2) & A2DP_AAC_BIT_RATE_MASK2);
p_codec_info += 3;
- if (is_capability) return A2DP_SUCCESS;
+ 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->objectType) == A2DP_SET_ZERO_BIT)
+ return A2DP_BAD_OBJ_TYPE;
+ if (A2DP_BitsSet(p_ie->sampleRate) == A2DP_SET_ZERO_BIT)
+ return A2DP_BAD_SAMP_FREQ;
+ if (A2DP_BitsSet(p_ie->channelMode) == A2DP_SET_ZERO_BIT)
+ return A2DP_BAD_CH_MODE;
+
+ return A2DP_SUCCESS;
+ }
if (A2DP_BitsSet(p_ie->objectType) != A2DP_SET_ONE_BIT)
return A2DP_BAD_OBJ_TYPE;
return A2DP_BAD_MAX_BITPOOL;
}
- if (is_capability) return A2DP_SUCCESS;
+ 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;
+ if (A2DP_BitsSet(p_ie->ch_mode) == A2DP_SET_ZERO_BIT)
+ return A2DP_BAD_CH_MODE;
+ if (A2DP_BitsSet(p_ie->block_len) == A2DP_SET_ZERO_BIT)
+ return A2DP_BAD_BLOCK_LEN;
+ if (A2DP_BitsSet(p_ie->num_subbands) == A2DP_SET_ZERO_BIT)
+ return A2DP_BAD_SUBBANDS;
+ if (A2DP_BitsSet(p_ie->alloc_method) == A2DP_SET_ZERO_BIT)
+ return A2DP_BAD_ALLOC_METHOD;
+
+ return A2DP_SUCCESS;
+ }
if (A2DP_BitsSet(p_ie->samp_freq) != A2DP_SET_ONE_BIT)
return A2DP_BAD_SAMP_FREQ;
p_ie->sampleRate = *p_codec_info & 0xF0;
p_codec_info++;
- if (is_capability) return A2DP_SUCCESS;
+ 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->sampleRate) == A2DP_SET_ZERO_BIT)
+ return A2DP_BAD_SAMP_FREQ;
+ if (A2DP_BitsSet(p_ie->channelMode) == A2DP_SET_ZERO_BIT)
+ return A2DP_BAD_CH_MODE;
+
+ return A2DP_SUCCESS;
+ }
if (A2DP_BitsSet(p_ie->sampleRate) != A2DP_SET_ONE_BIT)
return A2DP_BAD_SAMP_FREQ;
p_ie->acl_sprint_reserved2 = *(p_codec_info++);
p_ie->acl_sprint_reserved3 = *(p_codec_info++);
- if (is_capability) return A2DP_SUCCESS;
+ 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->sampleRate) == A2DP_SET_ZERO_BIT)
+ return A2DP_BAD_SAMP_FREQ;
+ if (A2DP_BitsSet(p_ie->channelMode) == A2DP_SET_ZERO_BIT)
+ return A2DP_BAD_CH_MODE;
+
+ return A2DP_SUCCESS;
+ }
if (A2DP_BitsSet(p_ie->sampleRate) != A2DP_SET_ONE_BIT)
return A2DP_BAD_SAMP_FREQ;
p_ie->sampleRate = *p_codec_info++ & A2DP_LDAC_SAMPLING_FREQ_MASK;
p_ie->channelMode = *p_codec_info++ & A2DP_LDAC_CHANNEL_MODE_MASK;
- if (is_capability) return A2DP_SUCCESS;
+ 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->sampleRate) == A2DP_SET_ZERO_BIT)
+ return A2DP_BAD_SAMP_FREQ;
+ if (A2DP_BitsSet(p_ie->channelMode) == A2DP_SET_ZERO_BIT)
+ return A2DP_BAD_CH_MODE;
+
+ return A2DP_SUCCESS;
+ }
if (A2DP_BitsSet(p_ie->sampleRate) != A2DP_SET_ONE_BIT)
return A2DP_BAD_SAMP_FREQ;