output

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DisableHardwarePause = true // FIXME: should we fix this?
	ReleasePcmOnPause    = true
	BufferTimeMicro      = 500_000
)

Variables

View Source
var ErrBufferClosed = errors.New("buffer closed")

Functions

This section is empty.

Types

type NewOutputOptions

type NewOutputOptions struct {
	// 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 unix driver.
	Device string

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

	// InitialVolume specifies the initial output volume.
	InitialVolume float32

	// ExternalVolume specifies, if the volume is controlled outside of the app.
	ExternalVolume bool

	ExternalVolumeUpdate *RingBuffer[float32]
}

type Output

type Output struct {
	// contains filtered or unexported fields
}

func NewOutput

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

func (*Output) Close

func (c *Output) Close() error

Close closes the output.

func (*Output) DelayMs

func (c *Output) DelayMs() (int64, error)

DelayMs returns the output device delay in milliseconds.

func (*Output) Drop

func (c *Output) Drop() error

Drop empties the audio buffer without waiting.

func (*Output) Error

func (c *Output) Error() <-chan error

Error returns the error that stopped the device (if any).

func (*Output) Pause

func (c *Output) Pause() error

Pause pauses the output.

func (*Output) Resume

func (c *Output) Resume() error

Resume resumes the output.

func (*Output) SetVolume

func (c *Output) SetVolume(vol float32)

SetVolume sets the volume (0-1).

type RingBuffer

type RingBuffer[T any] struct {
	// contains filtered or unexported fields
}

func NewRingBuffer

func NewRingBuffer[T any](capacity uint64) *RingBuffer[T]

func (*RingBuffer[T]) Clear

func (rb *RingBuffer[T]) Clear()

func (*RingBuffer[T]) Close

func (rb *RingBuffer[T]) Close() error

func (*RingBuffer[T]) Get

func (rb *RingBuffer[T]) Get() (T, bool, error)

func (*RingBuffer[T]) GetWait

func (rb *RingBuffer[T]) GetWait() (T, error)

func (*RingBuffer[T]) Put

func (rb *RingBuffer[T]) Put(item T) error

func (*RingBuffer[T]) PutWait

func (rb *RingBuffer[T]) PutWait(item T) error

func (*RingBuffer[T]) Size

func (rb *RingBuffer[T]) Size() int

Jump to

Keyboard shortcuts

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