Documentation
¶
Overview ¶
Package pulse is the PulseAudio backend of the audio service on Linux (SPEC §28.3, step 31.5): playback and capture streams of float32 frames on libpulse's threaded main loop, the devices and the default device of the server, and a notification when they change. libpulse is loaded when it is first needed; the library is never linked. It speaks to PulseAudio and to PipeWire's PulseAudio protocol alike. The design (a thread of the library that calls the handler, a write callback that asks for just what the server wants) follows the PulseAudio driver of SDL 3 (src/audio/pulseaudio/SDL_pulseaudio.c; zlib license, third_party/sdl/LICENSE), translated to Go and changed.
Flutter: no counterpart
Index ¶
Constants ¶
const LibraryEnv = "GLUTTER_PULSE_LIBRARY"
LibraryEnv names the environment variable that overrides the path of libpulse, for setups such as NixOS (SPEC §8.1).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// AppName names the application to the server (it shows in a volume control); it defaults to the name of the program.
AppName string
}
Options configure a Service.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the PulseAudio backend: it implements platform.Audio. It connects to the server when it is first used, and again when the server was lost.
Flutter: no counterpart
func (*Service) Close ¶
func (s *Service) Close()
Close ends the connection: the devices that are open are closed, the main loop stops and the context is freed. The service is not used afterwards: its calls fail with AudioUnavailable. The memory of the stopped main loop is kept, because a device that was open can still be closed or paused by its owner afterwards, and takes the loop's lock to find out that it is closed.
Flutter: no counterpart
func (*Service) Devices ¶
Devices lists the sinks (playback) or the sources (capture) of the server, without the monitors of the sinks. It fails with AudioUnavailable when no server answers.
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 playback or a capture stream. It fails with AudioUnavailable when no server answers, AudioFormatUnsupported when the server takes no such format, AudioCapturePermissionDenied when the server refuses the recording, and AudioDeviceOpenFailed for the rest (the device is not there, the stream cannot connect).
Flutter: no counterpart
func (*Service) SetChangeHandler ¶
func (s *Service) SetChangeHandler(fn func())
SetChangeHandler sets what is called when a device appears, goes or changes, or the default changes. It is called on the thread of libpulse; nil clears it. The subscription is made when the service connects, which is when the app first asks for devices or opens one.
Flutter: no counterpart