coreaudio

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Rendered for darwin/amd64

Overview

Package coreaudio plays PCM through the macOS default output device.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Playback

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

Playback is a buffered sink for planar float32 PCM. CoreAudio converts the queue's input format to the format of the selected system output device.

func OpenPlayback

func OpenPlayback(ctx context.Context, format audio.Format, options PlaybackOptions) (*Playback, error)

OpenPlayback prepares a mono or stereo float32 queue for the macOS default output device. Playback starts with the first nonempty write. Canceling ctx aborts playback and releases the native queue. A nil context returns audio.ErrNilContext.

func (*Playback) Close

func (p *Playback) Close() error

Close aborts playback and releases its native resources. It is safe to call Close concurrently with a blocked write or drain.

func (*Playback) Drain

func (p *Playback) Drain() error

Drain waits until AudioQueue plays all accepted frames and stops. Writes can resume afterward. Canceling the playback context interrupts this wait.

func (*Playback) PCMFormat

func (p *Playback) PCMFormat() audio.Format

PCMFormat reports the input format accepted by the AudioQueue.

func (*Playback) PreferredBlockFrames

func (p *Playback) PreferredBlockFrames() int

PreferredBlockFrames reports the capacity of one native queue buffer.

func (*Playback) WriteFrames

func (p *Playback) WriteFrames(src audio.Buffer[float32]) (int, error)

WriteFrames copies PCM to the native queue, waiting for space when needed.

type PlaybackOptions

type PlaybackOptions struct {
	BlockFrames  int
	QueueBuffers int
}

PlaybackOptions controls buffering. Zero fields select 512 frames per block and four native buffers.

type StatusError

type StatusError struct {
	Operation string
	Status    int32
}

StatusError reports an error returned by AudioQueue Services.

func (*StatusError) Error

func (e *StatusError) Error() string

Jump to

Keyboard shortcuts

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