alsa

package
v1.17.7 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: BSD-3-Clause Imports: 10 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

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

View Source
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

func (s *Service) Devices(kind platform.AudioKind) ([]platform.AudioDeviceInfo, error)

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

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

Jump to

Keyboard shortcuts

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