Win DirectSound Buffer Underruns (Windows 11, Bluetooth Audio, Kodi-Specific
#1
Hello!

I'm a long time Kodi user and I've hit a major snag after moving to a new PC. I'm seeking help to understand the root cause of this problem and explore potential solutions that allow DirectSound to function correctly with Bluetooth audio in Kodi on Windows 11. Any insights from developers or experienced users would be immensely appreciated.

Problem Description:

-After migrating from a Windows 10 PC to a new Windows 11 PC, experiencing persistent audio issues specifically when using Bluetooth audio with Kodi in DirectSound mode.
-Issues manifest as stuttering, garbled audio for a couple of seconds, and video playback problems when starting videos in Kodi. After the garbled audio, it never recovers.
-This occurs for any video I have tried. 
-Key Workaround: Starting an audio stream from any other application (Spotify, Chrome, etc.) before opening Kodi completely resolves the issue within Kodi.
-Switching Kodi to WASAPI mode works, but causes unacceptable latency issues with the TempoUp feature I use a ton (to speed up video podcasts).

Version information:
Kodi 20.4.0
Windows 11 23H2
CPU: Intel N95, 64 bit
RAM: 16GB
GPU: Integrated Intel UHD Graphics; Driver version 31.0.101.5186
Bluetooth Adapter: TP-Link Bluetooth 5.3 USB Adapter; Driver version 1.9.1051.3009

Devices relevant to the problem:
-This occurs with any Bluetooth audio device I've tried (two headsets and a speaker)
-I have used 3 different Bluetooth adapters (one built into the PC, two adapters with Bluetooth 4.0 and 5.3 respectively)
-The PC is a Beelink Mini S12

Debug Log :
https://paste.kodi.tv/onixifekiz.kodi
NOTE: It was too large for the sites provided in the sticky so I cut out some of the repeated errors - if you need the FULL log, I can upload it somewhere but I know that is not allowed

Log Analysis:

-Kodi debug log shows repeated instances of these lines during problematic playback:
 "warning <general>: CWin32DirectSound::GetSpace - buffer underrun" 
 "warning <general>: ActiveAE - large audio sync error:"

Troubleshooting Steps Attempted:

-Verified latest Bluetooth adapter drivers on both old and new PCs. Tested with multiple Bluetooth adapters (standards 3.0 and 5.3).
-Tested with Bluetooth headphones and a Bluetooth speaker, issue persists on both.
-Confirmed no physical interference or distance issues.
-Ensured Kodi is fully updated.
-Removed background apps, disabled real-time antivirus protection.
-Tweaked Kodi audio settings (channels, resample quality, "keep alive", Output configuration (most notably set to Fixed, 44.1 kHz)).
-Tested changing other settings (Adjust refresh rate, Sync playback to display)
-Experimented with 'advancedsettings.xml' (buffer settings mostly - tried large and 0 buffer, multiple buffermodes).
-Tried clean Kodi install with minimal/default configuration. 
-Old PC (Windows 10) with same Bluetooth adapter and Kodi settings works without issue.

System Considerations:

-Issue is isolated to Kodi:  Bluetooth audio works correctly on my new Windows 11 PC with other applications. 
-Windows 10 vs. 11 Factor: The problem started specifically upon migrating to a new Windows 11 PC.

Any input you can provide would be appreciated!!

-attmay
Reply
#2
I'm hoping someone has an idea of things to try. I did come across this bug report which seems similar: https://github.com/xbmc/xbmc/issues/20567  It looks like it was deemed to be a Windows issue, however I believe my steps above make it very clear that this is specific to Kodi only. 

-attmay
Reply
#3
I have same issue.
Reply
#4
As an update, I have determined there is definitely an interaction between some Bluetooth devices and Kodi. Others seem to work fine. I am still confident this is specific to Kodi because it does not happen to any other application I've tested. I hope that someone is able to take a look and provide guidance. I have replicated this behavior on multiple Windows 11 PCs now, so it wasn't super specific to my first testing PC.

-attmay
Reply
#5
Another update: I have confirmed this still happens in version 21. I am unsure how to proceed with getting help on this as it appears it may be a niche issue. If anyone has ideas, I'm very open to trying things!

-attmay
Reply
#6
The problem is that none of the Windows dev seem to have a similar software and hardware combination that produces the glitch.
Always read the Kodi online-manual, the FAQ and search the forum before posting.
Do not e-mail Kodi Team members directly asking for support. Read/follow the forum rules (wiki).
For troubleshooting and bug reporting please make sure you read this first.
Reply
#7
That makes sense. I know that others are experiencing it, so it's not 100% specific to me, but I can see it being difficult if it cannot be replicated. I feel pretty strongly that it should be replicable with any new Bluetooth Adapter / Audio Device combination on Windows 11. I am trying to figure out a way to try this with an old adapter that doesn't support newer Bluetooth functionality, but haven't been able to track down old drivers for the adapters I can find. 

I was hopeful that this issue could be revisited: https://github.com/xbmc/xbmc/issues/20567  But I understand this is a fairly niche use of Kodi. 

-attmay
Reply
#8
it is pretty easy to replicate the issue. It happens with Sony WH1000XM4 noise cancellation headphone in my case on different laptops. My OontZ Angle Bluetooth speaker does not have this issue.
Reply
#9
Test builds with larger DirectSound buffer: current is 180 ms, build_1 is 300 ms and build_2 450 ms

300 ms
https://mirrors.kodi.tv/test-builds/wind...st-x64.exe 

450 ms
https://mirrors.kodi.tv/test-builds/wind...-2-x64.exe

EDIT: other build to test 400 ms but different (50 ms * 8 chunks) instead to current 15 ms chunks

400 ms
https://mirrors.kodi.tv/test-builds/wind...-3-x64.exe


Someone affected should try them and tell us if either version fixes the BT sound issues.
Reply
#10
I just tested all three builds and can confirm they all fix it! I then reverted back to the normal build and it was still broken, so I am confident in my testing. I can't discern a difference between how the three builds behave in my testing. All three function and resolve the reported behavior for me on two previously impacted Bluetooth audio devices. 

Thank you for taking the time to look into this! I'm happy to perform more testing or provide whatever information you need to help make this a part of Kodi going forward!
Reply
#11
New build to test:

250 ms
https://mirrors.kodi.tv/test-builds/wind...-4-x64.exe

If works, the final solution should be very similar.

Ideally, more people should try it since it might not solve all cases.
Reply
#12
I can confirm that this build does not fix the issue for me. It almost seems worse, honestly, because the normal workaround I was using (playing music in Spotify while starting audio) didn't work either. I had to roll back to one of the other builds you provided to get it working again.
Reply
#13
PR opened: https://github.com/xbmc/xbmc/pull/25046
Reply
#14
My test results:
250ms: No sound at all.
300ms: works.
400ms: works.
450ms: works.
Reply
#15
Fix already merged in master branch.

Affected users who want to use v21/Omega will have to use this build for the time being:

KodiSetup-20240423-e77cb18f-fix-DirectSound-Omega-x64.exe
Reply

Logout Mark Read Team Forum Stats Members Help
DirectSound Buffer Underruns (Windows 11, Bluetooth Audio, Kodi-Specific0