Skip to content

feat: WASAPI driver — Pure Go audio output (ADR-001, v0.1.0) - #1

Merged
kolkov merged 1 commit into
mainfrom
feat/wasapi-driver-v0.1.0
May 9, 2026
Merged

feat: WASAPI driver — Pure Go audio output (ADR-001, v0.1.0)#1
kolkov merged 1 commit into
mainfrom
feat/wasapi-driver-v0.1.0

Conversation

@kolkov

@kolkov kolkov commented May 9, 2026

Copy link
Copy Markdown
Contributor

Summary

First working release of gogpu/audio — Pure Go audio engine with WASAPI driver.

WASAPI Driver (Windows)

  • COM vtable via syscall.SyscallN (same pattern as wgpu DX12 backend)
  • Shared mode, event-driven, AUTOCONVERTPCM
  • Pull model: background goroutine reads from Mixer via ReadFloat32er
  • internal/wasapi/ hides COM implementation from public API

Core

  • Context (singleton, auto-selects platform driver)
  • Player (io.Reader PCM stream, play/pause/stop/volume)
  • WAV decoder (8/16/24/32-bit PCM + float32)
  • Mixer (multi-channel, per-source + master volume)
  • NullDriver (testing/headless)

Verified

  • 440Hz sine wave plays through Windows speakers
  • 42 tests, 94.8% coverage
  • Lint 0 issues (Windows, Linux, macOS)

Test plan

  • go build ./...
  • go test ./... — 42 pass
  • golangci-lint run — 0 issues (3 platforms)
  • Visual: 440Hz sine wave audible on Windows
  • CI

Working Windows audio output through WASAPI shared mode. Zero CGO.

Architecture:
- internal/wasapi/ — COM vtable structs, driver implementation
- wasapiWrapper in audio/ adapts internal driver to public interface
- Pull model: background goroutine reads from Mixer via ReadFloat32er
- Event-driven: WaitForSingleObject on WASAPI buffer events

WASAPI flow: CoInitializeEx → MMDeviceEnumerator → GetDefaultAudioEndpoint
→ IAudioClient.Initialize(SHARED, AUTOCONVERTPCM) → IAudioRenderClient
→ audio loop (GetBuffer → fill from Mixer → ReleaseBuffer)

Fixes:
- AUDCLNT_E_UNSUPPORTED_FORMAT (0x88890008): added AUTOCONVERTPCM +
  SRC_DEFAULT_QUALITY flags — WASAPI handles format conversion
- Tests use NullDriver explicitly (no real audio device in CI)
- Driver interface refined: pull model with ReadFloat32er

Verified: 440Hz sine wave plays through speakers on Windows.
42 tests pass, lint 0 issues (Windows/Linux/macOS).
@codecov

codecov Bot commented May 9, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@kolkov
kolkov merged commit 86eac9c into main May 9, 2026
8 of 9 checks passed
@kolkov
kolkov deleted the feat/wasapi-driver-v0.1.0 branch May 9, 2026 23:18
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