Jump to: navigation, search

Difference between revisions of "Pulseaudio"

Difference between revisions of "Pulseaudio"

(Server side: Reference the ansible playbook)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Enable remote device discovery ==
+
[[Category:Sysadmin]]
 +
= PulseAudio network sink =
  
 +
This is a simple server, that anyone (!!!, I mean it!) in the network can send music and the server will play it through its speakers.
 +
It's a guide for debian, but it applies exaclty the same to other distros (on gentoo you have to recobile pulseaudio with zeroconf use flag for server use and avahi use flag for user).
 +
 +
== Server side ==
 +
Pulseaudio needs 2 modules. One to listen over TCP and one to publicate this over avahi (makes it much easier to configure from the user side).
 +
You also need avahi-daemon and pulseaudio installed.
 +
 +
The whole process has been scripted using [[Ansible]] and can be ran using the pulseaudio.yml playbook.
 +
 +
Now install the zeroconf/avahi module:
 
  <nowiki>
 
  <nowiki>
$ aptitude install pulseaudio-module-zeroconf</nowiki>
+
# apt-get install pulseaudio-module-zeroconf</nowiki>
 +
Enable the avahi server:
 +
<nowiki>
 +
# systemctl enable avahi-daemon
 +
# systemctl start avahi-daemon</nowiki>
  
After that, as a user, you can use the paprefs utility to enable remote device discovery.
+
Enable the pulseaudio modules, in /etc/pulse/default.pa add these lines:
 +
<nowiki>
 +
load-module module-native-protocol-tcp auth-anonymous=1
 +
load-module module-zeroconf-publish</nowiki>
  
== Make pulseaudio discover zeroconf devices for all users by default ==
+
If you need security, take a look at auth-ip-acl, 'cause some ultra-hax0rs are hacking pulseaudio servers to achive world domination through hypnosis.
 +
Last, create a service to start on boot and have a beautiful control, create a file in /etc/systemd/system/pulseaudio.service:
 +
<nowiki>
 +
[Unit]
 +
Description=PulseAudio Server
 +
Requires=avahi-daemon.service
  
 +
[Service]
 +
Type=forking
 +
User=pulse
 +
ExecStart=/usr/bin/pulseaudio --start
 +
ExecStop=/usr/bin/pulseaudio --kill
 +
 +
 +
[Install]
 +
WantedBy=multi-user.target</nowiki>
 +
 +
And enable it...
 
  <nowiki>
 
  <nowiki>
$ gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set /system/pulseaudio/modules/zeroconf-discover/name0 module-zeroconf-discover
+
# systemctl enable pulseaudio
$ gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set /system/pulseaudio/modules/zeroconf-discover/args0 ""
+
# systemctl start pulseaudio</nowiki>
$ gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type bool --set /system/pulseaudio/modules/zeroconf-discover/enabled true
+
$ gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type bool --set /system/pulseaudio/modules/zeroconf-discover/locked false</nowiki>
+
  
This eliminates the need for every user to enable this option in paprefs.
+
== User side ==
 +
The n00bs can configure pulseaudio to passthrough all sound to the server via paprefs.
 +
 
 +
The real men can either passthrough a specific program to the server via:
 +
<nowiki>
 +
$ PULSE_SERVER=<hostname/ip> <command></nowiki>
 +
 
 +
Or add the network sink to the local pulseaudio server via:
 +
<nowiki>
 +
pacmd load-module module-tunnel-sink server=<hostname/ip></nowiki>
 +
and do whatever you want with it.

Latest revision as of 09:57, 11 April 2015

PulseAudio network sink[edit]

This is a simple server, that anyone (!!!, I mean it!) in the network can send music and the server will play it through its speakers. It's a guide for debian, but it applies exaclty the same to other distros (on gentoo you have to recobile pulseaudio with zeroconf use flag for server use and avahi use flag for user).

Server side[edit]

Pulseaudio needs 2 modules. One to listen over TCP and one to publicate this over avahi (makes it much easier to configure from the user side). You also need avahi-daemon and pulseaudio installed.

The whole process has been scripted using Ansible and can be ran using the pulseaudio.yml playbook.

Now install the zeroconf/avahi module:

# apt-get install pulseaudio-module-zeroconf

Enable the avahi server:

# systemctl enable avahi-daemon
# systemctl start avahi-daemon

Enable the pulseaudio modules, in /etc/pulse/default.pa add these lines:

load-module module-native-protocol-tcp auth-anonymous=1
load-module module-zeroconf-publish

If you need security, take a look at auth-ip-acl, 'cause some ultra-hax0rs are hacking pulseaudio servers to achive world domination through hypnosis. Last, create a service to start on boot and have a beautiful control, create a file in /etc/systemd/system/pulseaudio.service:

[Unit]
Description=PulseAudio Server
Requires=avahi-daemon.service

[Service]
Type=forking
User=pulse
ExecStart=/usr/bin/pulseaudio --start
ExecStop=/usr/bin/pulseaudio --kill


[Install]
WantedBy=multi-user.target

And enable it...

# systemctl enable pulseaudio
# systemctl start pulseaudio

User side[edit]

The n00bs can configure pulseaudio to passthrough all sound to the server via paprefs.

The real men can either passthrough a specific program to the server via:

$ PULSE_SERVER=<hostname/ip> <command>

Or add the network sink to the local pulseaudio server via:

pacmd load-module module-tunnel-sink server=<hostname/ip>

and do whatever you want with it.