Skip to content

Commit 1ba829a

Browse files
Bluetooth: audio: Handle lack of channel allocation structure
This commits fixes the handling of codec configuration in case there is no channel allocation field present. Signed-off-by: Szymon Czapracki <[email protected]>
1 parent b27c5d7 commit 1ba829a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

include/zephyr/bluetooth/audio/audio.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ struct bt_codec_data {
221221
* These values are defined by the Generic Audio Assigned Numbers, bluetooth.com
222222
*/
223223
enum bt_audio_location {
224+
/*
225+
* As Audio Location is not mandatory, for handling lack of this field
226+
* in codec configuration we introduce special opcode with unspecified location.
227+
*/
228+
BT_AUDIO_LOCATION_UNSPECIFIED = 0,
224229
BT_AUDIO_LOCATION_FRONT_LEFT = BIT(0),
225230
BT_AUDIO_LOCATION_FRONT_RIGHT = BIT(1),
226231
BT_AUDIO_LOCATION_FRONT_CENTER = BIT(2),

subsys/bluetooth/audio/codec.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,16 @@ int bt_codec_cfg_get_chan_allocation_val(const struct bt_codec *codec,
123123

124124
*chan_allocation = 0;
125125
if (bt_codec_get_val(codec, BT_CODEC_CONFIG_LC3_CHAN_ALLOC, &element)) {
126-
127126
*chan_allocation = sys_le32_to_cpu(*((uint32_t *)&element->data.data[0]));
128127

129128
return BT_AUDIO_CODEC_PARSE_ERR_SUCCESS;
130129
}
131130

132-
return BT_AUDIO_CODEC_PARSE_ERR_TYPE_NOT_FOUND;
131+
/* BAP v1.0.1 4.3.2 Codec_Specific_Configuration LTV requirements
132+
* The absence of the Audio_Channel_Allocation LTV structure
133+
* shall be interpreted as a single channel with no specified Audio Location.
134+
*/
135+
return BT_AUDIO_LOCATION_UNSPECIFIED;
133136
}
134137

135138
int bt_codec_cfg_get_octets_per_frame(const struct bt_codec *codec)

0 commit comments

Comments
 (0)