Kodi Community Forum
Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: Windows (https://forum.kodi.tv/forumdisplay.php?fid=59)
+---- Thread: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. (/showthread.php?tid=378807)



Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - farish - 2024-09-15

Hi, I'm having trouble getting WASAPI exclusive mode to work with a specific audio device: a MOTU UltraLite-mk5 USB audio interface.

Kodi: 21.1.0 x64
Windows: 10 Pro x64 22H2 19045.4894
CPU: Intel Core i7-6700K
RAM: 32GB
Link to log

The two exclusive mode checkboxes in Windows Control Panel are both checked for the UltraLite-mk5.

Important notes:
  • Foobar2000's WASAPI Exclusive mode is working fine with the UltraLite-mk5 on the same system.
  • Kodi's WASAPI Exclusive mode works with a different USB DAC (SteelSeries GameDAC Gen 2) on the same system.
So as you can see, both the UltraLite-mk5 and Kodi support WASAPI, it's just the combination of the two that seems to be problematic. Any ideas how to resolve this? Thanks.


RE: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - jjd-uk - 2024-09-16

Kodi uses Event mode for transfer of audio so it could be the device driver is incompatible. All modern devices should support Event mode, however there is an older Push mode that some vendors still use. I think Foobar2000 has the possibility to toggle between Event/Push, so how was that setup? Make sure it's also in Event mode to see if it has the same problem as Kodi using Event mode.


RE: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - farish - 2024-09-16

(2024-09-16, 10:22)jjd-uk Wrote: Kodi uses Event mode for transfer of audio so it could be the device driver is incompatible. All modern devices should support Event mode, however there is an older Push mode that some vendors still use. I think Foobar2000 has the possibility to toggle between Event/Push, so how was that setup? Make sure it's also in Event mode to see if it has the same problem as Kodi using Event mode.

Double checked this. Yes, Foobar2000 is in Event mode by default. WASAPI works properly with the UltraLite-mk5 in both Event and Push modes from Foobar2000.


RE: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - CrystalP - 2024-09-16

There is a clear error in the log for WASAPI:
 
Code:
CAESinkWASAPI::InitializeExclusive: Failed to initialize WASAPI in exclusive mode -2147024882 - (E_OUTOFMEMORY).

MS documentation or googling didn't show  what this could mean but the requested buffer size seems suspicious for USB devices, though different error messages would be expected if that was the problem. I'll take a look after I'm done with current project.

Does the DAC use Microsoft out of the box drivers or manufacturer drivers? Do you have the latest drivers installed?


RE: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - farish - 2024-09-17

(2024-09-16, 15:42)CrystalP Wrote: There is a clear error in the log for WASAPI:
 
Code:
CAESinkWASAPI::InitializeExclusive: Failed to initialize WASAPI in exclusive mode -2147024882 - (E_OUTOFMEMORY).

MS documentation or googling didn't show  what this could mean but the requested buffer size seems suspicious for USB devices, though different error messages would be expected if that was the problem. I'll take a look after I'm done with current project.

Does the DAC use Microsoft out of the box drivers or manufacturer drivers? Do you have the latest drivers installed?

Thank you. It uses manufacturer drivers. And yes, currently running the latest driver and firmware for this device.


RE: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - CrystalP - 2024-09-23

Looking a little closer at the log, Kodi didn't detect any valid sample rates so there is a defect in the probing code but that doesn't explain the problem later.


RE: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - CrystalP - 2024-09-26

Tonight's v22 nightly will include a fix for the incorrect detection so please try it and provide a new debug log, even if it will still not allow you to play using wasapi.
A portable installation is recommended to avoid impacts on your normal installation and to avoid trouble when you upgrade to v22 final eventually.
I have an idea for the out of memory error but that will be a different change that will likely require significant code changes.


RE: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - farish - 2024-09-27

(2024-09-26, 19:53)CrystalP Wrote: Tonight's v22 nightly will include a fix for the incorrect detection so please try it and provide a new debug log, even if it will still not allow you to play using wasapi.
A portable installation is recommended to avoid impacts on your normal installation and to avoid trouble when you upgrade to v22 final eventually.
I have an idea for the out of memory error but that will be a different change that will likely require significant code changes.
Thanks. Still no WASAPI but here is the log as requested.


RE: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - Karellen - 2024-09-27

(2024-09-27, 11:32)farish Wrote: but here is the log as requested.
You will need to play something with the problem audio and capture that in the log.


RE: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - farish - 2024-09-27

(2024-09-27, 11:47)Karellen Wrote:
(2024-09-27, 11:32)farish Wrote: but here is the log as requested.
You will need to play something with the problem audio and capture that in the log.
Here you go.


RE: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - CrystalP - 2024-09-28

Thanks, the enumeration works correctly now.


RE: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - CrystalP - 2024-09-29

This v22 test build has something that may help with the out of memory error https://mirrors.kodi.tv/test-builds/windows/win64/KodiSetup-20240928-d3760f99-fix-glitch-x64.exe
Please give it a try. However it's just a quick and dirty proof of concept not ready to merge.


RE: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - farish - 2024-09-29

(2024-09-29, 07:30)CrystalP Wrote: This v22 test build has something that may help with the out of memory error https://mirrors.kodi.tv/test-builds/windows/win64/KodiSetup-20240928-d3760f99-fix-glitch-x64.exe
Please give it a try. However it's just a quick and dirty proof of concept not ready to merge.

WASAPI mode is now initialized without failure (LOG) if the file has the same sample rate as what the DAC is currently set to. For example, if the DAC currently in 44k mode and you play 44k file, WASAPI works. This is a huge improvement.

There is still some flakiness when it comes to on-the-fly switching, i.e. playing a file with a sample rate different to what the DAC is currently idle in. I think it might be a timeout issue due to the DAC taking so long to switch modes (It takes a second or more to get a lock with a new sample rate when switching). For example, if the DAC is currently in 96k mode and you play a 48k file in Kodi, the DAC's display indicates that it is switching to 48k mode, but Kodi fails to initialize WASAPI with error: CAESinkWASAPI::Initialize: Could not initialize the WASAPI render client interface. - HRESULT = -2004287484 ErrorMessage = AUDCLNT_E_DEVICE_INVALIDATED. I've also seen the E_OUTOFMEMORY error come up sometimes when it has to autoswitch from a lower to higher sample rate. This behavior is frustratingly inconsistent, sometimes resulting in silence, sometimes falling back on DirectSound.

Since this auto switching issue is likely the DAC's fault, I think the "fix-glitch" build is working about as well as we can hope for with this particular DAC. The most important thing is that WASAPI exclusive is working, so thanks for that.

PS. In my test for the previous nightly build (the log I posted in my last message) I used a 96k test file and I'm pretty sure the DAC was NOT preset to 96k mode when I tried playing it. Given what I said above, you might be wondering if that could have been the cause of WASAPI not initializing during that test. To double check, I reinstalled that build, preset the DAC to 44k mode and played a matching 44k file. WASAPI still failed, so there is definitely a difference in behavior between that last nightly build and the "fix-glitch" build when it comes to this DAC.


RE: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - CrystalP - 2024-09-29

Thanks. That's good news, it looks like the out of memory message was indeed related to the max buffer size.
Can you confirm that this works with 192kHz audio? It requires the largest buffer.
I'd like to see a log with the AUDCLNT_E_DEVICE_INVALIDATED error (log with debug mode activated, unlike the last log).


RE: Kodi "WASAPI initialization failed" with MOTU UltraLite-mk5 USB audio interface. - farish - 2024-09-30

(2024-09-29, 15:21)CrystalP Wrote: Thanks. That's good news, it looks like the out of memory message was indeed related to the max buffer size.
Can you confirm that this works with 192kHz audio? It requires the largest buffer.
I'd like to see a log with the AUDCLNT_E_DEVICE_INVALIDATED error (log with debug mode activated, unlike the last log).

The first time I tested a 192k file (the DAC was already in 192k mode) it failed with the E_OUTOFMEMORY error: LOG

But on subsequent attempts it worked: LOG

Not sure why the inconsistency.

As for the other error, here is an example of it trying to play a 96k file with the DAC starting in 192k mode (the DAC immediately started switching to 96 but took 1 second to finally lock and the audio never played): LOG