Emulator Issues #9410
Audio Crackling in Homebrew Demo, not present on 4.0.2
GRLLib 4.3.0 Demo Presentation
Game ID? (right click the game in the game list, properties, info tab)
What's the problem? Describe what went wrong.
Using HLE or LLE, XAudio2 and OpenAL results in audio crackling when running the program, even though VPS and FPS remain a solid 60
What steps will reproduce the problem?
- Enable Virtual XFB, EFB2RAM (Required for proper video emulation)
- Start the dol, and listen
Which versions of Dolphin did you test on? Does using an older version of Dolphin solve your issue? If yes, which versions of Dolphin used to work?
4.0.2 - No issue on LLE or HLE (although video emulation is incorrect)
What are your PC specifications? (CPU, GPU, Operating System, more)
i5-4670k @ 4.4GHz
Is there any other relevant information? (e.g. logs, screenshots,
#2 Updated by Helios about 5 years ago
If you're on windows and can't (easily) use git bisect, use this https://forums.dolphin-emu.org/Thread-green-notice-development-thread-unofficial-dolphin-bisection-tool-for-finding-broken-builds
And yes, please bisect this.
#5 Updated by ASSympt0te about 5 years ago
#14 Updated by degasus about 5 years ago
- Status changed from Fix pending to Accepted
- Assignee deleted (
- Priority changed from High to Normal
The bisect is wrong, this commit makes the stutter worse, but it's not the source of the issue. AI sends more DMA samples than expected, likely because of the homebrew very often enables / disabled DMA streaming: https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/Core/HW/DSP.cpp#L432
So the linked patch is wrong.
#18 Updated by degasus about 5 years ago
About the issue: We send the correct amount of samples triggered by coretiming. But within https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/Core/HW/DSP.cpp#L432 , we also send samples on enable/disable the DMA. So if a game enables/disables very often, we send more samples than expected. No idea if this line is just wrong, or if we need to restart the coretiming event on every enable/disable action.
#22 Updated by phire almost 5 years ago
I'm pretty sure loading samples on enable/disable DMA is correct, but I think the AudioDMACallback which runs at 4khz needs to have it's phase adjusted to match the timing of enabling the DMA.
If the homebrew is ignoring the Audio DMA interrupt + latching for correct timing (which will quickly force any game into whatever phase that dolphin chooses) and is using timers to manually trigger the Audio DMA at the correct time... you could get issues.
#23 Updated by phire almost 5 years ago
So... I've looked into this.
Dolphin currently latches the new values onto the Audio DMA at the start of a new transferer. Because this Homebrew hasn't updated the buffer, dolphin goes back to the start of previous buffer and loads the entire thing (512 samples). Then dolphin fires the Audio DMA interrupt.
The game sees this interrupt and stops the Audio DMA, loads the new address into it and starts a new transfer.
I've experimented and it looks like the re-latching interrupt is meant to fire soon enough that this homebrew can successfully restart the DMA at a new address before any samples are read out of memory.