USB Audio Class 1.0 Application Crashes In 1i1o1 Config.

Technical questions regarding the XTC tools and programming with XMOS.
fchin
Member++
Posts: 16
Joined: Fri Jul 15, 2016 6:35 am

USB Audio Class 1.0 Application Crashes In 1i1o1 Config.

Post by fchin »

Hi,

I'm running the USB example code on a xCORE-200 MC board with my custom configuration (1 input and 1 output):

XCC_FLAGS_1i1o1xxxxxx = $(BUILD_FLAGS) -DAUDIO_CLASS=1 -DNUM_USB_CHAN_IN_FS=1 -DNUM_USB_CHAN_IN=1 -DNUM_USB_CHAN_OUT_FS=1 -DNUM_USB_CHAN_OUT=1 -DMAX_FREQ_FS=48000 -DSTREAM_FORMAT_INPUT_1_RESOLUTION_BITS=16 -DSTREAM_FORMAT_OUTPUT_1_RESOLUTION_BITS=16 -DUAC_FORCE_FEEDBACK_EP=1

When I played the test tone from Windows, the application crashed with error:

xrun: Program received signal ET_LOAD_STORE, Memory access exception.
[Switching to tile[1] core[0] (dual issue)]
handle_audio_request (c_mix_out=<value optimized out>) at C:/Users/fchin/workspace/module_usb_audio/usb_buffer/decouple.xc:541

541 read_via_xc_ptr(aud_data_remaining_to_device, g_aud_from_host_rdptr);


However, everything works fine when I had 2 inputs and 2 outputs i.e.
XCC_FLAGS_1i2o2xxxxxx = $(BUILD_FLAGS) -DAUDIO_CLASS=1 -DNUM_USB_CHAN_IN_FS=2 -DNUM_USB_CHAN_IN=2 -DNUM_USB_CHAN_OUT_FS=2 -DNUM_USB_CHAN_OUT=2 -DMAX_FREQ_FS=48000 -DSTREAM_FORMAT_INPUT_1_RESOLUTION_BITS=16 -DSTREAM_FORMAT_OUTPUT_1_RESOLUTION_BITS=16 -DUAC_FORCE_FEEDBACK_EP=1

Do I need extra parameters to get 1 input and 1 output working? Thanks.

Frankie
User avatar
Ross
Verified
XCore Legend
Posts: 1195
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Hi the code base is un-tested/unsupported for channel counts that are not a multiple of two. I suspect there are instances throughout the code where this is assumed. Will take a look to see how much work this would be.
User avatar
Ross
Verified
XCore Legend
Posts: 1195
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Try changing

Code: Select all

-DSTREAM_FORMAT_OUTPUT_1_RESOLUTION_BITS=16
to

Code: Select all

-DSTREAM_FORMAT_OUTPUT_1_RESOLUTION_BITS=24 
I will try and find a solution to the 16bit issue (misaligned memory access) on the output path.
fchin
Member++
Posts: 16
Joined: Fri Jul 15, 2016 6:35 am

Post by fchin »

Hi Ross,

Thanks for the suggestion. I changed from 16-bit to 24-bit resolution. The application didn't crash but Windows reported error saying "Failed to play test tone". However, iOS was able to play successfully.

When running 16-bit the application crashes regardless of using Windows or iOS.
User avatar
Ross
Verified
XCore Legend
Posts: 1195
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

One issue with windows is it caches drivers/settings. Try using usbdeview (http://www.nirsoft.net/utils/usb_devices_view.html) to remove the device.
fchin
Member++
Posts: 16
Joined: Fri Jul 15, 2016 6:35 am

Post by fchin »

Ross,

I used the USBDeview app to remove all the USB drivers associated to XMOS except the XTAG-3. Then I ran USB 1in x 1out application on the XMOS kit. Windows freshly installed the driver but it still failed to play the test tone. Please see the attached screenshot. The mono channel didn't show up in the Speaker Setup dialog.
You do not have the required permissions to view the files attached to this post.
User avatar
Ross
Verified
XCore Legend
Posts: 1195
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

To resolve this issue please make the following change in decouple.xc:

Code: Select all


         if (aud_data_remaining_to_device)
         {
-            /* Round up to nearest word */
-            aud_data_remaining_to_device +=3 - (unpackState&0x3);
-            aud_data_remaining_to_device &= (~3);
-
             /* Skip the rest of this malformed packet */
             g_aud_from_host_rdptr += aud_data_remaining_to_device;

             aud_data_remaining_to_device = 0;
         }

+        /* Round up to nearest word */
+        g_aud_from_host_rdptr += 3 - (unpackState&0x3);
+        g_aud_from_host_rdptr &= (~3);
+

We'll get this released.
fchin
Member++
Posts: 16
Joined: Fri Jul 15, 2016 6:35 am

Post by fchin »

Hi Ross,

Thanks a lot for the fix. It works!