Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apps/auracast_usb: Fix calculation for octets_per_frame and max_sdu #1824

Merged
Merged
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
27 changes: 16 additions & 11 deletions apps/auracast_usb/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "app_priv.h"

#define BROADCAST_SID 1
#define BROADCAST_SDU_INTVL MYNEWT_VAL(LC3_FRAME_DURATION)

#if (MYNEWT_VAL(LC3_SAMPLING_FREQ) == 8000)
#define BROADCAST_SAMPLE_RATE BLE_AUDIO_SAMPLING_RATE_8000_HZ
Expand All @@ -47,11 +46,17 @@
BUILD_ASSERT(0, "Sample frequency not supported");
#endif

#define BROADCAST_MAX_SDU (BROADCAST_SDU_INTVL * \
MYNEWT_VAL(LC3_BITRATE) / \
(1000 * 1000 * 8) * \
MYNEWT_VAL(AURACAST_CHAN_NUM) / \
MYNEWT_VAL(BIG_NUM_BIS))
/* Note: values need to be adjusted if sampling frequency is 44100 (currently
* not supported by app) or SDU interval is different from LC3 frame
* length
*/
#define OCTETS_PER_CODEC_FRAME (MYNEWT_VAL(LC3_BITRATE) / \
8 * MYNEWT_VAL(LC3_FRAME_DURATION) / \
1000000)
#define BIG_SDU_INTERVAL (MYNEWT_VAL(LC3_FRAME_DURATION))
#define BIG_MAX_SDU (OCTETS_PER_CODEC_FRAME * \
MYNEWT_VAL(AURACAST_CHAN_NUM) / \
MYNEWT_VAL(BIG_NUM_BIS))

#define BROADCASTER_INTERRUPT_TASK_PRIO 4
#define BROADCASTER_INTERRUPT_TASK_STACK_SZ 512
Expand Down Expand Up @@ -104,14 +109,14 @@ base_create(void)
BLE_AUDIO_SELECTED_FRAME_DURATION_10_MS :
BLE_AUDIO_SELECTED_FRAME_DURATION_7_5_MS,
BLE_AUDIO_LOCATION_FRONT_LEFT,
BROADCAST_MAX_SDU, );
OCTETS_PER_CODEC_FRAME, );
uint8_t codec_spec_config_right_chan[] =
BLE_AUDIO_BUILD_CODEC_CONFIG(BROADCAST_SAMPLE_RATE,
MYNEWT_VAL(LC3_FRAME_DURATION) == 10000 ?
BLE_AUDIO_SELECTED_FRAME_DURATION_10_MS :
BLE_AUDIO_SELECTED_FRAME_DURATION_7_5_MS,
BLE_AUDIO_LOCATION_FRONT_RIGHT,
BROADCAST_MAX_SDU, );
OCTETS_PER_CODEC_FRAME, );
#else
uint16_t chan_loc = BLE_AUDIO_LOCATION_FRONT_LEFT |
BLE_AUDIO_LOCATION_FRONT_RIGHT;
Expand All @@ -121,7 +126,7 @@ base_create(void)
BLE_AUDIO_SELECTED_FRAME_DURATION_10_MS :
BLE_AUDIO_SELECTED_FRAME_DURATION_7_5_MS,
chan_loc,
BROADCAST_MAX_SDU * 2, );
OCTETS_PER_CODEC_FRAME, );

struct ble_audio_bis *bis;
#endif
Expand Down Expand Up @@ -239,8 +244,8 @@ auracast_create(void)
{
const char *program_info = "NimBLE Auracast Test";
static struct ble_iso_big_params big_params = {
.sdu_interval = MYNEWT_VAL(LC3_FRAME_DURATION),
.max_sdu = BROADCAST_MAX_SDU,
.sdu_interval = BIG_SDU_INTERVAL,
.max_sdu = BIG_MAX_SDU,
.max_transport_latency = MYNEWT_VAL(LC3_FRAME_DURATION) / 1000,
.rtn = MYNEWT_VAL(BIG_RTN),
.phy = MYNEWT_VAL(BIG_PHY),
Expand Down
Loading