Add blackout time.

This commit is contained in:
HiFiPhile 2023-10-17 15:18:05 +02:00
parent 0a1d6cf4d0
commit d83a210788
1 changed files with 23 additions and 9 deletions

View File

@ -2614,25 +2614,39 @@ static uint16_t audiod_tx_packet_size(const uint16_t* norminal_size, uint16_t da
// Flow control need a FIFO size of at least 4*Navg // Flow control need a FIFO size of at least 4*Navg
if(norminal_size[1] && norminal_size[1] <= fifo_depth * 4) if(norminal_size[1] && norminal_size[1] <= fifo_depth * 4)
{ {
// Use blackout to prioritize normal size packet
static int ctrl_blackout = 0;
uint16_t packet_size; uint16_t packet_size;
uint16_t slot_size = norminal_size[2] - norminal_size[1]; uint16_t slot_size = norminal_size[2] - norminal_size[1];
if (data_count < fifo_depth / 2 - slot_size) if (data_count < norminal_size[0])
{ {
if (data_count < norminal_size[0])
{
// If you get here frequently, then your I2S clock deviation is too big ! // If you get here frequently, then your I2S clock deviation is too big !
packet_size = 0; packet_size = 0;
} else } else
{ if (data_count < fifo_depth / 2 - slot_size && !ctrl_blackout)
packet_size = norminal_size[0]; {
} packet_size = norminal_size[0];
} ctrl_blackout = 10;
else if (data_count > fifo_depth / 2 + slot_size) } else
if (data_count > fifo_depth / 2 + slot_size && !ctrl_blackout)
{ {
packet_size = norminal_size[2]; packet_size = norminal_size[2];
if(norminal_size[0] == norminal_size[1])
{
// nav = INT(nav) + 1
ctrl_blackout = 2;
} else
{
// nav = INT(nav)
ctrl_blackout = 10;
}
} else } else
{ {
packet_size = norminal_size[1]; packet_size = norminal_size[1];
if (ctrl_blackout)
{
ctrl_blackout--;
}
} }
// Normally this cap is not necessary // Normally this cap is not necessary
return tu_min16(packet_size, max_depth); return tu_min16(packet_size, max_depth);