Skip to content

Defer audio engine init to first playSound call - #3684

Merged
hluk merged 1 commit into
masterfrom
lazy-audio-engine
Aug 23, 2026
Merged

hluk merged 1 commit into
masterfrom
lazy-audio-engine

Conversation

@hluk

@hluk hluk commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Initialize the miniaudio engine lazily on the first playSound() call instead of at startup. Release the engine once all sounds finish playing.

This avoids holding a persistent PulseAudio/PipeWire connection while idle, which caused ~1-2% background CPU from the audio socket dispatch thread and a spurious "playing audio" status in the desktop environment.

Assisted-by: Claude (Anthropic)

@codecov

codecov Bot commented Aug 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.69565% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.45%. Comparing base (e9544c1) to head (28a8ef8).

Files with missing lines Patch % Lines
src/common/audioplayer.cpp 58.69% 19 Missing ⚠️

❌ Your patch check has failed because the patch coverage (58.69%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3684      +/-   ##
==========================================
- Coverage   74.49%   74.45%   -0.04%     
==========================================
  Files         256      256              
  Lines       37993    38008      +15     
  Branches     5118     5118              
==========================================
- Hits        28303    28299       -4     
- Misses       9690     9709      +19     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hluk
hluk force-pushed the lazy-audio-engine branch from 224f72e to 5a874e8 Compare August 22, 2026 10:06
Initialize the miniaudio engine lazily on the first playSound()
call instead of at startup. Release the engine once all sounds
finish playing.

This avoids holding a persistent PulseAudio/PipeWire connection
while idle, which caused ~1-2% background CPU from the audio
socket dispatch thread and a spurious "playing audio" status
in the desktop environment.

Assisted-by: Claude (Anthropic)
@hluk
hluk force-pushed the lazy-audio-engine branch from 5a874e8 to 28a8ef8 Compare August 22, 2026 10:31
@hluk
hluk merged commit 0cfd624 into master Aug 23, 2026
12 of 13 checks passed
@hluk
hluk deleted the lazy-audio-engine branch August 23, 2026 06:29
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.

1 participant