Categorygithub.com/sqp/pulseaudio
modulepackage
0.0.0-20180916175200-29ac6bfa231c
Repository: https://github.com/sqp/pulseaudio.git
Documentation: pkg.go.dev

# README

pulseaudio: native pulseaudio client for go through dbus.

Build Status codecov golangci Go Report Card

License GoDoc

pulseaudio is a simple library that controls a pulseaudio server through its D-Bus interface.

Features

  • Control your audio cards and streams in pure go.
  • Native implementation of the pulseaudio D-Bus protocol.
  • Small lib pretty close to the DBus API rather than trying to abstract everything.
  • Splitted interface to allow clients to implement only what they need.
  • Test coverage 86%, missing 9 lines in errors paths harder to test.
  • Only one dependency, the dbus library: github.com/godbus/dbus
  • Permissive software licence: ISC

Installation

This packages requires Go 1.7 (for the dbus lib). If you installed it and set up your GOPATH, just run:

go get -u github.com/sqp/pulseaudio

Usage

The complete package documentation is available at godoc.org. See also:

Note

You will have to enable the dbus module of your pulseaudio server. This can now be done with pulseaudio.LoadModule() function (requires the pacmd command, in package pulseaudio-utils on debian).

or as a permanent config by adding this line in /etc/pulse/default.pa

    load-module module-dbus-protocol

If system-wide daemon mode is used, the file to edit is /etc/pulse/system.pa

Evolutions

  • The base API has been stable for years and there's no plan to improve it for now.
  • A higher level API could be designed to cover simple frequent needs. Open an issue to discuss it if you want.
  • The lib may at some point move to a community repo. This could be an opportunity to change a little the API, so we'll need some feedback.

Feedback

Please open an issue or submit a pull request if:

  • You tried or use this library, let us know if you saw things to improve, especially in the doc if you're a native English speaker.
  • You want your code to be listed as example.

# Functions

LoadModule loads the PulseAudio DBus module.
ModuleIsLoaded tests if the PulseAudio DBus module is loaded.
New creates a new pulseaudio Dbus client session.
NewHooker handles a loosely coupled hook interface to forward dbus signals to registered clients.
NewObject creates a dbus Object with properties access methods.
UnloadModule unloads the PulseAudio DBus module.

# Constants

Dbus objects paths.
Dbus objects paths.

# Variables

PulseCalls defines callbacks methods to call the matching object method with type-asserted arguments.
PulseTypes defines interface types for events to register.

# Structs

Client manages a pulseaudio Dbus client session.
Hooker defines a list of objects indexed by the methods they implement.
Msg defines an dbus signal event message.
Object extends the dbus Object with properties access methods.

# Interfaces

OnDeviceActivePortUpdated is an interface to the DeviceActivePortUpdated method.
OnDeviceMuteUpdated is an interface to the DeviceMuteUpdated method.
OnDeviceVolumeUpdated is an interface to the DeviceVolumeUpdated method.
OnFallbackSinkUnset is an interface to the FallbackSinkUnset method.
OnFallbackSinkUpdated is an interface to the FallbackSinkUpdated method.
OnNewPlaybackStream is an interface to the NewPlaybackStream method.
OnNewSink is an interface to the NewSink method.
OnPlaybackStreamRemoved is an interface to the PlaybackStreamRemoved method.
OnSinkRemoved is an interface to the SinkRemoved method.
OnStreamMuteUpdated is an interface to the StreamMuteUpdated method.
OnStreamVolumeUpdated is an interface to the StreamVolumeUpdated method.

# Type aliases

Calls defines a list of event callback methods indexed by dbus method name.
Types defines a list of interfaces types indexed by dbus method name.