About the max size of BSA_Server BT SINK audio callback PCM/AAC data buffer

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
swli_3187821
Level 2
Level 2
First like received

Hi expert,

   We are using Linux BSA_Server to implement BT Sink function. Application layer uses UIPC_Open to receive PCM/AAC data from BSA_Server.

   The data buffer pointer is: pBuffer = ((uint8_t*)(p_msg + 1)) + p_msg->offset;

   The data buffer lenght is: p_msg->len

     Q1. Is the maximum value of p_msg->len always 1024?

     Q2. Where to configure this value or if it's a fixed value and can't be change?

Thanks very much and look forward to your feedback!

0 Likes
1 Solution

only find this one for AV, assume they are using the same buffer.

# Configure the BSA AV buffer size.  This will be set the maximum latency
# that can be added before the SBC encoder.  When setting this value, you
# should take into account:
# - the ring buffer mechanism requires 1 byte to be always free, the
#    actual size used is smaller by 1
# - the size must be a multiple of the sample size (2x16 for 16 bit stereo)
#   because if the buffer write is non blocking, samples could get truncated
# examples:
# - 48kHz 16 bit stereo:
# 8193 -> 8192 byte buffer -> 2048 sample buffer -> 42.666 ms
BSA_AV_UIPC_BUFFER_SIZE = 20001

I think the size 512 or 1024 is not the biggest size, but it is limited by PCM types.

for example :  if we transfer the PCM data with a big frame, the big frame is composed of 16 frame, every frame has 32 slots, every slots has 8 bit sample data.  so the big frame size is  16*32*8= 4096 bit , 512 bytes.

View solution in original post

0 Likes
4 Replies
Zhengbao_Zhang
Moderator
Moderator
Moderator
250 sign-ins First comment on KBA 10 questions asked

hello:

I do not think len is a fixed value, otherwise alsa_frames_to_send should be a fixed value if num_channel fixed.  So maybe need your help to print the len info out when avk function is running.

#ifdef PCM_ALSA

    pthread_mutex_lock(&alsa_opt_mutex);

    if (app_avk_cb.alsa_handle != NULL && p_buffer)

    {

/* Compute number of PCM samples (contained in p_msg->len bytes) */

alsa_frames_to_send = p_msg->len / connection->num_channel;

if (connection->bit_per_sample == 16)

alsa_frames_to_send /= 2;

0 Likes

Hi ZhengbaoZ,

     Yes, we have printed the “p_msg->len” value for AVK mode.

     For PCM format, it's always 1024 or 512.

     For AAC format with LATM header, it's around 600~700 normally, 1024 maximum.

     As we observed, the maximum value is 1024. But we don't make sure this thing.

     We require your confirmation, does BSA_server set the maximum buffer size to 1024 for AVK UIPC transmission?

     Thanks very much!

Jevon

0 Likes

only find this one for AV, assume they are using the same buffer.

# Configure the BSA AV buffer size.  This will be set the maximum latency
# that can be added before the SBC encoder.  When setting this value, you
# should take into account:
# - the ring buffer mechanism requires 1 byte to be always free, the
#    actual size used is smaller by 1
# - the size must be a multiple of the sample size (2x16 for 16 bit stereo)
#   because if the buffer write is non blocking, samples could get truncated
# examples:
# - 48kHz 16 bit stereo:
# 8193 -> 8192 byte buffer -> 2048 sample buffer -> 42.666 ms
BSA_AV_UIPC_BUFFER_SIZE = 20001

I think the size 512 or 1024 is not the biggest size, but it is limited by PCM types.

for example :  if we transfer the PCM data with a big frame, the big frame is composed of 16 frame, every frame has 32 slots, every slots has 8 bit sample data.  so the big frame size is  16*32*8= 4096 bit , 512 bytes.

0 Likes

Hi ZhengbaoZ,

   OK. Thanks for your reply!

Jevon

0 Likes