mirror of
https://github.com/hathach/tinyusb.git
synced 2026-08-18 02:53:35 +00:00
audio_device: enforce the documented FIFO minimum in the EP-IN flow-control guard
The comment above audiod_tx_packet_size() states flow control needs a FIFO of at least 4*Navg, but the guard tests nominal_size[1] <= fifo_depth * 4 - true for any FIFO larger than a quarter packet - instead of nominal_size[1] * 4 <= fifo_depth. As written, flow control engages on FIFOs far below its own documented minimum, where the depth/2 setpoint sits within one packet of empty and the packet_size = 0 branch (a zero-length packet, i.e. an audible 1 ms dropout for audio-class hosts) is reachable from ordinary scheduling jitter rather than only from gross clock deviation. With the guard corrected, undersized FIFOs fall back to the plain min(count, max) path as intended.
This commit is contained in:
@ -1841,7 +1841,7 @@ static bool audiod_calc_tx_packet_sz(audiod_function_t *audio) {
|
||||
|
||||
static uint16_t audiod_tx_packet_size(const uint16_t *nominal_size, uint16_t data_count, uint16_t fifo_depth, uint16_t fifo_threshold, uint16_t max_depth) {
|
||||
// Flow control need a FIFO size of at least 4*Navg
|
||||
if (nominal_size[1] && nominal_size[1] <= fifo_depth * 4) {
|
||||
if (nominal_size[1] && nominal_size[1] * 4 <= fifo_depth) {
|
||||
// Use blackout to prioritize normal size packet
|
||||
static int ctrl_blackout = 0;
|
||||
uint16_t packet_size;
|
||||
|
||||
Reference in New Issue
Block a user