pulseaudio

package module
v0.0.0-...-c0de5a7 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: MIT Imports: 10 Imported by: 0

README

pulseaudio GoDoc

Package pulseaudio is a pure-Go (no libpulse) implementation of the PulseAudio native protocol.

Download:

go get mrogalski.eu/go/pulseaudio

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.


Automatically generated by autoreadme on 2018.06.22

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.

Example
client, err := NewClient()
if err != nil {
	panic(err)
}
defer client.Close()
// Use `client` to interact with PulseAudio
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card struct {
	Index         uint32
	Name          string
	Module        uint32
	Driver        string
	Profiles      map[string]*profile
	ActiveProfile *profile
	PropList      map[string]string
	Ports         []port
}

type Client

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

Client maintains a connection to the PulseAudio server.

func NewClient

func NewClient(addressArr ...string) (*Client, error)

NewClient establishes a connection to the PulseAudio server.

func (*Client) Cards

func (c *Client) Cards() ([]Card, error)

func (*Client) Close

func (c *Client) Close()

Close closes the connection to PulseAudio server and makes the Client unusable.

func (*Client) Mute

func (c *Client) Mute() (bool, error)

func (*Client) Outputs

func (c *Client) Outputs() (outputs []Output, activeIndex int, err error)

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) ServerInfo

func (c *Client) ServerInfo() (*Server, error)

func (*Client) SetCardProfile

func (c *Client) SetCardProfile(cardIndex uint32, profileName string) error

func (*Client) SetMute

func (c *Client) SetMute(b bool) error

ToggleMute reverse mute status

func (*Client) SetSinkVolume

func (c *Client) SetSinkVolume(sinkName string, volume float32) error

func (*Client) SetVolume

func (c *Client) SetVolume(volume float32) error

SetVolume changes the current volume to a specified value from 0 to 1 (or more than 1 - if volume should be boosted).

func (*Client) Sinks

func (c *Client) Sinks() ([]sink, error)

func (*Client) ToggleMute

func (c *Client) ToggleMute() (bool, error)

ToggleMute reverse mute status

func (*Client) Updates

func (c *Client) Updates() (updates <-chan struct{}, err error)

Updates returns a channel with PulseAudio updates.

func (*Client) Volume

func (c *Client) Volume() (float32, error)

Volume returns current audio volume as a number from 0 to 1 (or more than 1 - if volume is boosted).

type Error

type Error struct {
	Cmd  string
	Code uint32
}

func (*Error) Error

func (err *Error) Error() string

type Output

type Output struct {
	CardID    string
	PortID    string
	CardName  string
	PortName  string
	Available bool
	// contains filtered or unexported fields
}

Output represents PulseAudio output.

func (Output) Activate

func (o Output) Activate() error

Activate sets this output as the main one.

type Server

type Server struct {
	PackageName    string
	PackageVersion string
	User           string
	Hostname       string
	SampleSpec     sampleSpec
	DefaultSink    string
	DefaultSource  string
	Cookie         uint32
	ChannelMap     channelMap
}

func (*Server) ReadFrom

func (s *Server) ReadFrom(r io.Reader) (int64, error)

Jump to

Keyboard shortcuts

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