diff --git a/lib_xua/lib_xua/src/core/buffer/ep/ep_buffer.xc b/lib_xua/lib_xua/src/core/buffer/ep/ep_buffer.xc index 8cfbdbd..bcb0e27 100644 --- a/lib_xua/lib_xua/src/core/buffer/ep/ep_buffer.xc +++ b/lib_xua/lib_xua/src/core/buffer/ep/ep_buffer.xc @@ -737,8 +737,15 @@ void XUA_Buffer_Ep( if(usb_speed != XUD_SPEED_HS) feedbackMul = 8ULL; /* TODO Use 4 instead of 8 to avoid windows LSB issues? */ - /* Number of MCLK ticks in this SOF period (E.g = 125 * 24.576 = 3072) */ - int count = (int) ((short)(u_tmp - lastClock)); + /* Number of MCLK ticks in this SOF period (E.g = 125 * 24.576 = 3072) + * 改动原因:原 (short) 截断只能处理 MCLK 计数 < 32768 的情况。 + * UAC1 使用 FS USB(SOF 周期 1ms),1024x MCLK(49.152MHz)时 + * 每个 SOF 产生 49152 ticks > 32767,(short) 溢出为 -16384(负数), + * 导致 feedback 计算错误,录音 IN endpoint 缓冲区管理失败,录音卡住。 + * 改为 (unsigned short) 后:49152 = 0xC000,truncate 后仍为 49152, + * 同时保留对 16-bit 端口计时器回绕(wraparound)的正确处理。 + * UAC2 HS SOF(125µs)下最大 6144 ticks < 32768,两者等价,无副作用。 */ + int count = (int) ((unsigned short)(u_tmp - lastClock)); unsigned long long full_result = count * feedbackMul * sampleFreq; @@ -1235,7 +1242,7 @@ void XUA_Buffer_Ep( { if (btn_start_time == 0) { - UserReadHIDButtons(&g_hidData[1]); + // UserReadHIDButtons(&g_hidData[1]); btn_start_time = now; XUD_SetReady_In(ep_hid, g_hidData, HID_BUTTON_REPORT_BYTES); } diff --git a/lib_xua/lib_xua/src/core/uac_hwresources.h b/lib_xua/lib_xua/src/core/uac_hwresources.h index 08ff66d..dda3f67 100644 --- a/lib_xua/lib_xua/src/core/uac_hwresources.h +++ b/lib_xua/lib_xua/src/core/uac_hwresources.h @@ -8,8 +8,8 @@ #define CLKBLK_SPDIF_TX XS1_CLKBLK_1 #define CLKBLK_SPDIF_RX XS1_CLKBLK_1 #define CLKBLK_MCLK XS1_CLKBLK_2 -#define CLKBLK_FLASHLIB XS1_CLKBLK_3 /* Clock block for use by flash lib */ +#define CLKBLK_FLASHLIB XS1_CLKBLK_1 /* Clock block for use by flash lib */ #define CLKBLK_ADAT_RX XS1_CLKBLK_REF /* Use REF for ADAT_RX on x200/AI series */ -#define CLKBLK_I2S_BIT XS1_CLKBLK_1 +#define CLKBLK_I2S_BIT XS1_CLKBLK_3 #endif /* _UAC_HWRESOURCES_H_ */