output

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: GPL-3.0 Imports: 14 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NewOutputOptions

type NewOutputOptions struct {
	Log librespot.Logger

	// Backend is the audio backend to use (also, pulseaudio, etc).
	Backend string

	// Reader provides data for the output device.
	//
	// The format of data is as follows:
	//
	//	[data]      = [sample 1] [sample 2] [sample 3] ...
	//	[sample *]  = [channel 1] [channel 2] ...
	//	[channel *] = [byte 1] [byte 2] ...
	//
	// Byte ordering is little endian.
	Reader librespot.Float32Reader

	// SampleRate specifies the number of samples that should be played during one second.
	// Usual numbers are 44100 or 48000. One context has only one sample rate. You cannot play multiple audio
	// sources with different sample rates at the same time.
	SampleRate int

	// ChannelCount specifies the number of channels. One channel is mono playback. Two
	// channels are stereo playback. No other values are supported.
	ChannelCount int

	// Device specifies the audio device name.
	//
	// This feature is support only for the alsa and pulseaudio backend.
	// The wasapi backend always uses the default playback endpoint.
	Device string
	// RuntimeSocket specifies a prefixed with protocol (e.g. `unix:` or `tcp:`) path
	// to a runtime socket of audio backend.
	//
	// This feature is support only for pulseaudio backend.
	RuntimeSocket string

	// Mixer specifies the audio mixer name.
	//
	// This feature is support only for the alsa backend.
	Mixer string
	// Control specifies the mixer control name
	//
	// This only works in combination with Mixer
	Control string

	// BufferTimeMicro is the buffer time in microseconds.
	//
	// This is only supported on the alsa backend.
	BufferTimeMicro int

	// PeriodCount is the number of periods to request.
	//
	// This is only supported on the alsa backend.
	PeriodCount int

	// InitialVolume specifies the initial output volume.
	//
	// This is supported on the alsa, pipe, audio-toolbox, and wasapi backends. The PulseAudio
	// backend uses the PulseAudio default volume.
	InitialVolume float32

	// ExternalVolume specifies, if the volume is controlled outside the app.
	//
	// This is only supported on the alsa and pipe backends.
	// The PulseAudio backend always uses external volume.
	ExternalVolume bool

	// VolumeUpdate is a channel on which volume updates will be sent back to
	// Spotify. All updates come through this channel, including those sent by
	// Spotify.
	// This must be a buffered channel.
	VolumeUpdate chan float32

	// OutputPipe is the path to the output pipe.
	//
	// This is only supported on the pipe backend.
	OutputPipe string

	// OutputPipeFormat is the format of the output pipe.
	// Available formats are: "s16le", "s32le", "f32le". Default is "s16le".
	//
	// This is only supported on the pipe backend.
	OutputPipeFormat string

	// OutputPipeWaitForReader makes the pipe backend wait for a reader to
	// appear when opening the FIFO, instead of failing if none is present at the
	// time playback starts. This is useful for readers (e.g. snapcast with
	// dryout) that only connect to the FIFO when data is expected.
	//
	// This is only supported on the pipe backend.
	OutputPipeWaitForReader bool
}

type Output

type Output interface {
	// Pause pauses the output.
	Pause() error

	// Resume resumes the output.
	Resume() error

	// Drop empties the audio buffer without waiting. It must not resume or
	// restart playback; the caller resumes explicitly when needed.
	Drop() error

	// DelayMs returns the output device delay in milliseconds.
	DelayMs() (int64, error)

	// SetVolume sets the volume (0-1).
	SetVolume(vol float32)

	// Error returns the error that stopped the device (if any).
	Error() <-chan error

	// Close closes the output.
	Close() error
}

func NewOutput

func NewOutput(options *NewOutputOptions) (Output, error)

Jump to

Keyboard shortcuts

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