xmos / sln_voice

XCORE-VOICE Solution
Other
9 stars 21 forks source link

FFVA 48KHz USB buffer overflow fix #315

Closed shuchitak closed 12 months ago

shuchitak commented 12 months ago

https://xmosjira.atlassian.net/browse/AP-153

I've ported the increased precision USB rate calculation changes from the ASRC demo example to the FFVA example.

Without the fix, with what's on develop, the samples_to_host_stream_buf level looks like this, where the y axis is the number of unread samples in the buffer - ffva_adaptive_usb_orig The buffer gets full and is reset in the driver (the sharp drop from 1000 something samples to 0) about every ~ 16 seconds.

After porting the USB rate calculation logic from ASRC app to FFVA, the buffer overflow issue is not seen. I ran for 10 mins on my Mac and the buffer level remained constant. stable_buffer_ffva

We could also add a closed loop control based on the buffer level but since I don't notice any drift, I'm not going to add it for now. Keeping this in mind as an option though.

I've also added support to run the adaptive algorithm for the EP_IN direction in case EP_OUT interface is not active.