summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiFiPHile <[email protected]>2026-08-25 09:29:07 +0200
committerHiFiPHile <[email protected]>2026-08-25 09:29:07 +0200
commitb0bd26eb5f0b941da2120e8e90a27bae48f29278 (patch)
tree8f4eae5b0d3a0461f314f8051cfa2d10ed79e1bc /test
parent87511ce87280e986545149e4ad017ccf2392671c (diff)
fix(audio): decode full-speed isochronous bInterval
Treat isochronous bInterval as a power-of-two exponent for both full and high speed, using the appropriate frame unit. Packet sizing and fractional scheduling now use the actual service interval. Signed-off-by: HiFiPHile <[email protected]>
Diffstat (limited to 'test')
-rw-r--r--test/unit-test/test/host/audio/test_audio_host.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/unit-test/test/host/audio/test_audio_host.c b/test/unit-test/test/host/audio/test_audio_host.c
index 37b35dae8..b64335910 100644
--- a/test/unit-test/test/host/audio/test_audio_host.c
+++ b/test/unit-test/test/host/audio/test_audio_host.c
@@ -444,6 +444,17 @@ static const uint8_t playback_44100_max_packets_only[] = {
TEST_UAC1_CS_DATA_EP_ATTR(AUDIO10_CS_AS_ISO_DATA_EP_ATT_MAX_PACKETS_ONLY),
};
+static const uint8_t playback_11025_interval4[] = {
+ TEST_UAC1_AC_HEADER,
+ TEST_UAC1_INPUT_TERM(PLAYBACK_INPUT_TERM, AUDIO_TERM_TYPE_USB_STREAMING, 2),
+ TEST_UAC1_AS_ALT0,
+ TEST_UAC1_AS_INTERFACE(1, 1),
+ TEST_UAC1_AS_GENERAL(PLAYBACK_INPUT_TERM),
+ TEST_UAC1_FORMAT(2, 2, 16, 11025),
+ TEST_UAC1_DATA_EP(0x01, TUSB_ISO_EP_ATT_ADAPTIVE, 180, 3),
+ TEST_UAC1_CS_DATA_EP,
+};
+
static uint8_t fu_cb_count;
static uintptr_t fu_cb_user_data;
@@ -814,6 +825,33 @@ void test_audio_host_schedules_44100_hz_fractional_packets_with_max_packets_only
TEST_ASSERT_EQUAL_UINT16(180, edpt_xfer_bytes[9]);
}
+void test_audio_host_uses_exponential_full_speed_iso_interval(void) {
+ uint8_t samples[441 * 4] = {0};
+ mount_descriptors(playback_11025_interval4, sizeof(playback_11025_interval4));
+
+ TEST_ASSERT_TRUE(tuh_audio_configure(0, 0, 0));
+ TEST_ASSERT_TRUE(tuh_audio_start(0, 0));
+ TEST_ASSERT_EQUAL_UINT32(256, tuh_audio_write(0, 0, samples, 256));
+ complete_interface_set(XFER_RESULT_SUCCESS);
+
+ while (edpt_xfer_count < 5) {
+ edpt_busy = false;
+ TEST_ASSERT_TRUE(audioh_xfer_cb(AUDIO_DEV_ADDR, 0x01, XFER_RESULT_SUCCESS,
+ edpt_xfer_bytes[edpt_xfer_count - 1]));
+ }
+ TEST_ASSERT_EQUAL_UINT32(185, tuh_audio_write(0, 0, samples, 185));
+ while (edpt_xfer_count < 10) {
+ edpt_busy = false;
+ TEST_ASSERT_TRUE(audioh_xfer_cb(AUDIO_DEV_ADDR, 0x01, XFER_RESULT_SUCCESS,
+ edpt_xfer_bytes[edpt_xfer_count - 1]));
+ }
+
+ for (uint8_t i = 0; i < 9; i++) {
+ TEST_ASSERT_EQUAL_UINT16(176, edpt_xfer_bytes[i]);
+ }
+ TEST_ASSERT_EQUAL_UINT16(180, edpt_xfer_bytes[9]);
+}
+
void test_audio_host_sends_silence_when_playback_fifo_has_too_few_frames(void) {
uint8_t sample[4] = {1, 2, 3, 4};
uint8_t more_samples[43 * 4];