Documentation
¶
Overview ¶
Package coreaudio names the machine's audio devices, so a program can send its sound somewhere in particular instead of wherever the system happens to be pointing.
The need is ordinary and the default is wrong often enough to matter: a film played on a pair of XR glasses draws its picture on the glasses and, with no device named, plays its sound out of the Mac's own speakers. Nothing reports an error, because nothing went wrong -- the sound simply went to the default output, which is not where the person is looking.
What is here is enumeration and identity, not playback. A device's Device.UID is the string AVFoundation and AudioQueue both take to be told where to play, and it is stable across reboots and re-plugs, unlike the numeric ids beside it, which are not.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupported = errors.New("coreaudio: only macOS has CoreAudio")
ErrUnsupported is returned by every call off macOS. CoreAudio is a macOS framework; there is nothing here to fall back to, and pretending otherwise would hand a caller an empty device list that looks like a machine with no sound card.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
// UID identifies the device to the rest of CoreAudio, and keeps identifying
// it after a reboot or a re-plug. It is what a setting should store; the
// name is what a person should read.
UID string
// Name is the name shown in Sound settings.
Name string
// Outputs is how many output streams the device publishes, and Inputs how
// many input ones. A device is not necessarily either: a microphone has no
// outputs, and asking it to play sound would fail for a reason nobody would
// guess from "device not found".
Outputs, Inputs int
}
Device is one audio device the system knows about.