Documentation ¶
Overview ¶
Package pulseaudio is a pure-Go (no libpulse) implementation of the PulseAudio native protocol.
Rather than exposing the PulseAudio protocol directly this library attempts to hide the PulseAudio complexity behind a Go interface. Some of the things which are deliberately not exposed in the API are:
→ backwards compatibility for old PulseAudio servers
→ transport mechanism used for the connection (Unix sockets / memfd / shm)
→ encoding used in the pulseaudio-native protocol
Working features ¶
Querying and setting the volume.
Listing audio outputs.
Changing the default audio output.
Notifications on config updates.
Index ¶
- Variables
- type CVolume
- type Card
- type ChannelMap
- type CliClient
- type Client
- func (c *Client) Cards(ctx context.Context) ([]Card, error)
- func (c *Client) Close()
- func (c *Client) Connect(ctx context.Context, interval time.Duration, wg *sync.WaitGroup)
- func (c *Client) Modules(ctx context.Context) ([]Module, error)
- func (c *Client) Mute(ctx context.Context) (bool, error)
- func (c *Client) Outputs(ctx context.Context) (outputs []Output, activeIndex int, err error)
- func (c *Client) ServerInfo(ctx context.Context) (*Server, error)
- func (c *Client) SetCardProfile(ctx context.Context, cardIndex uint32, profileName string) error
- func (c *Client) SetMute(ctx context.Context, mute bool) error
- func (c *Client) SetSinkMute(ctx context.Context, sinkName string, mute bool) error
- func (c *Client) SetSinkVolume(ctx context.Context, sinkName string, volume float32) error
- func (c *Client) SetVolume(ctx context.Context, volume float32) error
- func (c *Client) Sinks(ctx context.Context) ([]Sink, error)
- func (c *Client) ToggleMute(ctx context.Context) (bool, error)
- func (c *Client) Updates(ctx context.Context) (updates <-chan struct{}, err error)
- func (c *Client) Volume(ctx context.Context) (float32, error)
- type ClientOpt
- type Error
- type FormatInfo
- type Logger
- type Module
- type Opts
- type Output
- type Port
- type Profile
- type SampleSpec
- type Server
- type Sink
- type SinkPort
Constants ¶
This section is empty.
Variables ¶
var ( ErrClientClosed = errors.New("pulseaudio client was closed") ErrClientDisabled = errors.New("client disabled") ErrCouldNotSendRequest = errors.New("could not send packet") )
var ErrSinkNotFound = errs.New("sink not found in output")
Functions ¶
This section is empty.
Types ¶
type ChannelMap ¶
type ChannelMap []byte
type CliClient ¶
type CliClient struct {
// contains filtered or unexported fields
}
func NewCliClient ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client maintains a connection to the PulseAudio server.
func (*Client) Outputs ¶
Outputs returns a list of all audio outputs and an index of the active audio output.
The last audio output is always called "None" and indicates that audio is disabled.
func (*Client) SetCardProfile ¶
func (*Client) SetSinkMute ¶
SetSinkMute reverse mute status
func (*Client) SetSinkVolume ¶
func (*Client) SetVolume ¶
SetVolume changes the current volume to a specified value from 0 to 1 (or more than 1 - if volume should be boosted).
func (*Client) ToggleMute ¶
ToggleMute reverse mute status
type ClientOpt ¶
type ClientOpt func(*Client)
ClientOpt defines a client modifier routine
func WithDialTimeout ¶ added in v0.2.0
type FormatInfo ¶
type Module ¶
type Opts ¶ added in v0.3.0
type Opts struct { DialTimeout time.Duration RequestTimeout time.Duration Logger Logger Protocol string Addr string Cookie string }
Opts wraps all available config options
type Output ¶
type Output struct { CardID string PortID string CardName string PortName string Available bool // contains filtered or unexported fields }
Output represents PulseAudio output.
type Port ¶
type SampleSpec ¶
type Server ¶
type Server struct { PackageName string PackageVersion string User string Hostname string SampleSpec SampleSpec DefaultSink string DefaultSource string Cookie uint32 ChannelMap ChannelMap }
type Sink ¶
type Sink struct { Index uint32 Name string Description string SampleSpec SampleSpec ChannelMap ChannelMap ModuleIndex uint32 CVolume CVolume Muted bool MonitorSourceIndex uint32 MonitorSourceName string Latency uint64 Driver string Flags uint32 PropList map[string]string RequestedLatency uint64 BaseVolume uint32 SinkState uint32 NVolumeSteps uint32 CardIndex uint32 Ports []SinkPort ActivePortName string Formats []FormatInfo }