summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiFiPHile <[email protected]>2026-08-27 03:31:01 +0200
committerHiFiPHile <[email protected]>2026-08-27 10:34:34 +0200
commit178426720cbe2f170872cc1469329570d37726a3 (patch)
treea6b280b93ff8a4861065624c8761665a823bd4a0 /test
parent6019e538125e9863a4fa4bcf0b026d3e639a1a4d (diff)
audio: normalize Feature Unit volume requests
Accept the defined silence value and round ordinary volume requests to the nearest supported resolution step within the cached range. Add tests for silence, clamping, and step alignment. Signed-off-by: HiFiPHile <[email protected]>
Diffstat (limited to 'test')
-rw-r--r--test/unit-test/test/host/audio/test_audio_host.c16
1 files changed, 16 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 55b5e8ef6..aa2f70f9b 100644
--- a/test/unit-test/test/host/audio/test_audio_host.c
+++ b/test/unit-test/test/host/audio/test_audio_host.c
@@ -1536,6 +1536,22 @@ void test_audio_host_typed_mute_and_volume_controls(void) {
TEST_ASSERT_EQUAL_HEX32(0x4567, fu_cb_user_data);
}
+void test_audio_host_volume_set_accepts_silence_and_rounds_unaligned_values(void) {
+ tuh_audio_volume_range_t range;
+ mount_descriptors(playback_fu_before_terminal, sizeof(playback_fu_before_terminal));
+ TEST_ASSERT_TRUE(tuh_audio_volume_range_get(0, 0, &range));
+
+ TEST_ASSERT_TRUE(tuh_audio_volume_set(0, 0, (int16_t)(-6 * 256 + 100), feature_unit_complete, 0));
+ TEST_ASSERT_EQUAL_UINT8(1, control_xfer_count);
+ TEST_ASSERT_EQUAL_HEX8_ARRAY(((uint8_t[]){0x00, 0xFA}), control_buffer, 2);
+ complete_control_xfer(XFER_RESULT_SUCCESS);
+
+ TEST_ASSERT_TRUE(tuh_audio_volume_set(0, 0, TUH_AUDIO_VOLUME_SILENCE, feature_unit_complete, 0));
+ TEST_ASSERT_EQUAL_UINT8(2, control_xfer_count);
+ TEST_ASSERT_EQUAL_HEX8_ARRAY(((uint8_t[]){0x00, 0x80}), control_buffer, 2);
+ complete_control_xfer(XFER_RESULT_SUCCESS);
+}
+
void test_audio_host_schedules_44100_hz_fractional_packets_with_max_packets_only(void) {
uint8_t samples[441 * 4] = {0};
mount_descriptors(playback_44100_max_packets_only, sizeof(playback_44100_max_packets_only));