diff options
| author | HiFiPHile <[email protected]> | 2026-08-25 09:27:36 +0200 |
|---|---|---|
| committer | HiFiPHile <[email protected]> | 2026-08-25 09:27:36 +0200 |
| commit | b26958c47e70d659620ec391731b37c6d1c66ea7 (patch) | |
| tree | 9fc702254f1995a240af7c526e42948d2936c7ca /examples | |
| parent | ebec43ef01258e1abd37a08f603c940690257951 (diff) | |
feat(audio): track a Feature Unit per stream direction
Associate one directly connected Feature Unit with each capture and playback stream. This lets applications control microphone and speaker paths independently.
Signed-off-by: HiFiPHile <[email protected]>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/host/audio_host/README.md | 5 | ||||
| -rw-r--r-- | examples/host/audio_host/src/audio_app.c | 10 |
2 files changed, 10 insertions, 5 deletions
diff --git a/examples/host/audio_host/README.md b/examples/host/audio_host/README.md index 2ad3f40d6..c7cad5bfa 100644 --- a/examples/host/audio_host/README.md +++ b/examples/host/audio_host/README.md @@ -20,6 +20,11 @@ This example supports any UAC 1.0 compliant USB audio device with a discrete sam The echo needs a matching S16_LE playback stream at the capture sample rate; devices without one run capture-only. The sample rate and channel preferences are configured by the `SAMPLE_RATES` / `AUDIO_MAX_CHANNELS` macros in `src/audio_app.c` (48 kHz stereo by default). Continuous sampling-frequency ranges are exposed as a single configuration at the range's highest frequency (e.g. a 8000–48000 Hz speaker appears as 48000 Hz); non-PCM formats are rejected by the driver. +## Limitations and trade-offs + +- The Feature Unit API exposes one directly connected Feature Unit per logical capture/playback stream. If several Feature Units map to the same logical stream, the first mapping is retained. +- The UAC1 `MaxPacketsOnly` endpoint attribute is not supported. OUT transfers are not padded to `wMaxPacketSize`, and padding in IN transfers is not removed from the reported audio data. + ## Building ### Using CMake (recommended) diff --git a/examples/host/audio_host/src/audio_app.c b/examples/host/audio_host/src/audio_app.c index c3bd59abf..6639b7ec5 100644 --- a/examples/host/audio_host/src/audio_app.c +++ b/examples/host/audio_host/src/audio_app.c @@ -243,12 +243,12 @@ void led_blinking_task(void) { #if 0 // Print the current Feature Unit volume, which is set to 0x0600 in mic_configured() and can be changed by the device. uint16_t volume = 0x0001; - tuh_audio_feature_unit_get_sync(audio_idx, AUDIO10_FU_CTRL_VOLUME, 0, &volume); + tuh_audio_feature_unit_get_sync(audio_idx, cap_stream_idx, AUDIO10_FU_CTRL_VOLUME, 0, &volume); printf(" Feature Unit volume get: 0x%04x\r\n", (unsigned int)volume); uint16_t mute = 0x0000; - tuh_audio_feature_unit_get_sync(audio_idx, AUDIO10_FU_CTRL_MUTE, 0, &mute); + tuh_audio_feature_unit_get_sync(audio_idx, cap_stream_idx, AUDIO10_FU_CTRL_MUTE, 0, &mute); mute=!mute; // toggle mute for demonstration - tuh_audio_feature_unit_set_sync(audio_idx, AUDIO10_FU_CTRL_MUTE, 0, mute); + tuh_audio_feature_unit_set_sync(audio_idx, cap_stream_idx, AUDIO10_FU_CTRL_MUTE, 0, mute); printf(" Feature Unit mute set: 0x%04x\r\n", (unsigned int)mute); #endif } @@ -368,10 +368,10 @@ static void mic_configured(uint8_t idx, uint8_t stream_idx, tusb_xfer_result_t r mic_ready = tuh_audio_start(idx, stream_idx); uint16_t volume = 0x0600; - result = tuh_audio_feature_unit_set_sync(idx, AUDIO10_FU_CTRL_VOLUME, 0, volume); + result = tuh_audio_feature_unit_set_sync(idx, stream_idx, AUDIO10_FU_CTRL_VOLUME, 0, volume); if (result == XFER_RESULT_SUCCESS) { printf(" Feature Unit volume set:volume 0x%04x\r\n", (unsigned int)volume); - tuh_audio_feature_unit_get_sync(idx, AUDIO10_FU_CTRL_VOLUME, 0, &volume); + tuh_audio_feature_unit_get_sync(idx, stream_idx, AUDIO10_FU_CTRL_VOLUME, 0, &volume); printf(" Feature Unit volume get: 0x%04x\r\n", (unsigned int)volume); } else { printf(" Setting Feature Unit volume FAILED: result=%u\r\n", result); |
