In the 5.0 USB stack, in usb_audio.c, in routine USB_Class_Audio_Init(), I find the following:
for (index = 0; index < p_usb_data_ut->count; index++)
{
devicePtr->audio_ut_data.ut[index].unit_id = p_usb_data_ut->put[index].unit_id;
devicePtr->audio_ut_data.ut[index].type = p_usb_data_ut->put[index].type;
}
I find no reference whatsoever to "audio_ut_data" anywhere else in the code, making the two assignments and the loop around them an apparent waste of time, energy, electrons, memory, and processor cycles.
What am I missing here?
Hi John,
I think you are right. The "audio_ut_data" is redundant, since the "usb_ut_data" structure has got all it endpoint information for this interface. We will remove these lines and the struct member from the audio_device_struct_t.
Hi John,
You could find the "audio_ut_data" defined at audio_device_struct struct located at <usb_audio.h> with below code:
/* Strucutre holding AUDIO class state information*/
typedef struct audio_device_struct
{
audio_handle_t audio_handle;
class_handle_t class_handle;
uint32_t user_handle;
usb_device_handle handle;
usb_endpoints_t* usb_ep_data;
audio_units_struct_t* usb_ut_data;
audio_ut_data_struct_t audio_ut_data;
audio_endpoint_data_struct_t audio_endpoint_data;
usb_application_callback_struct_t audio_application_callback;
usb_vendor_req_callback_struct_t vendor_req_callback;
usb_class_specific_callback_struct_t class_specific_callback;
usb_desc_request_notify_struct_t desc_callback;
uint8_t current_interface;
}audio_device_struct_t;
typedef struct _audio_ut_data_struct
{
audio_ut_struct_t ut[MAX_AUDIO_CLASS_UT_NUM];
}audio_ut_data_struct_t;
The "audio_ut_struct_t" definition located at <usb_class_audio.h> line179:
typedef struct _audio_ut_struct
{
uint8_t unit_id; /* endpoint number */
uint8_t type; /* type of endpoint */
}audio_ut_struct_t;
Wish it helps.
Have a great day,
best regards,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Sorry, I didn't make myself clear enough.
What I intended to communicate is that, after the endpoint number and type is copied into the ut array in the audio_ut_data member of the audio_device_struct_t, it is never used ANYWHERE. There is apparently no point in copying the data in the first place.
Immediately after the lines I quoted, there is a line
devicePtr->usb_ut_data = p_usb_data_ut;
that saves the pointer to the source data from which the items were copied. That pointer, and the original endpoint number and type data, as opposed to the COPIED endpoint number and type data, is used in three (3) places in usb_audio.c.
What I'm saying is that the audio_ut_data member, and the copy into it, appears to be superfluous and could be deleted.