-
Notifications
You must be signed in to change notification settings - Fork 915
Additional Sample Format for USB Audio Streaming in usb_device_uac (AEGHB-1139)
#541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- rx/tx and in/out seemed to have created some confusion - documented a short explanation
Log |
usb_host_uacusb_host_uac (AEGHB-1139)
usb_host_uac (AEGHB-1139)usb_device_uac (AEGHB-1139)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the USB Device UAC (USB Audio Class) library with configurable sample formats and fixes critical TX/RX and IN/OUT terminology mixups. The changes enable floating-point audio precision beyond 16-bit PCM and resolve build failures when microphone or speaker channels are disabled.
- Corrected TX/RX and IN/OUT naming confusion throughout the codebase to align with USB perspective conventions
- Added configurable sample format support for both PCM (16-bit) and IEEE floating-point (32-bit) formats
- Fixed conditional compilation guards to prevent build failures when channels are set to 0
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| usb_device_uac.c | Fixed TX/RX macro confusion and added conditional guards for channel configuration |
| uac_descriptors.h | Added sample format macros and updated descriptor definitions to use configurable formats |
| uac_config.h | Added sample format configuration macros based on Kconfig settings |
| tusb_config_uac.h | Corrected TX/RX channel assignments, added format-specific configurations, and improved documentation |
| Kconfig.uac | Added new configuration choices for SPK and MIC sample formats |
| #define UAC2_ENTITY_MIC_FEATURE_TERMINAL 0x12 | ||
| #define UAC2_ENTITY_MIC_OUTPUT_TERMINAL 0x13 | ||
|
|
||
| #if SPK_FORMAT_PCM |
Copilot
AI
Jul 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The macro SPK_FORMAT_PCM may be undefined when neither PCM nor FLOAT is selected, leading to undefined behavior. Consider adding an #else clause with a default format or an #error directive to catch invalid configurations.
| #define SPK_SAMPLE_FORMAT AUDIO_DATA_FORMAT_TYPE_I_IEEE_FLOAT | ||
| #endif | ||
|
|
||
| #if MIC_FORMAT_PCM |
Copilot
AI
Jul 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The macro MIC_FORMAT_PCM may be undefined when neither PCM nor FLOAT is selected, leading to undefined behavior. Consider adding an #else clause with a default format or an #error directive to catch invalid configurations.
| #define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX MIC_CHANNEL_NUM | ||
|
|
||
| // Sample type | ||
| #if SPK_FORMAT_PCM |
Copilot
AI
Jul 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing #else clause for SPK format configuration. If neither SPK_FORMAT_PCM nor SPK_FORMAT_FLOAT is defined, the RX sample configuration will be undefined, leading to compilation errors.
| #define CFG_TUD_AUDIO_FUNC_1_FORMAT_1_RESOLUTION_RX 32 | ||
| #endif | ||
|
|
||
| #if MIC_FORMAT_PCM |
Copilot
AI
Jul 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing #else clause for MIC format configuration. If neither MIC_FORMAT_PCM nor MIC_FORMAT_FLOAT is defined, the TX sample configuration will be undefined, leading to compilation errors.
Description
This PR addresses several issues and improvements in the
usb_host_uaclibrary:Fix build failure when no microphone/speaker channel is configured:
UAC_MIC_CHANNEL_NUMorUAC_SPK_CHANNEL_NUMwere set to 0.Add configurable sample format:
Fix mixup of TX/RX, IN/OUT:
These changes make it easier to stream microphone data over USB with enhanced precision and fix critical issues in the library.
Related
Testing
Checklist
Before submitting a Pull Request, please ensure the following: