Skip to content

wasapi: prevent audio pops on startup, resume, and seek#2545

Open
0x0003 wants to merge 3 commits into
MusicPlayerDaemon:masterfrom
0x0003:win-wasapi-pop
Open

wasapi: prevent audio pops on startup, resume, and seek#2545
0x0003 wants to merge 3 commits into
MusicPlayerDaemon:masterfrom
0x0003:win-wasapi-pop

Conversation

@0x0003

@0x0003 0x0003 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Fixes annoying audio pops in the wasapi output caused by sample waveform discontinuities. Most of them, at least. The remaining ones can only be masked by something like fade in/out, which MPD doesn't have.

Comment thread src/output/plugins/wasapi/WasapiOutputPlugin.cxx Outdated
Comment thread src/output/plugins/wasapi/WasapiOutputPlugin.cxx Outdated
Comment thread src/output/plugins/wasapi/WasapiOutputPlugin.cxx
Comment thread src/output/plugins/wasapi/WasapiOutputPlugin.cxx
Comment thread src/output/plugins/wasapi/WasapiOutputPlugin.cxx Outdated
Comment thread src/output/plugins/wasapi/WasapiOutputPlugin.cxx Outdated
Comment thread src/output/plugins/wasapi/WasapiOutputPlugin.cxx Outdated
Comment thread src/output/plugins/wasapi/WasapiOutputPlugin.cxx Outdated
Comment thread src/output/plugins/wasapi/WasapiOutputPlugin.cxx Outdated
@0x0003
0x0003 marked this pull request as draft July 15, 2026 23:15
@0x0003

0x0003 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Converting to draft until I can come up with something better with clearer explanations. Most of the current state was done by "throw shit at the wall and see what sticks" principle, and even though it works, I don't understand most of what's going on behind the scenes really.

@MaxKellermann

Copy link
Copy Markdown
Member

Throwing shit is a good approach for the first iteration, but before merging, we need a better understanding of the situation.

Certainly the existing code isn't as good as it should be, and suffers from the same problem; I guess the author didn't have a full understanding either. But new code solves problems, and never introduces new problems. But when I merge changes to existing code, that may introduce new problems, therefore merging code changes needs more thorough review. Because likely you will be gone when the bug reports start coming in, and then it's my problem.

I suggest you try to finish the "primed" patch first, but a simpler version as I described in the comment. It is easy to see that this needs to be improved and how.

0x0003 added 3 commits July 17, 2026 19:54
Call IAudioClient::Reset() when resuming playback after a pause
to flush stale buffered audio and prevent audible pops.
Gate the first Play() call on having enough data in the ring buffer
to fill the entire endpoint buffer.
Stop the IAudioClient before discarding the ring buffer on cancel.
This prevents playing silence after discard, which would cause a pop
when real audio resumes. Push() will restart once the ring buffer is
full.
@0x0003
0x0003 marked this pull request as ready for review July 17, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants