summaryrefslogtreecommitdiff
path: root/examples/host/audio_host/src
diff options
context:
space:
mode:
authorHiFiPHile <[email protected]>2026-08-27 06:21:18 +0200
committerHiFiPHile <[email protected]>2026-08-27 10:34:34 +0200
commitb23e33a1ce07297df2f37219861d78d2a4cc9809 (patch)
tree0e4d46110d8e82ef28e9836e3a18e5c622b15430 /examples/host/audio_host/src
parentfa6283249362278b887364ae51f9d866fcb96ad3 (diff)
audio: expose generic Audio Control requests
Remove the narrow public Feature Unit request API while retaining managed mute and volume helpers. Expose validated Audio Control descriptors during enumeration and provide raw asynchronous and synchronous entity requests for advanced controls. Signed-off-by: HiFiPHile <[email protected]>
Diffstat (limited to 'examples/host/audio_host/src')
-rw-r--r--examples/host/audio_host/src/audio_app.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/examples/host/audio_host/src/audio_app.c b/examples/host/audio_host/src/audio_app.c
index 4623dff5a..8852ca58c 100644
--- a/examples/host/audio_host/src/audio_app.c
+++ b/examples/host/audio_host/src/audio_app.c
@@ -360,11 +360,9 @@ void tuh_audio_err_cb(uint8_t idx, uint8_t stream_idx, uint16_t xferred_bytes) {
// Print all supported stream configurations
static void print_stream_configs(uint8_t idx, uint8_t stream_idx) {
- const tuh_audio_direction_t dir = tuh_audio_stream_direction(idx, stream_idx);
- const char *dir_name = (dir == TUH_AUDIO_STREAM_CAPTURE) ? "capture" : "playback";
- const uint8_t feature_unit_id = tuh_audio_get_feature_unit_id(idx, stream_idx);
- printf(" %s stream %u Feature Unit ID: %u, configurations: %u\r\n", dir_name, stream_idx, feature_unit_id,
- tuh_audio_config_count(idx, stream_idx));
+ const tuh_audio_direction_t dir = tuh_audio_stream_direction(idx, stream_idx);
+ const char *dir_name = (dir == TUH_AUDIO_STREAM_CAPTURE) ? "capture" : "playback";
+ printf(" %s stream %u, configurations: %u\r\n", dir_name, stream_idx, tuh_audio_config_count(idx, stream_idx));
tuh_audio_volume_range_t range;
if (tuh_audio_mute_supported(idx, stream_idx)) {
printf(" master mute supported\r\n");
@@ -383,17 +381,14 @@ static void print_stream_configs(uint8_t idx, uint8_t stream_idx) {
}
static void configure_stream_controls(uint8_t idx, uint8_t stream_idx, const char *stream_name) {
- const uint8_t feature_unit_id = tuh_audio_get_feature_unit_id(idx, stream_idx);
- if (feature_unit_id == 0) {
- printf(" %s stream has no master mute/volume Feature Unit\r\n", stream_name);
- return;
- }
+ bool has_control = false;
if (tuh_audio_mute_supported(idx, stream_idx)) {
+ has_control = true;
bool mute;
tusb_xfer_result_t result = tuh_audio_mute_get_sync(idx, stream_idx, &mute);
if (result == XFER_RESULT_SUCCESS) {
- printf(" %s Feature Unit %u master mute: %s\r\n", stream_name, feature_unit_id, mute ? "on" : "off");
+ printf(" %s master mute: %s\r\n", stream_name, mute ? "on" : "off");
result = tuh_audio_mute_set_sync(idx, stream_idx, false);
}
if (result != XFER_RESULT_SUCCESS) {
@@ -403,10 +398,11 @@ static void configure_stream_controls(uint8_t idx, uint8_t stream_idx, const cha
tuh_audio_volume_range_t range;
if (tuh_audio_volume_range_get(idx, stream_idx, &range)) {
+ has_control = true;
int16_t volume;
tusb_xfer_result_t result = tuh_audio_volume_get_sync(idx, stream_idx, &volume);
if (result == XFER_RESULT_SUCCESS) {
- printf(" %s Feature Unit %u master volume: %d (1/256 dB)\r\n", stream_name, feature_unit_id, volume);
+ printf(" %s master volume: %d (1/256 dB)\r\n", stream_name, volume);
int32_t target = FEATURE_UNIT_VOLUME_DB;
target = TU_MAX(target, range.min);
target = TU_MIN(target, range.max);
@@ -421,6 +417,10 @@ static void configure_stream_controls(uint8_t idx, uint8_t stream_idx, const cha
printf(" Accessing %s master volume failed: result=%u\r\n", stream_name, result);
}
}
+
+ if (!has_control) {
+ printf(" %s stream has no master mute/volume control\r\n", stream_name);
+ }
}
// Invoked when device with Audio interface is un-mounted