From 93481365d1c61c8b6b53fe026e16107eaffb6497 Mon Sep 17 00:00:00 2001
From: Koichiro IWAO
Date: Tue, 26 Dec 2017 01:26:55 +0900
Subject: [PATCH] pulse: replace old pulse notes with bran-new README
---
sesman/chansrv/pulse/README.md | 145 ++++++++++++++++++++
sesman/chansrv/pulse/pulse-notes.txt | 79 -----------
sesman/chansrv/pulse/pulse-notes.ubuntu.txt | 77 -----------
3 files changed, 145 insertions(+), 156 deletions(-)
create mode 100644 sesman/chansrv/pulse/README.md
delete mode 100644 sesman/chansrv/pulse/pulse-notes.txt
delete mode 100644 sesman/chansrv/pulse/pulse-notes.ubuntu.txt
diff --git a/sesman/chansrv/pulse/README.md b/sesman/chansrv/pulse/README.md
new file mode 100644
index 00000000..a072df5d
--- /dev/null
+++ b/sesman/chansrv/pulse/README.md
@@ -0,0 +1,145 @@
+The latest version of this document can be found at wiki.
+
+* https://github.com/neutrinolabs/xrdp/wiki/How-to-set-up-audio-redirection
+
+
+# Overview
+xrdp supports audio redirection using PulseAudio, which is a sound system for
+POSIX operating systems. Server to client redirection is compliant to Remote
+Desktop Procol standard [[MS-RDPEA]](https://msdn.microsoft.com/en-us/library/cc240933.aspx)
+but client to server redirection implementation is proprietary. Accordingly,
+server to client redirection is available with many of RDP clients including
+Microsoft client but client to server redirection requires NeutrinoRDP client,
+not available with other clients.
+
+Here is how to build pulseaudio modules for your distro, so you can have audio
+support through xrdp.
+
+# Prerequisites
+Prepare xrdp source in your home directory. Of course, you can choose another
+directory.
+
+ cd ~
+ git clone https://github.com/neutrinolabs/xrdp.git
+
+In this instruction, pulseaudio version is **10.0**. Replace the version number
+in this instruction if your environment has different versions. You can find
+out your pulseaudio version executing the following command:
+
+ pulseaudio --version
+
+# How to build
+
+## Debian 9 / Ubuntu
+
+This instruction also should be applicable to Ubuntu family.
+
+### Prerequisites
+
+Some build tools and package development tools are required. Make sure install
+the tools.
+
+ apt install build-essential dpkg-dev
+
+### Prepare & build
+
+Install pulseaudio and requisite packages to build pulseaudio.
+
+ apt install pulseaudio
+ apt build-dep pulseaudio
+
+Fetch the pulseaudio source . You'll see `pulseaudio-10.0` directory in your
+current directory.
+
+ apt source pulseaudio
+
+Enter into the directory and build the pulseaudio package.
+
+ cd pulseaudio-10.0
+ dpkg-buildpackage -rfakeroot -uc -b
+
+Enter into pulse directory in xrdp source.
+
+ cd ~/xrdp/sesman/chansrv/pulse
+ nano Makefile
+
+Edit the `Makefile`. Replace `/tmp/pulseaudio-10.0` with your pulseaudio source
+directory.
+
+```diff
+diff --git a/sesman/chansrv/pulse/Makefile b/sesman/chansrv/pulse/Makefile
+index 74977221..395ef0a0 100644
+--- a/sesman/chansrv/pulse/Makefile
++++ b/sesman/chansrv/pulse/Makefile
+@@ -3,7 +3,7 @@
+ #
+
+ # change this to your pulseaudio source directory
+-PULSE_DIR = /tmp/pulseaudio-10.0
++PULSE_DIR = /home/debian/pulseaudio-10.0
+ CFLAGS = -Wall -O2 -I$(PULSE_DIR) -I$(PULSE_DIR)/src -DHAVE_CONFIG_H -fPIC
+
+ all: module-xrdp-sink.so module-xrdp-source.so
+```
+
+Finally, let's make. You'll have two .so files `module-xrdp-sink.so` and
+`module-xrdp-source.so`.
+
+ make
+
+## Other distro
+
+First off, find out your pulseaudio version using `pulseaudio --version`
+command. Download the tarball of the pulseaudio version that you have.
+
+* https://freedesktop.org/software/pulseaudio/releases/
+
+After downloading the tarball, extact the tarball and `cd` into the source
+directory, then run `./configure`.
+
+ wget https://freedesktop.org/software/pulseaudio/releases/pulseaudio-10.0.tar.xz
+ tar xf pulseaudio-10.0.tar.gz
+ cd pulseaudio-10.0
+ ./configure
+
+If additional packages are required to run `./configure`, install requisite
+packages depending on your environment.
+
+Next, enter into pulse directory in xrdp source and replace `/tmp/pulseaudio-10.0`
+in `Makefile` with your pulseaudio source directory.
+
+ cd ~/xrdp/sesman/chansrv/pulse
+ nano Makefile
+
+Finally, let's make. You'll have two .so files `module-xrdp-sink.so` and
+`module-xrdp-source.so`.
+
+ make
+
+# Install
+
+Install process is not distro specific except for install destination. Install
+built two .so files into the pulseaudio modules directory. Typically,
+`/usr/lib/pulse-10.0/modules` for Debian, `/usr/lib64/pulse-10.0/modules` for
+CentOS 7. Other distro might have different path. Find out the right path for
+your distro.
+
+Look into the directory with `ls` command. You'll see lots of `module-*.so`
+files. There's the place!
+
+ cd ~/xrdp/sesman/chansrv/pulse
+ for f in *.so; do install -s -m 644 $f /usr/lib/pulse-10.0/modules; done
+
+This command is equivalent to following:
+
+ install -s -m 644 module-xrdp-sink.so /usr/lib/pulse-10.0/modules
+ install -s -m 644 module-xrdp-source.so /usr/lib/pulse-10.0/modules
+
+Well done! Pulseaudio modules should be properly built and installed.
+
+
+# See if it works
+
+To see if it works, run `pavumeter` in the xrdp session. Playback any YouTube
+video in Firefox. You'll see "Showing signal levels of **xrdp sink**" and
+volume meter moving.
diff --git a/sesman/chansrv/pulse/pulse-notes.txt b/sesman/chansrv/pulse/pulse-notes.txt
deleted file mode 100644
index 92a9878d..00000000
--- a/sesman/chansrv/pulse/pulse-notes.txt
+++ /dev/null
@@ -1,79 +0,0 @@
-
-Pulse audio notes.
-
-to see what version of PA is on your machine
-pulseaudio --version
-
-IMA ADPCM
-
-To build xrdp pulse sink,
-get the pulse source that most closely matches your version on
-your machine. Get the source from
-http://freedesktop.org/software/pulseaudio/releases/
-run ./configure after extracting. I don't think you need to build it.
-edit Makefile to point to your pulse source directory.
-
-
-
-PA always respawning
-
- To stop its respawning habit, open /etc/pulse/client.conf, change
- autospawn = yes to autospawn = no, and set daemon-binary to /bin/true.
- Make sure these lines are uncommented, like this:
-
-autospawn = no
-daemon-binary = /bin/true
-
-xfreerdp -a 24 -z --plugin rdpsnd --data alsa:hw:0,0 -- 127.0.0.1
-
-
-to get ./configure on pulse source to run
-apt-get install libsndfile1-dev
-apt-get install libspeex-dev
-apt-get install libspeexdsp-dev
-
-alsamixer
-apt-get install alsa-utils
-
-
-/etc/asound.conf
----------------------------------
-pcm.pulse {
- type pulse
-}
-
-ctl.pulse {
- type pulse
-}
-
-pcm.!default {
- type pulse
-}
-
-ctl.!default {
- type pulse
-}
----------------------------------
-
-
-/etc/pulse/default.pa
----------------------------------
-.nofail
-.fail
-load-module module-augment-properties
-#load-module module-alsa-sink device=hw:0
-#load-module module-alsa-source device=hw:0
-#load-module module-pipe-sink
-#load-module module-pipe-source
-#load-module module-null-sink
-load-module module-xrdp-sink
-load-module module-native-protocol-unix
-#load-module module-udev-detect tsched=0
----------------------------------
-
-To see a list of sinks
-pacmd list-sinks
-
-To manually load a sink
-pactl load-module module-xrdp-sink.so sink_name=test
-
diff --git a/sesman/chansrv/pulse/pulse-notes.ubuntu.txt b/sesman/chansrv/pulse/pulse-notes.ubuntu.txt
deleted file mode 100644
index 18a3768f..00000000
--- a/sesman/chansrv/pulse/pulse-notes.ubuntu.txt
+++ /dev/null
@@ -1,77 +0,0 @@
-
---------------------------------------
- Building pulseaudio modules for xrdp
---------------------------------------
-
-o append the following line to /etc/apt/sources.list
-
- deb-src http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
-
- this is what my /etc/apt/sources.list looks like
-
- deb http://packages.linuxmint.com/ maya main upstream import
- deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
- deb http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
- deb http://security.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
- deb http://archive.canonical.com/ubuntu/ precise partner
- deb http://packages.medibuntu.org/ precise free non-free
-
- #deb http://archive.getdeb.net/ubuntu precise-getdeb apps
- #deb http://archive.getdeb.net/ubuntu precise-getdeb games
- deb http://drbl.sourceforge.net/drbl-core drbl stable
- deb-src http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
-
- NOTE: If you get an error message that goes something like this:
-
- E: You must put some 'source' URIs in your sources.list
-
- try running the following command first:
-
- apt-get source pulseaudio
-
-o run these commands in your home directory
-
- cd
- sudo apt-get install dpkg-dev
- apt-get source pulseaudio
- sudo apt-get build-dep pulseaudio
-
- cd pulseaudio-1.1
- dpkg-buildpackage -rfakeroot -uc -b
-
-o edit Makefile and point PULSE_DIR to ~/pulseaudio dir
-
-o run make; the outputs will be
- module-xrdp-sink.so
- module-xrdp-source.so
-
-o sudo cp module-xrdp-sink.so /usr/lib/pulse-/modules
- sudo cp module-xrdp-source.so /usr/lib/pulse-/modules
- note: on a 64bit machine use lib64 instead of lib
-
-o if you build xrdp with --enable-load_pulse_modules, then the above modules
- will get loaded automatically when xrdp starts. However if --enable-load_pulse_modules
- is not used, then you need to edit /etc/pulse/default.pa and insert the following
- two lines into it:
-
- load-module module-xrdp-sink
- load-module module-xrdp-source
-
---------------------------------------
- To test sound/microphone redirection
---------------------------------------
-
-o install gnome sound recorder or your favorite sound recorder
-
-o mplayer -ao pulse