cancel
Showing results for 
Search instead for 
Did you mean: 

USBX Audio Class frame done callback not called

nico23
Senior III

I've set up my STM32U5A9J-DK to use ThreadX and connect to my PC via USBX and Audio Class.

I'm correctly see the Audio Device on my PC and I can easily stream audio to it. The only thing is that, for some reason, the callback for new frame done is not fired

	audio_stream_parameter[0].ux_device_class_audio_stream_parameter_callbacks.ux_device_class_audio_stream_change
	= USBD_AUDIO_PlaybackStreamChange;

	audio_stream_parameter[0].ux_device_class_audio_stream_parameter_callbacks.ux_device_class_audio_stream_frame_done
	= USBD_AUDIO_PlaybackStreamFrameDone;

The strage thing is that USBD_AUDIO_PlaybackStreamChange is correctly called

VOID USBD_AUDIO_PlaybackStreamChange(UX_DEVICE_CLASS_AUDIO_STREAM *audio_play_stream,
                                     ULONG alternate_setting)
{
  /* USER CODE BEGIN USBD_AUDIO_PlaybackStreamChange */

  /* Do nothing if alternate setting is 0 (stream closed).  */
  if (alternate_setting == 0)
  {
    return;
  }

  BufferCtl.state = PLAY_BUFFER_OFFSET_UNKNOWN;

  /* Start reception (stream opened).  */
  ux_device_class_audio_reception_start(audio_play_stream);

  /* USER CODE END USBD_AUDIO_PlaybackStreamChange */

  return;
}

Instead, USBD_AUDIO_PlaybackStreamFrameDone is never called

VOID USBD_AUDIO_PlaybackStreamFrameDone(UX_DEVICE_CLASS_AUDIO_STREAM *audio_play_stream,
                                        ULONG length)
{
  /* USER CODE BEGIN USBD_AUDIO_PlaybackStreamFrameDone */

  UCHAR *frame_buffer;
  ULONG frame_length;

  /* Get access to first audio input frame.  */
  ux_device_class_audio_read_frame_get(audio_play_stream, &frame_buffer, &frame_length);

...
}
4 REPLIES 4
T_Hamdi
ST Employee

Hello @nico23 

To help you fix the issue where the ux_device_class_audio_stream_frame_done callback is not triggered, I recommend referring to the STM32WBA USBX Audio example available here:

STM32WBA BLE USBX Audio Example .

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Hamdi Teyeb
FBL
ST Employee

Hi @nico23 

Would you attach minimum firmware to reproduce the behavior? 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


Hi @FBL 

Here you are https://github.com/NicoCaldo/NovaSonus_ThreadX

I'm seeing that my memory allocation is one-third the one in the example

#define USBX_DEVICE_MEMORY_STACK_SIZE       20 * 1024

vs

#define USBX_APP_MEM_POOL_SIZE       60 * 1024
#define USBX_MEMORY_STACK_SIZE       53 * 1024

Could it be the issue?

 

Hi @nico23 

I suggest isolate the USB audio functionality by disabling other middleware like TouchGFX to rule out conflicts and narrow down the issue. Would you please provide a minimal project based on this STM32U5A9J-DK board, without any other peripherals configured? This will help us assist you more efficiently.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.