wasapi

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Rendered for windows/amd64

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

Driver implements audio output using the Windows Audio Session API (WASAPI) in shared mode with event-driven buffering.

The driver uses COM interfaces via syscall.SyscallN (zero CGO). A dedicated goroutine (locked to its OS thread) owns all COM state: initialization, the audio pull loop, and teardown.

func New

func New() *Driver

New creates a new WASAPI audio driver.

func (*Driver) Close

func (d *Driver) Close() error

Close stops playback, signals the audio goroutine to exit, and waits for COM cleanup to finish.

func (*Driver) Open

func (d *Driver) Open(sampleRate, channels, bufferSizeMs int) error

Open initializes COM on a dedicated OS thread, obtains the default audio playback device, and prepares a shared-mode WASAPI stream. The stream does not begin playing until Start is called.

func (*Driver) SetSource

func (d *Driver) SetSource(src Source)

SetSource sets the audio data source. The driver pulls from this source in its audio loop.

func (*Driver) Start

func (d *Driver) Start() error

Start begins WASAPI audio streaming. The audio loop goroutine (already running since Open) starts pulling samples from the source and writing them to the hardware buffer.

func (*Driver) Stop

func (d *Driver) Stop() error

Stop pauses audio playback without closing the device.

type Source

type Source interface {
	ReadFloat32s(buf []float32) (int, error)
}

Source provides interleaved float32 PCM samples. This mirrors audio.ReadFloat32er to avoid circular imports.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL