summaryrefslogtreecommitdiff
path: root/examples/host/audio_host/src/audio_app.c
diff options
context:
space:
mode:
authorHiFiPHile <[email protected]>2026-09-02 15:22:07 +0200
committerHiFiPHile <[email protected]>2026-09-02 15:24:36 +0200
commit1ff684a07ec5d80a89ba82276139a202288b7716 (patch)
tree96aab26ac287e2e2e976b1187baa050338f25b45 /examples/host/audio_host/src/audio_app.c
parent93545d0bfb90b48a33a08b8b12df21a886b7a338 (diff)
implement per channel volume control
Signed-off-by: HiFiPHile <[email protected]>
Diffstat (limited to 'examples/host/audio_host/src/audio_app.c')
-rw-r--r--examples/host/audio_host/src/audio_app.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/examples/host/audio_host/src/audio_app.c b/examples/host/audio_host/src/audio_app.c
index 55efe3295..749274f44 100644
--- a/examples/host/audio_host/src/audio_app.c
+++ b/examples/host/audio_host/src/audio_app.c
@@ -365,7 +365,7 @@ static void print_stream_configs(uint8_t idx, uint8_t stream_idx) {
printf(" master mute supported\r\n");
}
if (tuh_audio_volume_range_get(idx, stream_idx, &range)) {
- printf(" master volume range: min=%d max=%d res=%u (1/256 dB)\r\n", (int)range.min, (int)range.max,
+ printf(" volume range: min=%d max=%d res=%u (1/256 dB)\r\n", (int)range.min, (int)range.max,
(unsigned)range.res);
}
for (uint8_t i = 0; i < tuh_audio_config_count(idx, stream_idx); i++) {
@@ -397,26 +397,26 @@ static void configure_stream_controls(uint8_t idx, uint8_t stream_idx, const cha
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);
+ tusb_xfer_result_t result = tuh_audio_volume_get_sync(idx, stream_idx, 0, &volume);
if (result == XFER_RESULT_SUCCESS) {
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);
- target = range.min + ((target - range.min + range.res / 2) / range.res) * range.res;
- target = TU_MIN(target, range.max);
- result = tuh_audio_volume_set_sync(idx, stream_idx, (int16_t)target);
- if (result == XFER_RESULT_SUCCESS) {
- printf(" %s master volume set: %d (1/256 dB)\r\n", stream_name, (int)target);
- }
+ }
+ int32_t target = FEATURE_UNIT_VOLUME_DB;
+ target = TU_MAX(target, range.min);
+ target = TU_MIN(target, range.max);
+ target = range.min + ((target - range.min + range.res / 2) / range.res) * range.res;
+ target = TU_MIN(target, range.max);
+ result = tuh_audio_volume_set_sync(idx, stream_idx, 0, (int16_t)target);
+ if (result == XFER_RESULT_SUCCESS) {
+ printf(" %s volume set: %d (1/256 dB)\r\n", stream_name, (int)target);
}
if (result != XFER_RESULT_SUCCESS) {
- printf(" Accessing %s master volume failed: result=%u\r\n", stream_name, result);
+ printf(" Setting %s 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);
+ printf(" %s stream has no mute/volume control\r\n", stream_name);
}
}