summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiFiPHile <[email protected]>2026-08-25 09:29:06 +0200
committerHiFiPHile <[email protected]>2026-08-25 09:29:06 +0200
commit8fdf71b46b270f60bc66489f60ea85f7b527408c (patch)
treef4245845ccba1d28649148eb2c9872a67ec612fe /test
parent6028a4dfca34cca13d28a72a2e6f0643864bc742 (diff)
refactor(audio): simplify UAC1 interface discovery
Parse the contiguous AudioStreaming interfaces by class and subclass instead of copying baInterfaceNr. This removes the UAC1-only collection limit and prevents MIDI AudioControl interfaces from leaving a half-allocated Audio Host instance. Signed-off-by: HiFiPHile <[email protected]>
Diffstat (limited to 'test')
-rw-r--r--test/unit-test/test/host/audio/test_audio_host.c18
1 files changed, 18 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 ec1816084..4137642b3 100644
--- a/test/unit-test/test/host/audio/test_audio_host.c
+++ b/test/unit-test/test/host/audio/test_audio_host.c
@@ -226,6 +226,19 @@ static const uint8_t playback_with_explicit_feedback[] = {
TEST_UAC1_DATA_EP(0x81, TUSB_ISO_EP_ATT_EXPLICIT_FB, 3, 1),
};
+static const uint8_t midi_only_collection[] = {
+ TEST_UAC1_AC_HEADER,
+ 9,
+ TUSB_DESC_INTERFACE,
+ AUDIO_AS_ITF,
+ 0,
+ 0,
+ TUSB_CLASS_AUDIO,
+ AUDIO_SUBCLASS_MIDI_STREAMING,
+ AUDIO_INT_PROTOCOL_CODE_V1,
+ 0,
+};
+
static const uint8_t playback_with_implicit_feedback[] = {
TEST_UAC1_AC_HEADER,
TEST_UAC1_INPUT_TERM(PLAYBACK_INPUT_TERM, AUDIO_TERM_TYPE_USB_STREAMING, 2),
@@ -417,6 +430,11 @@ static void mount_descriptors(const uint8_t *desc, uint16_t desc_len) {
}
void test_audio_host_ignores_explicit_feedback_endpoint(void) {
+ // A MIDI-only AC collection must not consume an Audio Host instance.
+ TEST_ASSERT_EQUAL_UINT16(0, audioh_open(0, AUDIO_DEV_ADDR, (const tusb_desc_interface_t *)midi_only_collection,
+ sizeof(midi_only_collection)));
+ TEST_ASSERT_EQUAL_UINT8(0, tuh_audio_get_dev_addr(0));
+
open_descriptors(playback_with_explicit_feedback, sizeof(playback_with_explicit_feedback));
TEST_ASSERT_EQUAL_UINT8(1, tuh_audio_stream_count(0));