summaryrefslogtreecommitdiff
path: root/examples/device/cdc_uac2/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2026-06-18 17:42:51 +0700
committerhathach <[email protected]>2026-06-18 17:42:51 +0700
commit3710e6e5a580fadb53ec2e6cbf12dd6fb65c39c2 (patch)
tree3b72f5daf2aa461ca337a5e473722b630a771a9b /examples/device/cdc_uac2/src
parentedf675f468a9ff7ac8c5e14d41d1060f3296fb2b (diff)
examples/uac2: drop redundant entity_id check in request helpers
The audio20 get/set entity dispatchers already extract entity_id from wIndex and route to the matching clock / feature-unit helper, so each helper's own entity_id re-derivation and TU_ASSERT(entity_id == ...) was dead: the helper is only ever reached for its one entity. Unknown entities are still rejected by the dispatcher's "not handled" path. Remove the redundant local, the dead assert, and the constant "entity" field from each helper's not-supported log (the message text already identifies the entity). The local is dropped entirely rather than kept for the log, since TU_LOG1 compiles out in release and would leave it unused. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Diffstat (limited to 'examples/device/cdc_uac2/src')
-rw-r--r--examples/device/cdc_uac2/src/uac2_app.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/examples/device/cdc_uac2/src/uac2_app.c b/examples/device/cdc_uac2/src/uac2_app.c
index 59c695514..a504c3b57 100644
--- a/examples/device/cdc_uac2/src/uac2_app.c
+++ b/examples/device/cdc_uac2/src/uac2_app.c
@@ -84,10 +84,7 @@ void audio_task(void) {
// Helper for clock get requests
static bool tud_audio_clock_get_request(uint8_t rhport, tusb_control_request_t const *p_request)
{
- uint8_t const entity_id = TU_U16_HIGH(p_request->wIndex);
- uint8_t const ctrl_sel = TU_U16_HIGH(p_request->wValue);
-
- TU_ASSERT(entity_id == UAC2_ENTITY_CLOCK);
+ uint8_t const ctrl_sel = TU_U16_HIGH(p_request->wValue);
if (ctrl_sel == AUDIO20_CS_CTRL_SAM_FREQ)
{
@@ -123,8 +120,8 @@ static bool tud_audio_clock_get_request(uint8_t rhport, tusb_control_request_t c
TU_LOG1("Clock get is valid %u\r\n", cur_valid.bCur);
return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, &cur_valid, sizeof(cur_valid));
}
- TU_LOG1("Clock get request not supported, entity = %u, selector = %u, request = %u\r\n",
- entity_id, ctrl_sel, p_request->bRequest);
+ TU_LOG1("Clock get request not supported, selector = %u, request = %u\r\n",
+ ctrl_sel, p_request->bRequest);
return false;
}
@@ -133,10 +130,8 @@ static bool tud_audio_clock_set_request(uint8_t rhport, tusb_control_request_t c
{
(void)rhport;
- uint8_t const entity_id = TU_U16_HIGH(p_request->wIndex);
- uint8_t const ctrl_sel = TU_U16_HIGH(p_request->wValue);
+ uint8_t const ctrl_sel = TU_U16_HIGH(p_request->wValue);
- TU_ASSERT(entity_id == UAC2_ENTITY_CLOCK);
TU_VERIFY(p_request->bRequest == AUDIO20_CS_REQ_CUR);
if (ctrl_sel == AUDIO20_CS_CTRL_SAM_FREQ)
@@ -151,8 +146,8 @@ static bool tud_audio_clock_set_request(uint8_t rhport, tusb_control_request_t c
}
else
{
- TU_LOG1("Clock set request not supported, entity = %u, selector = %u, request = %u\r\n",
- entity_id, ctrl_sel, p_request->bRequest);
+ TU_LOG1("Clock set request not supported, selector = %u, request = %u\r\n",
+ ctrl_sel, p_request->bRequest);
return false;
}
}
@@ -160,12 +155,9 @@ static bool tud_audio_clock_set_request(uint8_t rhport, tusb_control_request_t c
// Helper for feature unit get requests
static bool tud_audio_feature_unit_get_request(uint8_t rhport, tusb_control_request_t const *p_request)
{
- uint8_t const entity_id = TU_U16_HIGH(p_request->wIndex);
- uint8_t const ctrl_sel = TU_U16_HIGH(p_request->wValue);
+ uint8_t const ctrl_sel = TU_U16_HIGH(p_request->wValue);
uint8_t const channel_num = TU_U16_LOW(p_request->wValue);
- TU_ASSERT(entity_id == UAC2_ENTITY_SPK_FEATURE_UNIT);
-
if (ctrl_sel == AUDIO20_FU_CTRL_MUTE && p_request->bRequest == AUDIO20_CS_REQ_CUR)
{
audio20_control_cur_1_t mute1 = { .bCur = mute[channel_num] };
@@ -191,8 +183,8 @@ static bool tud_audio_feature_unit_get_request(uint8_t rhport, tusb_control_requ
return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, &cur_vol, sizeof(cur_vol));
}
}
- TU_LOG1("Feature unit get request not supported, entity = %u, selector = %u, request = %u\r\n",
- entity_id, ctrl_sel, p_request->bRequest);
+ TU_LOG1("Feature unit get request not supported, selector = %u, request = %u\r\n",
+ ctrl_sel, p_request->bRequest);
return false;
}
@@ -202,11 +194,9 @@ static bool tud_audio_feature_unit_set_request(uint8_t rhport, tusb_control_requ
{
(void)rhport;
- uint8_t const entity_id = TU_U16_HIGH(p_request->wIndex);
uint8_t const ctrl_sel = TU_U16_HIGH(p_request->wValue);
uint8_t const channel_num = TU_U16_LOW(p_request->wValue);
- TU_ASSERT(entity_id == UAC2_ENTITY_SPK_FEATURE_UNIT);
TU_VERIFY(p_request->bRequest == AUDIO20_CS_REQ_CUR);
if (ctrl_sel == AUDIO20_FU_CTRL_MUTE)
@@ -231,8 +221,8 @@ static bool tud_audio_feature_unit_set_request(uint8_t rhport, tusb_control_requ
}
else
{
- TU_LOG1("Feature unit set request not supported, entity = %u, selector = %u, request = %u\r\n",
- entity_id, ctrl_sel, p_request->bRequest);
+ TU_LOG1("Feature unit set request not supported, selector = %u, request = %u\r\n",
+ ctrl_sel, p_request->bRequest);
return false;
}
}