Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions subsys/bluetooth/audio/shell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ zephyr_library_sources_ifdef(
CONFIG_BT_BAP_STREAM
bap.c
)
if (CONFIG_BT_AUDIO_RX AND CONFIG_LIBLC3 AND CONFIG_USB_DEVICE_AUDIO)
zephyr_library_sources(bap_usb.c)
endif()
zephyr_library_sources_ifdef(
CONFIG_BT_BAP_SCAN_DELEGATOR
bap_scan_delegator.c
Expand Down
34 changes: 33 additions & 1 deletion subsys/bluetooth/audio/shell/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "shell/bt.h"

#define SHELL_PRINT_INDENT_LEVEL_SIZE 2
#define MAX_CODEC_FRAMES_PER_SDU 4U

extern struct bt_csip_set_member_svc_inst *svc_inst;

Expand All @@ -46,8 +47,17 @@ ssize_t cap_initiator_pa_data_add(struct bt_data *data_array, const size_t data_
#include <zephyr/bluetooth/audio/bap_lc3_preset.h>
#include <zephyr/bluetooth/audio/cap.h>

unsigned long bap_get_recv_stats_interval(void);

#if defined(CONFIG_LIBLC3)
#include "lc3.h"

#define USB_SAMPLE_RATE 48000U
#define LC3_MAX_SAMPLE_RATE 48000U
#define LC3_MAX_FRAME_DURATION_US 10000U
#define LC3_MAX_NUM_SAMPLES_MONO ((LC3_MAX_FRAME_DURATION_US * LC3_MAX_SAMPLE_RATE) / \
USEC_PER_SEC)
#define LC3_MAX_NUM_SAMPLES_STEREO (LC3_MAX_NUM_SAMPLES_MONO * 2U)
#endif /* CONFIG_LIBLC3 */

#define LOCATION BT_AUDIO_LOCATION_FRONT_LEFT | BT_AUDIO_LOCATION_FRONT_RIGHT
Expand All @@ -67,6 +77,12 @@ struct named_lc3_preset {
const struct named_lc3_preset *bap_get_named_preset(bool is_unicast, enum bt_audio_dir dir,
const char *preset_arg);

size_t bap_get_rx_streaming_cnt(void);
int bap_usb_init(void);
int bap_usb_add_frame_to_usb(enum bt_audio_location lc3_chan_allocation, const int16_t *frame,
size_t frame_size, uint32_t ts);
void bap_usb_clear_frames_to_usb(void);

struct shell_stream {
struct bt_cap_stream stream;
struct bt_audio_codec_cfg codec_cfg;
Expand All @@ -90,7 +106,7 @@ struct shell_stream {
int64_t connected_at_ticks;
uint16_t seq_num;
struct k_work_delayable audio_send_work;
bool tx_active;
bool active;
#if defined(CONFIG_LIBLC3)
atomic_t lc3_enqueue_cnt;
size_t lc3_sdu_cnt;
Expand Down Expand Up @@ -182,6 +198,22 @@ int cap_ac_unicast(const struct shell *sh, const struct bap_unicast_ac_param *pa
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT */
#endif /* CONFIG_BT_BAP_UNICAST */

static inline uint8_t get_chan_cnt(enum bt_audio_location chan_allocation)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may consider making this a common function; it is used several other places

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
uint8_t cnt = 0U;

if (chan_allocation == BT_AUDIO_LOCATION_MONO_AUDIO) {
return 1;
}

while (chan_allocation != 0) {
cnt += chan_allocation & 1U;
chan_allocation >>= 1;
}

return cnt;
}

static inline void print_qos(const struct shell *sh, const struct bt_audio_codec_qos *qos)
{
#if defined(CONFIG_BT_BAP_BROADCAST_SOURCE) || defined(CONFIG_BT_BAP_UNICAST)
Expand Down
Loading