While conducting Bluetooth audio testing, I found that when the device is in sink mode, during conversations with the phone’s AI, the first word of each AI voice sentence output by the device stutters. I’ve tried your sink example code and also tested it on the Huangshan Pi board, but the stuttering occurs regardless.
```c
void xz_audio_downlink(uint8_t *data, uint32_t size, uint32_t *aes_value,
uint8_t need_aes)
{
int try_times = 0;
xz_audio_t *thiz = &xz_audio;
rt_slist_t *idle;
if (!thiz->inited)
{
LOG_I("%s invalid\r\n", __FUNCTION__);
return;
}
// LOG_I("%s tx=%d inited=%d\r\n", __FUNCTION__, thiz->is_tx_enable,
// thiz->inited);
wait_speaker:
rt_enter_critical();
idle = rt_slist_first(&thiz->downlink_decode_idle);
rt_exit_critical();
if (idle)
{
xz_decode_queue_t *queue =
rt_container_of(idle, xz_decode_queue_t, node);
if (queue->size < size + 16)
{
opus_heap_free(queue->data);
queue->size = size + 16;
queue->data = opus_heap_malloc(queue->size);
RT_ASSERT(queue->data);
}
queue->data_len = size;
if (need_aes)
{
HAL_AES_init((uint32_t *)&(g_xz_context.key[0]), 16, aes_value,
AES_MODE_CTR);
HAL_AES_run(AES_DEC, data, queue->data, size);
}
else
{
memcpy(queue->data, data, size);
}
rt_enter_critical();
rt_slist_remove(&thiz->downlink_decode_idle, idle);
rt_slist_append(&thiz->downlink_decode_busy, idle);
rt_exit_critical();
rt_event_send(thiz->event, XZ_EVENT_DOWNLINK);
```
````
Add initial handling for `rt_event_send(thiz->event, XZ_EVENT_DOWNLINK);` — delay sending until several packets are accumulated the first time.
When the speaker is opened, set `thiz->trigger_count = 0;`.
Modify this section as follows:
if (thiz->trigger_count < 4) // But what if the server sends only 1–3 packets at once?
{
thiz->trigger_count++;
}
else
{
rt_event_send(thiz->event, XZ_EVENT_DOWNLINK);
}
XZ_DOWNLINK_QUEUE_NUM
You mean that the xz_audio_downlink function starts transmitting audio data to the speaker only after receiving a certain amount of audio data.


It can’t always be ==4; it starts that way initially, but afterward, you need to send each time.
No, it doesn’t feel like this is the issue.
What’s the current situation? Has there been any improvement?