summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiFiPHile <[email protected]>2026-08-26 16:56:42 +0200
committerHiFiPHile <[email protected]>2026-08-27 10:34:33 +0200
commit0782fb796d7981c36a3d2a11485596f288dd6bd5 (patch)
tree1a97754f4a6f73bc80497e9993078da5176f7be9 /test
parent4893a14be173e9ab3fadb606222b440ab94e55b4 (diff)
audio: allow stopped duplex streams to change rate
Enforce a shared capture/playback sample rate only while the opposite stream is running. This lets both stopped streams be configured in either order while preventing a live shared clock from changing underneath a transfer. Signed-off-by: HiFiPHile <[email protected]>
Diffstat (limited to 'test')
-rw-r--r--test/unit-test/test/host/audio/test_audio_host.c30
1 files changed, 30 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 4c8d21245..2f92b232f 100644
--- a/test/unit-test/test/host/audio/test_audio_host.c
+++ b/test/unit-test/test/host/audio/test_audio_host.c
@@ -976,6 +976,36 @@ void test_audio_host_uac2_shared_clock_is_discovered_once_for_both_streams(void)
TEST_ASSERT_EQUAL_UINT8(2, tuh_audio_config_count(0, 1));
}
+void test_audio_host_reconfigures_stopped_duplex_streams_to_a_new_common_rate(void) {
+ open_descriptors(uac2_duplex_shared_clock, sizeof(uac2_duplex_shared_clock));
+ TEST_ASSERT_TRUE(audioh_set_config(AUDIO_DEV_ADDR, AUDIO_AC_ITF));
+ complete_uac2_clock_range(44100, 48000);
+
+ TEST_ASSERT_TRUE(tuh_audio_configure(0, 0, 1));
+ TEST_ASSERT_TRUE(tuh_audio_configure(0, 1, 1));
+ TEST_ASSERT_TRUE(tuh_audio_configure(0, 0, 0));
+ TEST_ASSERT_EQUAL_UINT8(0, tuh_audio_active_config(0, 0));
+ TEST_ASSERT_EQUAL_UINT8(1, tuh_audio_active_config(0, 1));
+ TEST_ASSERT_TRUE(tuh_audio_configure(0, 1, 0));
+ TEST_ASSERT_EQUAL_UINT8(0, tuh_audio_active_config(0, 1));
+}
+
+void test_audio_host_rejects_start_at_different_rate_from_running_peer(void) {
+ open_descriptors(uac2_duplex_shared_clock, sizeof(uac2_duplex_shared_clock));
+ TEST_ASSERT_TRUE(audioh_set_config(AUDIO_DEV_ADDR, AUDIO_AC_ITF));
+ complete_uac2_clock_range(44100, 48000);
+
+ TEST_ASSERT_TRUE(tuh_audio_configure(0, 0, 0));
+ TEST_ASSERT_TRUE(tuh_audio_configure(0, 1, 1));
+ TEST_ASSERT_TRUE(tuh_audio_start(0, 0));
+ complete_control_xfer(XFER_RESULT_SUCCESS);
+ complete_interface_set(XFER_RESULT_SUCCESS);
+
+ TEST_ASSERT_FALSE(tuh_audio_start(0, 1));
+ TEST_ASSERT_EQUAL_UINT8(2, control_xfer_count);
+ TEST_ASSERT_EQUAL_UINT8(1, interface_set_count);
+}
+
void test_audio_host_rejects_malformed_uac2_clock_range_and_releases_instance(void) {
open_descriptors(uac2_playback, sizeof(uac2_playback));
TEST_ASSERT_TRUE(audioh_set_config(AUDIO_DEV_ADDR, AUDIO_AC_ITF));