Skip to content

Commit

Permalink
Tested 3 bytes feedback work on OSX.
Browse files Browse the repository at this point in the history
  • Loading branch information
HiFiPhile committed May 12, 2024
1 parent df67403 commit 32d0baa
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/class/audio/audio_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ static uint16_t audiod_encode_type_I_pcm(uint8_t rhport, audiod_function_t* audi
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
static inline bool audiod_fb_send(audiod_function_t *audio)
{
bool apply_correction = TUSB_SPEED_FULL == tud_speed_get() && audio->feedback.format_correction;
bool apply_correction = (TUSB_SPEED_FULL == tud_speed_get()) && audio->feedback.format_correction;
// Format the feedback value
if (apply_correction)
{
Expand All @@ -1226,6 +1226,7 @@ static inline bool audiod_fb_send(audiod_function_t *audio)
*(fb++) = (audio->feedback.value >> 2) & 0xFF;
*(fb++) = (audio->feedback.value >> 10) & 0xFF;
*(fb++) = (audio->feedback.value >> 18) & 0xFF;
*fb = 0;
} else
{
audio->feedback.send_buf = audio->feedback.value;
Expand All @@ -1241,10 +1242,10 @@ static inline bool audiod_fb_send(audiod_function_t *audio)
// 10.14 4 4 Linux
// 10.14 4 3 Linux
// 10.14 3 4 Linux, OSX
// 10.14 3 3 Linux
// 10.14 3 3 Linux, OSX
//
// OSX requires wMaxPacketSize=3 while sending 4 bytes (WTF ?!), so we still send 4 bytes even of correction is applied
return usbd_edpt_xfer(audio->rhport, audio->ep_fb, (uint8_t *) &audio->feedback.send_buf, 4);
// We send 3 bytes since sending packet larger than wMaxPacketSize is pretty ugly
return usbd_edpt_xfer(audio->rhport, audio->ep_fb, (uint8_t *) &audio->feedback.send_buf, apply_correction ? 3 : 4);
}
#endif

Expand Down

0 comments on commit 32d0baa

Please sign in to comment.