Skip to content

Commit

Permalink
Bluetooth: fix compiling issue when either A2DP SRC or SNK are not en…
Browse files Browse the repository at this point in the history
…abled

Some of the A2DP interfaces are not defined if the corresponding feature is not enabled,
and therefore shall not be initialized. This patchs include the interfaces/variables by
the configurations to go through the compiling stage.

Signed-off-by: gaozihao <[email protected]>
  • Loading branch information
gaozihao committed Jul 4, 2024
1 parent 2457f73 commit 049f2e8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion subsys/bluetooth/shell/a2dp.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ static struct bt_a2dp_ep *found_peer_sbc_endpoint;
static struct bt_a2dp_ep *registered_sbc_endpoint;
static struct bt_a2dp_stream sbc_stream;
static struct bt_a2dp_stream_ops stream_ops;

#if defined(CONFIG_BT_A2DP_SOURCE)
static uint8_t media_data[] = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
Expand All @@ -52,6 +54,7 @@ static uint8_t media_data[] = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
};
#endif

NET_BUF_POOL_DEFINE(a2dp_tx_pool, CONFIG_BT_MAX_CONN,
BT_L2CAP_BUF_SIZE(CONFIG_BT_L2CAP_TX_MTU),
Expand Down Expand Up @@ -538,8 +541,12 @@ static struct bt_a2dp_stream_ops stream_ops = {
.started = stream_started,
.suspended = NULL,
.reconfigured = NULL,
#if defined(CONFIG_BT_A2DP_SINK)
.recv = stream_recv,
#endif
#if defined(CONFIG_BT_A2DP_SOURCE)
.sent = NULL,
#endif
};

BT_A2DP_SBC_EP_CFG_DEFAULT(sbc_cfg_default, A2DP_SBC_SAMP_FREQ_44100);
Expand Down Expand Up @@ -647,6 +654,7 @@ static int cmd_start(const struct shell *sh, int32_t argc, char *argv[])

static int cmd_send_media(const struct shell *sh, int32_t argc, char *argv[])
{
#if defined(CONFIG_BT_A2DP_SOURCE)
struct net_buf *buf;
int ret;

Expand All @@ -670,7 +678,7 @@ static int cmd_send_media(const struct shell *sh, int32_t argc, char *argv[])
printk(" Failed to send SBC audio data on streams(%d)\n", ret);
net_buf_unref(buf);
}

#endif
return 0;
}

Expand Down

0 comments on commit 049f2e8

Please sign in to comment.