Skip to content

Commit

Permalink
Fix HS playback on OSX.
Browse files Browse the repository at this point in the history
  • Loading branch information
HiFiPhile authored and ra1nb0w committed Jul 24, 2024
1 parent 1b74461 commit 58b1938
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/class/audio/audio_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -2062,7 +2062,7 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *

case AUDIO_FEEDBACK_METHOD_FIFO_COUNT:
{
/* Initialize the threshold level to half filled */
// Initialize the threshold level to half filled
uint16_t fifo_lvl_thr;
#if CFG_TUD_AUDIO_ENABLE_DECODING
fifo_lvl_thr = tu_fifo_depth(&audio->rx_supp_ff[0]) / 2;
Expand All @@ -2071,11 +2071,16 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
#endif
audio->feedback.compute.fifo_count.fifo_lvl_thr = fifo_lvl_thr;
audio->feedback.compute.fifo_count.fifo_lvl_avg = ((uint32_t)fifo_lvl_thr) << 16;
/* Avoid 64bit division */
// Avoid 64bit division
uint32_t nominal = ((fb_param.sample_freq / 100) << 16) / (frame_div / 100);
audio->feedback.compute.fifo_count.nom_value = nominal;
audio->feedback.compute.fifo_count.rate_const[0] = (audio->feedback.max_value - nominal) / fifo_lvl_thr;
audio->feedback.compute.fifo_count.rate_const[1] = (nominal - audio->feedback.min_value) / fifo_lvl_thr;
// On HS feedback is more sensitive since packet size can vary every MSOF, could cause instability
if(tud_speed_get() == TUSB_SPEED_HIGH) {
audio->feedback.compute.fifo_count.rate_const[0] /= 8;
audio->feedback.compute.fifo_count.rate_const[1] /= 8;
}
}
break;

Expand Down

0 comments on commit 58b1938

Please sign in to comment.