AnsweredAssumed Answered

USB Host Audio Stream Receive Data Length Misreporting

Question asked by Austin Wilhite on Oct 1, 2019

I'm confused about the operation of the USB Host Audio APIs and was hoping someone may be able to clarify a few questions.

 

My RT1050 is setup as a USB Audio Host. I'm able to receive audio data from a connected device by repeatedly calling USB_HostAudioStreamRecv. However, the dataLength parameter returned in the _HostAudioInCallback function is different from what I was expecting.

 

Each time the _HostAudioInCallback is called, the dataLength parameter is set to 128 bytes, despite the audioBuffer passed into the USB_HostAudioStreamRecv function being 2048 bytes.

 

However, looking at the memory location of the audioBuffer, it looks like 2048 bytes of data are written between each call to _HostAudioInCallback.

 

Is anyone able to explain this behavior?

 

#define AUDIO_BUFFER_SIZE (2048u)

static void _HostAudioInCallback(
     void *param,
     uint8_t *data,
     uint32_t dataLength,
     usb_status_t status)
{
    USBHostAudioInstance_t *audioInstance = (USBHostAudioInstance_t *)param;

     if (audioInstance->deviceState == kStatus_DEV_Attached)
     {
          if (status == kStatus_USB_Success)
          {
               DEBUG_USB("%s: Successfully received %u bytes\r\n", __func__);
                }
        }
}


status = USB_HostAudioStreamRecv(audioInstance->classHandle,
                        audioInstance->audioBuffer,
                        AUDIO_BUFFER_SIZE,
                        _HostAudioInCallback,
                        audioInstance);

Outcomes