Documentation
¶
Overview ¶
Package alsa is the ALSA backend of the audio service on Linux (SPEC §28.3, step 31.5), for the systems where no PulseAudio (or PipeWire) server answers: playback and capture of float32 frames through libasound's PCM interface, on a goroutine of its own for each device. It has no hotplug: the list of devices is read when it is asked for. libasound is loaded when it is first needed. The design follows the ALSA driver of SDL 3 (src/audio/alsa/SDL_alsa_audio.c; zlib license, third_party/sdl/LICENSE), translated to Go and changed: the stream is set with snd_pcm_set_params, the loop waits for the device with a timeout so that pausing and closing do not wait for a device that is stuck, and an underrun is recovered with snd_pcm_recover.
Flutter: no counterpart
Index ¶
Constants ¶
const LibraryEnv = "GLUTTER_ALSA_LIBRARY"
LibraryEnv names the environment variable that overrides the path of libasound, for setups such as NixOS (SPEC §8.1).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the ALSA backend: it implements platform.Audio.
Flutter: no counterpart
func New ¶
func New() *Service
New makes a Service. libasound is not loaded yet.
Flutter: no counterpart
func (*Service) Devices ¶
Devices lists what ALSA's configuration offers as PCM devices: the default one, and the system default of each card.
Flutter: no counterpart
func (*Service) Open ¶
func (s *Service) Open(ctx context.Context, kind platform.AudioKind, opts platform.AudioOpenOptions, h platform.AudioHandler) (platform.AudioDevice, error)
Open opens a device and starts its goroutine. It fails with AudioUnavailable when libasound cannot be loaded, AudioFormatUnsupported when the device takes no such format, AudioCapturePermissionDenied when the system refuses the recording and AudioDeviceOpenFailed for the rest.
Flutter: no counterpart
func (*Service) SetChangeHandler ¶
func (s *Service) SetChangeHandler(fn func())
SetChangeHandler does nothing: ALSA has no notification of devices that come and go (SPEC §28.3).
Flutter: no counterpart