nativeaudio

audio playback for Go
Log | Files | Refs | README | LICENSE

commit e63bbc49b6a3d4b85606a5cc85c187a57ae6f09b
parent 3bdbe9d9e5d2e907bf64e2d33492e9a4e5648f9a
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date:   Thu, 17 Sep 2026 12:09:48 -0400

audio: fix inverted package comment and document the Play format limit

The package comment said ffmpeg is used where native APIs exist, the
opposite of the design. Spell ffmpeg correctly and note on Play that the
Windows and macOS playback context is fixed to the first file's format.

Diffstat:
Maudio.go | 6+++++-
Maudio_ffmpeg.go | 2+-
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/audio.go b/audio.go @@ -1,7 +1,7 @@ // Package nativeaudio leverages native decoders for each supported OS // to decode raw PCM data. // -// Where there are native APIs to call we default to invoking ffmpeg. +// Where there are no native APIs to call we default to invoking ffmpeg. // // Windows: Media Foundation // macOS: AudioToolbox @@ -46,6 +46,10 @@ func End() error { } // Play an audio file exactly once, synchronously. +// +// On Windows and macOS playback goes through a single process-wide audio +// context whose sample rate and channel count are fixed by the first file +// played; later files must share that format. func Play(path string) error { if err := Start(); err != nil { return err diff --git a/audio_ffmpeg.go b/audio_ffmpeg.go @@ -1,7 +1,7 @@ // This file is a temporary audio implementation for macOS and Linux // platforms. For Linux I suspect ffmpeg will be the defacto, but macOS // ships an AAC decoder that we can access directly. That is preferable -// to relying on the ffmepg binary being present since we'd have to +// to relying on the ffmpeg binary being present since we'd have to // provide one or hope for the best. package nativeaudio