Commit 92d6b78f authored by Mariusz Skamra's avatar Mariusz Skamra Committed by Carles Cufi
Browse files

Bluetooth: audio: Introduce helper BT_AUDIO_RX(TX) flags

This adds new hidden compilation flags that indicate whether the
implementation is configured to be able to receive/transmit audio data.
The flags are profile agnostic to loosen dependencies between
modules/services.

Signed-off-by: default avatarMariusz Skamra <mariusz.skamra@codecoup.pl>
parent dcfafebc
Loading
Loading
Loading
Loading
+4 −4
Changes for include/zephyr/bluetooth/audio/bap.h: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -406,7 +406,7 @@ struct bt_bap_stream_ops {
	 */
	void (*stopped)(struct bt_bap_stream *stream, uint8_t reason);

#if defined(CONFIG_BT_BAP_UNICAST) || defined(CONFIG_BT_BAP_BROADCAST_SINK)
#if defined(CONFIG_BT_AUDIO_RX)
	/**
	 * @brief Stream audio HCI receive callback.
	 *
@@ -420,9 +420,9 @@ struct bt_bap_stream_ops {
	 */
	void (*recv)(struct bt_bap_stream *stream, const struct bt_iso_recv_info *info,
		     struct net_buf *buf);
#endif /* CONFIG_BT_BAP_UNICAST || CONFIG_BT_BAP_BROADCAST_SINK */
#endif /* CONFIG_BT_AUDIO_RX */

#if defined(CONFIG_BT_BAP_UNICAST) || defined(CONFIG_BT_BAP_BROADCAST_SOURCE)
#if defined(CONFIG_BT_AUDIO_TX)
	/**
	 * @brief Stream audio HCI sent callback
	 *
@@ -434,7 +434,7 @@ struct bt_bap_stream_ops {
	 * @param chan The channel which has sent data.
	 */
	void (*sent)(struct bt_bap_stream *stream);
#endif /* CONFIG_BT_BAP_UNICAST || CONFIG_BT_BAP_BROADCAST_SOURCE */
#endif /* CONFIG_BT_AUDIO_TX */
};

/**
+12 −0
Changes for subsys/bluetooth/audio/Kconfig: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -19,6 +19,18 @@ menuconfig BT_AUDIO

if BT_AUDIO

config BT_AUDIO_RX
	bool
	help
	  This hidden option is enabled when any of the profiles/services
	  enables support for receiving of audio data.

config BT_AUDIO_TX
	bool
	help
	  This hidden option is enabled when any of the profiles/services
	  enables support for transmitting of audio data.

config BT_CCID
	bool
	help
+2 −0
Changes for subsys/bluetooth/audio/Kconfig.ascs: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -31,10 +31,12 @@ config BT_ASCS_ASE_SRC_COUNT
config BT_ASCS_ASE_SNK
	def_bool BT_ASCS_ASE_SNK_COUNT > 0
	select BT_PAC_SNK
	select BT_AUDIO_RX

config BT_ASCS_ASE_SRC
	def_bool BT_ASCS_ASE_SRC_COUNT > 0
	select BT_PAC_SRC
	select BT_AUDIO_TX

config BT_ASCS_MAX_ACTIVE_ASES
	int "Number of simultaneously supported ASE sessions"
+10 −0
Changes for subsys/bluetooth/audio/Kconfig.bap: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -107,12 +107,21 @@ config BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT
	  This option enables caching a number of Audio Stream Endpoint Source
	  instances for Basic Audio Profile on a per connection basis.

config BT_BAP_UNICAST_CLIENT_ASE_SNK
	def_bool BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT > 0
	select BT_AUDIO_TX

config BT_BAP_UNICAST_CLIENT_ASE_SRC
	def_bool BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT > 0
	select BT_AUDIO_RX

endif # BT_BAP_UNICAST_CLIENT

config BT_BAP_BROADCAST_SOURCE
	bool "Bluetooth Broadcast Source Audio Support [EXPERIMENTAL]"
	select EXPERIMENTAL
	select BT_ISO_BROADCASTER
	select BT_AUDIO_TX
	help
	  This option enables support for Bluetooth Broadcast Source Audio using
	  Isochronous channels.
@@ -152,6 +161,7 @@ config BT_BAP_BROADCAST_SINK
	bool "Bluetooth Broadcast Sink Audio Support [EXPERIMENTAL]"
	select EXPERIMENTAL
	select BT_ISO_SYNC_RECEIVER
	select BT_AUDIO_RX
	depends on BT_PERIPHERAL
	depends on BT_PAC_SNK
	help
+8 −0
Changes for subsys/bluetooth/audio/ascs.c: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -607,6 +607,7 @@ static int ascs_iso_accept(const struct bt_iso_accept_info *info, struct bt_iso_
	return -EACCES;
}

#if defined(CONFIG_BT_AUDIO_RX)
static void ascs_iso_recv(struct bt_iso_chan *chan,
			  const struct bt_iso_recv_info *info,
			  struct net_buf *buf)
@@ -658,7 +659,9 @@ static void ascs_iso_recv(struct bt_iso_chan *chan,
		LOG_WRN("No callback for recv set");
	}
}
#endif /* CONFIG_BT_AUDIO_RX */

#if defined(CONFIG_BT_AUDIO_TX)
static void ascs_iso_sent(struct bt_iso_chan *chan)
{
	struct bt_bap_iso *iso = CONTAINER_OF(chan, struct bt_bap_iso, chan);
@@ -688,6 +691,7 @@ static void ascs_iso_sent(struct bt_iso_chan *chan)
		ops->sent(stream);
	}
}
#endif /* CONFIG_BT_AUDIO_TX */

static void ascs_ep_iso_connected(struct bt_bap_ep *ep)
{
@@ -801,8 +805,12 @@ static void ascs_iso_disconnected(struct bt_iso_chan *chan, uint8_t reason)
}

static struct bt_iso_chan_ops ascs_iso_ops = {
#if defined(CONFIG_BT_AUDIO_RX)
	.recv = ascs_iso_recv,
#endif /* CONFIG_BT_AUDIO_RX */
#if defined(CONFIG_BT_AUDIO_TX)
	.sent = ascs_iso_sent,
#endif /* CONFIG_BT_AUDIO_TX */
	.connected = ascs_iso_connected,
	.disconnected = ascs_iso_disconnected,
};
Loading