fix(sound): use Web Audio API to fix PipeWire node accumulation and volume resets#1548
Open
aspiers wants to merge 1 commit intoEpicenterHQ:mainfrom
Open
fix(sound): use Web Audio API to fix PipeWire node accumulation and volume resets#1548aspiers wants to merge 1 commit intoEpicenterHQ:mainfrom
aspiers wants to merge 1 commit intoEpicenterHQ:mainfrom
Conversation
Replace HTMLAudioElement with a shared AudioContext for sound playback. HTMLAudioElement creates a new PipeWire node per element, and WebKit tears down/recreates the node on any src change, causing WirePlumber to restore full volume (1.0) before user adjustments can be saved back. A single AudioContext maintains one stable PipeWire node for the app's lifetime, allowing WirePlumber to reliably persist volume changes. Decoded audio buffers are cached in memory for efficient replay.
Author
|
CI failure is pre-existing on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces
HTMLAudioElementwith the Web Audio API (AudioContext+BufferSourceNode) for sound playback. This fixes both the PipeWire node accumulation from #842 and a volume reset issue on Linux where WirePlumber restores full volume on every sound play.Supersedes #1374.
Problem
HTMLAudioElementhas two issues on Linux with PipeWire/WirePlumber:Node accumulation (Ubuntu 25.04: lots of "whispering" entries in System -> Sounds -> Volume Levels #842): Each
Audioelement registers a PipeWire output node that persists as long as the element is reachable. The original code cached 8 elements at module load, and HMR reloads orphaned old elements without releasing their nodes.Volume resets: fix(sound): release Audio elements after playback to prevent PipeWire node leaks #1374 fixed accumulation by creating a fresh element per playback and tearing it down after
ended. However, WebKit tears down and recreates the underlying PipeWire media pipeline on every newAudio()orsrcchange, so WirePlumber sees each playback as a brand-new stream and restores it to its database volume (1.0 / full) before the user's adjustment can be saved back.Solution
A single
AudioContextis created lazily on first use and kept alive for the app's lifetime. This registers exactly one PipeWire node that persists across all sound playback. Audio files are decoded once intoAudioBuffers (cached in memory), and eachplaySound()call creates a lightweightBufferSourceNode— no new PipeWire nodes.endedevent race conditions that could hang the playback promiseFixes #842