Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSP: Copy audio dma samples one block at a time #10741

Merged
merged 2 commits into from Oct 24, 2022

Conversation

Pokechu22
Copy link
Contributor

This fixes missing audio in various Datel titles; see https://bugs.dolphin-emu.org/issues/12281. They send a large number of samples at the same time, since they don't have to deal with an actual DSP program generating them. Before, we were sending all of the samples at once, which would be too large to ever fit in the buffer in Mixer.cpp and thus the code that prevents overflowing the buffer rejected the samples. This new approach should be more hardware-accurate, though I haven't done any testing related to it.

Compared to #10738, this change does not result in audio desyncs after pressing tab to disable the speed limit, and I never encountered any duplicated sound effects on Datel titles.

This PR reverts #720 (but it keeps the length 0 change from #762). Other PRs that are good for context are #692 and #762. I don't own Xenoblade Chronicles, so I haven't confirmed whether this causes issues for it.

This PR also fixes a broken size check in WaveFile. That check used to be relevant for the Wii-compatible Action Replay (which would crash Dolphin if audio dumping was enabled), but the other change in this PR means that only 8 samples at a time are getting written. Still, it's better to fix it.

@Pokechu22 Pokechu22 force-pushed the audio-dma-one-block-at-a-time branch from cdf1382 to ab49cb1 Compare June 11, 2022 18:58
@Pokechu22 Pokechu22 marked this pull request as ready for review June 11, 2022 18:58
@PatrickFerry
Copy link
Contributor

PatrickFerry commented Jun 11, 2022

Also fixes https://bugs.dolphin-emu.org/issues/9410 or at least the audio crackling doesn't happen anymore.

The previous PR (#10738) didn't change the behaviour.

@Pokechu22 Pokechu22 force-pushed the audio-dma-one-block-at-a-time branch from ab49cb1 to 6725fbd Compare June 12, 2022 00:34
@Pokechu22 Pokechu22 force-pushed the audio-dma-one-block-at-a-time branch from 6725fbd to 9f424b4 Compare June 12, 2022 18:34
@Pokechu22 Pokechu22 force-pushed the audio-dma-one-block-at-a-time branch 3 times, most recently from 4711687 to 5b79f41 Compare June 25, 2022 02:48
@AdmiralCurtiss
Copy link
Contributor

Can we get a review here of someone who's familiar with the DSP/Audio stuff?

Reverts 9f8e1e2, but keeps the changes from e4e4490.

This fixes missing audio in Datel titles; see https://bugs.dolphin-emu.org/issues/12281.
`count` is the number of stereo samples to write (where each stereo sample is two shorts), while `BUFFER_SIZE` is the size of the buffer in shorts.  So `count` needs to be multiplied by `2`, not `BUFFER_SIZE`.  Also, when this check was failed, the previous code just clobbered whatever was past the end of the buffer after logging the warning, which corrupted `basename`, eventually resulting in Dolphin crashing.

This affected Datel's Wii-compatible Action Replay, which uses a block size of 2298, or 18384 stereo samples, which is 36768 shorts, which is bigger than the buffer size of 32768. (However, the previous commit means that only one block is transfered at a time, eliminating this issue; fixing the bounds check is just a general safety thing instead of an actual bugfix now.)
@Pokechu22 Pokechu22 force-pushed the audio-dma-one-block-at-a-time branch from 1eb2151 to 6de55e4 Compare October 22, 2022 18:45
@JMC47
Copy link
Contributor

JMC47 commented Oct 24, 2022

If this breaks audio, let it be known that I showed restraint and gave people months to review it before deciding that my shitty unlicensed games needed some love.

@JMC47 JMC47 merged commit 4787b25 into dolphin-emu:master Oct 24, 2022
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants