mirror of
https://github.com/neutrinolabs/pulseaudio-module-xrdp.git
synced 2025-06-03 06:30:16 +00:00
Compare commits
No commits in common. "devel" and "v0.1" have entirely different histories.
60
.github/workflows/build.yml
vendored
60
.github/workflows/build.yml
vendored
@ -1,60 +0,0 @@
|
|||||||
name: build
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
install_pa_sources:
|
|
||||||
name: install PA sources
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
# Set steps.os.outputs.image to the specific OS (e.g. 'ubuntu20')
|
|
||||||
- name: Get operating system name and version.
|
|
||||||
id: os
|
|
||||||
run: echo "image=$ImageOS" >>$GITHUB_OUTPUT
|
|
||||||
shell: bash
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Cache pulseaudio source
|
|
||||||
uses: actions/cache@v3
|
|
||||||
env:
|
|
||||||
cache-name: cache-pulseaudio-src
|
|
||||||
with:
|
|
||||||
path: ~/pulseaudio.src
|
|
||||||
key: ${{ steps.os.outputs.image }}-build-${{ env.cache-name }}
|
|
||||||
- run: scripts/install_pulseaudio_sources_apt.sh
|
|
||||||
|
|
||||||
build:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
|
|
||||||
- CC: gcc
|
|
||||||
|
|
||||||
- CC: clang
|
|
||||||
|
|
||||||
name: build with ${{ matrix.CC }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: install_pa_sources
|
|
||||||
env:
|
|
||||||
CC: ${{ matrix.CC }}
|
|
||||||
CFLAGS: -Wall -Wextra -Werror
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Get operating system name and version.
|
|
||||||
id: os
|
|
||||||
run: echo "image=$ImageOS" >>$GITHUB_OUTPUT
|
|
||||||
shell: bash
|
|
||||||
- name: Fetch pulseaudio sources
|
|
||||||
uses: actions/cache@v3
|
|
||||||
env:
|
|
||||||
cache-name: cache-pulseaudio-src
|
|
||||||
with:
|
|
||||||
path: ~/pulseaudio.src
|
|
||||||
key: ${{ steps.os.outputs.image }}-build-${{ env.cache-name }}
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- run: sudo apt-get update
|
|
||||||
- run: sudo apt-get -yq install build-essential libpulse-dev libltdl-dev
|
|
||||||
- run: ./bootstrap
|
|
||||||
- run: ./configure PULSE_DIR=~/pulseaudio.src
|
|
||||||
- run: make
|
|
21
.travis.centos.sh
Normal file
21
.travis.centos.sh
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
SRC_DIR=${PWD}
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
yum install -y epel-release
|
||||||
|
yum install -y xrdp xrdp-devel xrdp-selinux wget
|
||||||
|
yum install -y pulseaudio pulseaudio-libs pulseaudio-libs-devel
|
||||||
|
yum-builddep -y pulseaudio
|
||||||
|
yum groupinstall -y "Development Tools"
|
||||||
|
|
||||||
|
PULSE_VER=$(pkg-config --modversion libpulse)
|
||||||
|
|
||||||
|
# not to make traffic on upstream server
|
||||||
|
wget http://distcache.freebsd.org/ports-distfiles/pulseaudio-${PULSE_VER}.tar.xz
|
||||||
|
tar xf pulseaudio-${PULSE_VER}.tar.xz
|
||||||
|
cd pulseaudio-${PULSE_VER}
|
||||||
|
./configure || exit 1
|
||||||
|
|
||||||
|
cd ${SRC_DIR}
|
||||||
|
./bootstrap && ./configure PULSE_DIR=/tmp/pulseaudio-${PULSE_VER} && make
|
22
.travis.ubuntu.sh
Normal file
22
.travis.ubuntu.sh
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
SRC_DIR=${PWD}
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
sed -i.bak -e 's|^# deb-src|deb-src|' /etc/apt/sources.list
|
||||||
|
|
||||||
|
apt update
|
||||||
|
apt install -y build-essential dpkg-dev libpulse-dev pulseaudio pkg-config xrdp
|
||||||
|
apt install -y g++ clang
|
||||||
|
|
||||||
|
apt install -y pulseaudio
|
||||||
|
apt build-dep -y pulseaudio
|
||||||
|
apt source pulseaudio
|
||||||
|
|
||||||
|
PULSE_VER=$(pkg-config --modversion libpulse)
|
||||||
|
|
||||||
|
cd pulseaudio-${PULSE_VER}
|
||||||
|
./configure || exit 1
|
||||||
|
|
||||||
|
cd ${SRC_DIR}
|
||||||
|
./bootstrap && ./configure PULSE_DIR=/tmp/pulseaudio-${PULSE_VER} && make
|
18
.travis.yml
Normal file
18
.travis.yml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# vim:ts=2:sw=2:sts=0:number:expandtab
|
||||||
|
language: c
|
||||||
|
|
||||||
|
env:
|
||||||
|
matrix:
|
||||||
|
- OS_TYPE=ubuntu OS_VERSION=18.04 BRANCH=devel
|
||||||
|
- OS_TYPE=ubuntu OS_VERSION=18.04 BRANCH=master
|
||||||
|
- OS_TYPE=centos OS_VERSION=7 BRANCH=devel
|
||||||
|
- OS_TYPE=centos OS_VERSION=7 BRANCH=master
|
||||||
|
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- docker pull ${OS_TYPE}:${OS_VERSION}
|
||||||
|
|
||||||
|
script:
|
||||||
|
- docker run --rm --interactive --tty --volume=${PWD}:${PWD} ${OS_TYPE}:${OS_VERSION} bash -c "cd ${PWD} && bash .travis.${OS_TYPE}.sh"
|
502
LICENSE
502
LICENSE
@ -1,502 +0,0 @@
|
|||||||
GNU LESSER GENERAL PUBLIC LICENSE
|
|
||||||
Version 2.1, February 1999
|
|
||||||
|
|
||||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
[This is the first released version of the Lesser GPL. It also counts
|
|
||||||
as the successor of the GNU Library Public License, version 2, hence
|
|
||||||
the version number 2.1.]
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The licenses for most software are designed to take away your
|
|
||||||
freedom to share and change it. By contrast, the GNU General Public
|
|
||||||
Licenses are intended to guarantee your freedom to share and change
|
|
||||||
free software--to make sure the software is free for all its users.
|
|
||||||
|
|
||||||
This license, the Lesser General Public License, applies to some
|
|
||||||
specially designated software packages--typically libraries--of the
|
|
||||||
Free Software Foundation and other authors who decide to use it. You
|
|
||||||
can use it too, but we suggest you first think carefully about whether
|
|
||||||
this license or the ordinary General Public License is the better
|
|
||||||
strategy to use in any particular case, based on the explanations below.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom of use,
|
|
||||||
not price. Our General Public Licenses are designed to make sure that
|
|
||||||
you have the freedom to distribute copies of free software (and charge
|
|
||||||
for this service if you wish); that you receive source code or can get
|
|
||||||
it if you want it; that you can change the software and use pieces of
|
|
||||||
it in new free programs; and that you are informed that you can do
|
|
||||||
these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to make restrictions that forbid
|
|
||||||
distributors to deny you these rights or to ask you to surrender these
|
|
||||||
rights. These restrictions translate to certain responsibilities for
|
|
||||||
you if you distribute copies of the library or if you modify it.
|
|
||||||
|
|
||||||
For example, if you distribute copies of the library, whether gratis
|
|
||||||
or for a fee, you must give the recipients all the rights that we gave
|
|
||||||
you. You must make sure that they, too, receive or can get the source
|
|
||||||
code. If you link other code with the library, you must provide
|
|
||||||
complete object files to the recipients, so that they can relink them
|
|
||||||
with the library after making changes to the library and recompiling
|
|
||||||
it. And you must show them these terms so they know their rights.
|
|
||||||
|
|
||||||
We protect your rights with a two-step method: (1) we copyright the
|
|
||||||
library, and (2) we offer you this license, which gives you legal
|
|
||||||
permission to copy, distribute and/or modify the library.
|
|
||||||
|
|
||||||
To protect each distributor, we want to make it very clear that
|
|
||||||
there is no warranty for the free library. Also, if the library is
|
|
||||||
modified by someone else and passed on, the recipients should know
|
|
||||||
that what they have is not the original version, so that the original
|
|
||||||
author's reputation will not be affected by problems that might be
|
|
||||||
introduced by others.
|
|
||||||
|
|
||||||
Finally, software patents pose a constant threat to the existence of
|
|
||||||
any free program. We wish to make sure that a company cannot
|
|
||||||
effectively restrict the users of a free program by obtaining a
|
|
||||||
restrictive license from a patent holder. Therefore, we insist that
|
|
||||||
any patent license obtained for a version of the library must be
|
|
||||||
consistent with the full freedom of use specified in this license.
|
|
||||||
|
|
||||||
Most GNU software, including some libraries, is covered by the
|
|
||||||
ordinary GNU General Public License. This license, the GNU Lesser
|
|
||||||
General Public License, applies to certain designated libraries, and
|
|
||||||
is quite different from the ordinary General Public License. We use
|
|
||||||
this license for certain libraries in order to permit linking those
|
|
||||||
libraries into non-free programs.
|
|
||||||
|
|
||||||
When a program is linked with a library, whether statically or using
|
|
||||||
a shared library, the combination of the two is legally speaking a
|
|
||||||
combined work, a derivative of the original library. The ordinary
|
|
||||||
General Public License therefore permits such linking only if the
|
|
||||||
entire combination fits its criteria of freedom. The Lesser General
|
|
||||||
Public License permits more lax criteria for linking other code with
|
|
||||||
the library.
|
|
||||||
|
|
||||||
We call this license the "Lesser" General Public License because it
|
|
||||||
does Less to protect the user's freedom than the ordinary General
|
|
||||||
Public License. It also provides other free software developers Less
|
|
||||||
of an advantage over competing non-free programs. These disadvantages
|
|
||||||
are the reason we use the ordinary General Public License for many
|
|
||||||
libraries. However, the Lesser license provides advantages in certain
|
|
||||||
special circumstances.
|
|
||||||
|
|
||||||
For example, on rare occasions, there may be a special need to
|
|
||||||
encourage the widest possible use of a certain library, so that it becomes
|
|
||||||
a de-facto standard. To achieve this, non-free programs must be
|
|
||||||
allowed to use the library. A more frequent case is that a free
|
|
||||||
library does the same job as widely used non-free libraries. In this
|
|
||||||
case, there is little to gain by limiting the free library to free
|
|
||||||
software only, so we use the Lesser General Public License.
|
|
||||||
|
|
||||||
In other cases, permission to use a particular library in non-free
|
|
||||||
programs enables a greater number of people to use a large body of
|
|
||||||
free software. For example, permission to use the GNU C Library in
|
|
||||||
non-free programs enables many more people to use the whole GNU
|
|
||||||
operating system, as well as its variant, the GNU/Linux operating
|
|
||||||
system.
|
|
||||||
|
|
||||||
Although the Lesser General Public License is Less protective of the
|
|
||||||
users' freedom, it does ensure that the user of a program that is
|
|
||||||
linked with the Library has the freedom and the wherewithal to run
|
|
||||||
that program using a modified version of the Library.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow. Pay close attention to the difference between a
|
|
||||||
"work based on the library" and a "work that uses the library". The
|
|
||||||
former contains code derived from the library, whereas the latter must
|
|
||||||
be combined with the library in order to run.
|
|
||||||
|
|
||||||
GNU LESSER GENERAL PUBLIC LICENSE
|
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. This License Agreement applies to any software library or other
|
|
||||||
program which contains a notice placed by the copyright holder or
|
|
||||||
other authorized party saying it may be distributed under the terms of
|
|
||||||
this Lesser General Public License (also called "this License").
|
|
||||||
Each licensee is addressed as "you".
|
|
||||||
|
|
||||||
A "library" means a collection of software functions and/or data
|
|
||||||
prepared so as to be conveniently linked with application programs
|
|
||||||
(which use some of those functions and data) to form executables.
|
|
||||||
|
|
||||||
The "Library", below, refers to any such software library or work
|
|
||||||
which has been distributed under these terms. A "work based on the
|
|
||||||
Library" means either the Library or any derivative work under
|
|
||||||
copyright law: that is to say, a work containing the Library or a
|
|
||||||
portion of it, either verbatim or with modifications and/or translated
|
|
||||||
straightforwardly into another language. (Hereinafter, translation is
|
|
||||||
included without limitation in the term "modification".)
|
|
||||||
|
|
||||||
"Source code" for a work means the preferred form of the work for
|
|
||||||
making modifications to it. For a library, complete source code means
|
|
||||||
all the source code for all modules it contains, plus any associated
|
|
||||||
interface definition files, plus the scripts used to control compilation
|
|
||||||
and installation of the library.
|
|
||||||
|
|
||||||
Activities other than copying, distribution and modification are not
|
|
||||||
covered by this License; they are outside its scope. The act of
|
|
||||||
running a program using the Library is not restricted, and output from
|
|
||||||
such a program is covered only if its contents constitute a work based
|
|
||||||
on the Library (independent of the use of the Library in a tool for
|
|
||||||
writing it). Whether that is true depends on what the Library does
|
|
||||||
and what the program that uses the Library does.
|
|
||||||
|
|
||||||
1. You may copy and distribute verbatim copies of the Library's
|
|
||||||
complete source code as you receive it, in any medium, provided that
|
|
||||||
you conspicuously and appropriately publish on each copy an
|
|
||||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
|
||||||
all the notices that refer to this License and to the absence of any
|
|
||||||
warranty; and distribute a copy of this License along with the
|
|
||||||
Library.
|
|
||||||
|
|
||||||
You may charge a fee for the physical act of transferring a copy,
|
|
||||||
and you may at your option offer warranty protection in exchange for a
|
|
||||||
fee.
|
|
||||||
|
|
||||||
2. You may modify your copy or copies of the Library or any portion
|
|
||||||
of it, thus forming a work based on the Library, and copy and
|
|
||||||
distribute such modifications or work under the terms of Section 1
|
|
||||||
above, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The modified work must itself be a software library.
|
|
||||||
|
|
||||||
b) You must cause the files modified to carry prominent notices
|
|
||||||
stating that you changed the files and the date of any change.
|
|
||||||
|
|
||||||
c) You must cause the whole of the work to be licensed at no
|
|
||||||
charge to all third parties under the terms of this License.
|
|
||||||
|
|
||||||
d) If a facility in the modified Library refers to a function or a
|
|
||||||
table of data to be supplied by an application program that uses
|
|
||||||
the facility, other than as an argument passed when the facility
|
|
||||||
is invoked, then you must make a good faith effort to ensure that,
|
|
||||||
in the event an application does not supply such function or
|
|
||||||
table, the facility still operates, and performs whatever part of
|
|
||||||
its purpose remains meaningful.
|
|
||||||
|
|
||||||
(For example, a function in a library to compute square roots has
|
|
||||||
a purpose that is entirely well-defined independent of the
|
|
||||||
application. Therefore, Subsection 2d requires that any
|
|
||||||
application-supplied function or table used by this function must
|
|
||||||
be optional: if the application does not supply it, the square
|
|
||||||
root function must still compute square roots.)
|
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
|
||||||
identifiable sections of that work are not derived from the Library,
|
|
||||||
and can be reasonably considered independent and separate works in
|
|
||||||
themselves, then this License, and its terms, do not apply to those
|
|
||||||
sections when you distribute them as separate works. But when you
|
|
||||||
distribute the same sections as part of a whole which is a work based
|
|
||||||
on the Library, the distribution of the whole must be on the terms of
|
|
||||||
this License, whose permissions for other licensees extend to the
|
|
||||||
entire whole, and thus to each and every part regardless of who wrote
|
|
||||||
it.
|
|
||||||
|
|
||||||
Thus, it is not the intent of this section to claim rights or contest
|
|
||||||
your rights to work written entirely by you; rather, the intent is to
|
|
||||||
exercise the right to control the distribution of derivative or
|
|
||||||
collective works based on the Library.
|
|
||||||
|
|
||||||
In addition, mere aggregation of another work not based on the Library
|
|
||||||
with the Library (or with a work based on the Library) on a volume of
|
|
||||||
a storage or distribution medium does not bring the other work under
|
|
||||||
the scope of this License.
|
|
||||||
|
|
||||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
|
||||||
License instead of this License to a given copy of the Library. To do
|
|
||||||
this, you must alter all the notices that refer to this License, so
|
|
||||||
that they refer to the ordinary GNU General Public License, version 2,
|
|
||||||
instead of to this License. (If a newer version than version 2 of the
|
|
||||||
ordinary GNU General Public License has appeared, then you can specify
|
|
||||||
that version instead if you wish.) Do not make any other change in
|
|
||||||
these notices.
|
|
||||||
|
|
||||||
Once this change is made in a given copy, it is irreversible for
|
|
||||||
that copy, so the ordinary GNU General Public License applies to all
|
|
||||||
subsequent copies and derivative works made from that copy.
|
|
||||||
|
|
||||||
This option is useful when you wish to copy part of the code of
|
|
||||||
the Library into a program that is not a library.
|
|
||||||
|
|
||||||
4. You may copy and distribute the Library (or a portion or
|
|
||||||
derivative of it, under Section 2) in object code or executable form
|
|
||||||
under the terms of Sections 1 and 2 above provided that you accompany
|
|
||||||
it with the complete corresponding machine-readable source code, which
|
|
||||||
must be distributed under the terms of Sections 1 and 2 above on a
|
|
||||||
medium customarily used for software interchange.
|
|
||||||
|
|
||||||
If distribution of object code is made by offering access to copy
|
|
||||||
from a designated place, then offering equivalent access to copy the
|
|
||||||
source code from the same place satisfies the requirement to
|
|
||||||
distribute the source code, even though third parties are not
|
|
||||||
compelled to copy the source along with the object code.
|
|
||||||
|
|
||||||
5. A program that contains no derivative of any portion of the
|
|
||||||
Library, but is designed to work with the Library by being compiled or
|
|
||||||
linked with it, is called a "work that uses the Library". Such a
|
|
||||||
work, in isolation, is not a derivative work of the Library, and
|
|
||||||
therefore falls outside the scope of this License.
|
|
||||||
|
|
||||||
However, linking a "work that uses the Library" with the Library
|
|
||||||
creates an executable that is a derivative of the Library (because it
|
|
||||||
contains portions of the Library), rather than a "work that uses the
|
|
||||||
library". The executable is therefore covered by this License.
|
|
||||||
Section 6 states terms for distribution of such executables.
|
|
||||||
|
|
||||||
When a "work that uses the Library" uses material from a header file
|
|
||||||
that is part of the Library, the object code for the work may be a
|
|
||||||
derivative work of the Library even though the source code is not.
|
|
||||||
Whether this is true is especially significant if the work can be
|
|
||||||
linked without the Library, or if the work is itself a library. The
|
|
||||||
threshold for this to be true is not precisely defined by law.
|
|
||||||
|
|
||||||
If such an object file uses only numerical parameters, data
|
|
||||||
structure layouts and accessors, and small macros and small inline
|
|
||||||
functions (ten lines or less in length), then the use of the object
|
|
||||||
file is unrestricted, regardless of whether it is legally a derivative
|
|
||||||
work. (Executables containing this object code plus portions of the
|
|
||||||
Library will still fall under Section 6.)
|
|
||||||
|
|
||||||
Otherwise, if the work is a derivative of the Library, you may
|
|
||||||
distribute the object code for the work under the terms of Section 6.
|
|
||||||
Any executables containing that work also fall under Section 6,
|
|
||||||
whether or not they are linked directly with the Library itself.
|
|
||||||
|
|
||||||
6. As an exception to the Sections above, you may also combine or
|
|
||||||
link a "work that uses the Library" with the Library to produce a
|
|
||||||
work containing portions of the Library, and distribute that work
|
|
||||||
under terms of your choice, provided that the terms permit
|
|
||||||
modification of the work for the customer's own use and reverse
|
|
||||||
engineering for debugging such modifications.
|
|
||||||
|
|
||||||
You must give prominent notice with each copy of the work that the
|
|
||||||
Library is used in it and that the Library and its use are covered by
|
|
||||||
this License. You must supply a copy of this License. If the work
|
|
||||||
during execution displays copyright notices, you must include the
|
|
||||||
copyright notice for the Library among them, as well as a reference
|
|
||||||
directing the user to the copy of this License. Also, you must do one
|
|
||||||
of these things:
|
|
||||||
|
|
||||||
a) Accompany the work with the complete corresponding
|
|
||||||
machine-readable source code for the Library including whatever
|
|
||||||
changes were used in the work (which must be distributed under
|
|
||||||
Sections 1 and 2 above); and, if the work is an executable linked
|
|
||||||
with the Library, with the complete machine-readable "work that
|
|
||||||
uses the Library", as object code and/or source code, so that the
|
|
||||||
user can modify the Library and then relink to produce a modified
|
|
||||||
executable containing the modified Library. (It is understood
|
|
||||||
that the user who changes the contents of definitions files in the
|
|
||||||
Library will not necessarily be able to recompile the application
|
|
||||||
to use the modified definitions.)
|
|
||||||
|
|
||||||
b) Use a suitable shared library mechanism for linking with the
|
|
||||||
Library. A suitable mechanism is one that (1) uses at run time a
|
|
||||||
copy of the library already present on the user's computer system,
|
|
||||||
rather than copying library functions into the executable, and (2)
|
|
||||||
will operate properly with a modified version of the library, if
|
|
||||||
the user installs one, as long as the modified version is
|
|
||||||
interface-compatible with the version that the work was made with.
|
|
||||||
|
|
||||||
c) Accompany the work with a written offer, valid for at
|
|
||||||
least three years, to give the same user the materials
|
|
||||||
specified in Subsection 6a, above, for a charge no more
|
|
||||||
than the cost of performing this distribution.
|
|
||||||
|
|
||||||
d) If distribution of the work is made by offering access to copy
|
|
||||||
from a designated place, offer equivalent access to copy the above
|
|
||||||
specified materials from the same place.
|
|
||||||
|
|
||||||
e) Verify that the user has already received a copy of these
|
|
||||||
materials or that you have already sent this user a copy.
|
|
||||||
|
|
||||||
For an executable, the required form of the "work that uses the
|
|
||||||
Library" must include any data and utility programs needed for
|
|
||||||
reproducing the executable from it. However, as a special exception,
|
|
||||||
the materials to be distributed need not include anything that is
|
|
||||||
normally distributed (in either source or binary form) with the major
|
|
||||||
components (compiler, kernel, and so on) of the operating system on
|
|
||||||
which the executable runs, unless that component itself accompanies
|
|
||||||
the executable.
|
|
||||||
|
|
||||||
It may happen that this requirement contradicts the license
|
|
||||||
restrictions of other proprietary libraries that do not normally
|
|
||||||
accompany the operating system. Such a contradiction means you cannot
|
|
||||||
use both them and the Library together in an executable that you
|
|
||||||
distribute.
|
|
||||||
|
|
||||||
7. You may place library facilities that are a work based on the
|
|
||||||
Library side-by-side in a single library together with other library
|
|
||||||
facilities not covered by this License, and distribute such a combined
|
|
||||||
library, provided that the separate distribution of the work based on
|
|
||||||
the Library and of the other library facilities is otherwise
|
|
||||||
permitted, and provided that you do these two things:
|
|
||||||
|
|
||||||
a) Accompany the combined library with a copy of the same work
|
|
||||||
based on the Library, uncombined with any other library
|
|
||||||
facilities. This must be distributed under the terms of the
|
|
||||||
Sections above.
|
|
||||||
|
|
||||||
b) Give prominent notice with the combined library of the fact
|
|
||||||
that part of it is a work based on the Library, and explaining
|
|
||||||
where to find the accompanying uncombined form of the same work.
|
|
||||||
|
|
||||||
8. You may not copy, modify, sublicense, link with, or distribute
|
|
||||||
the Library except as expressly provided under this License. Any
|
|
||||||
attempt otherwise to copy, modify, sublicense, link with, or
|
|
||||||
distribute the Library is void, and will automatically terminate your
|
|
||||||
rights under this License. However, parties who have received copies,
|
|
||||||
or rights, from you under this License will not have their licenses
|
|
||||||
terminated so long as such parties remain in full compliance.
|
|
||||||
|
|
||||||
9. You are not required to accept this License, since you have not
|
|
||||||
signed it. However, nothing else grants you permission to modify or
|
|
||||||
distribute the Library or its derivative works. These actions are
|
|
||||||
prohibited by law if you do not accept this License. Therefore, by
|
|
||||||
modifying or distributing the Library (or any work based on the
|
|
||||||
Library), you indicate your acceptance of this License to do so, and
|
|
||||||
all its terms and conditions for copying, distributing or modifying
|
|
||||||
the Library or works based on it.
|
|
||||||
|
|
||||||
10. Each time you redistribute the Library (or any work based on the
|
|
||||||
Library), the recipient automatically receives a license from the
|
|
||||||
original licensor to copy, distribute, link with or modify the Library
|
|
||||||
subject to these terms and conditions. You may not impose any further
|
|
||||||
restrictions on the recipients' exercise of the rights granted herein.
|
|
||||||
You are not responsible for enforcing compliance by third parties with
|
|
||||||
this License.
|
|
||||||
|
|
||||||
11. If, as a consequence of a court judgment or allegation of patent
|
|
||||||
infringement or for any other reason (not limited to patent issues),
|
|
||||||
conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot
|
|
||||||
distribute so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you
|
|
||||||
may not distribute the Library at all. For example, if a patent
|
|
||||||
license would not permit royalty-free redistribution of the Library by
|
|
||||||
all those who receive copies directly or indirectly through you, then
|
|
||||||
the only way you could satisfy both it and this License would be to
|
|
||||||
refrain entirely from distribution of the Library.
|
|
||||||
|
|
||||||
If any portion of this section is held invalid or unenforceable under any
|
|
||||||
particular circumstance, the balance of the section is intended to apply,
|
|
||||||
and the section as a whole is intended to apply in other circumstances.
|
|
||||||
|
|
||||||
It is not the purpose of this section to induce you to infringe any
|
|
||||||
patents or other property right claims or to contest validity of any
|
|
||||||
such claims; this section has the sole purpose of protecting the
|
|
||||||
integrity of the free software distribution system which is
|
|
||||||
implemented by public license practices. Many people have made
|
|
||||||
generous contributions to the wide range of software distributed
|
|
||||||
through that system in reliance on consistent application of that
|
|
||||||
system; it is up to the author/donor to decide if he or she is willing
|
|
||||||
to distribute software through any other system and a licensee cannot
|
|
||||||
impose that choice.
|
|
||||||
|
|
||||||
This section is intended to make thoroughly clear what is believed to
|
|
||||||
be a consequence of the rest of this License.
|
|
||||||
|
|
||||||
12. If the distribution and/or use of the Library is restricted in
|
|
||||||
certain countries either by patents or by copyrighted interfaces, the
|
|
||||||
original copyright holder who places the Library under this License may add
|
|
||||||
an explicit geographical distribution limitation excluding those countries,
|
|
||||||
so that distribution is permitted only in or among countries not thus
|
|
||||||
excluded. In such case, this License incorporates the limitation as if
|
|
||||||
written in the body of this License.
|
|
||||||
|
|
||||||
13. The Free Software Foundation may publish revised and/or new
|
|
||||||
versions of the Lesser General Public License from time to time.
|
|
||||||
Such new versions will be similar in spirit to the present version,
|
|
||||||
but may differ in detail to address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Library
|
|
||||||
specifies a version number of this License which applies to it and
|
|
||||||
"any later version", you have the option of following the terms and
|
|
||||||
conditions either of that version or of any later version published by
|
|
||||||
the Free Software Foundation. If the Library does not specify a
|
|
||||||
license version number, you may choose any version ever published by
|
|
||||||
the Free Software Foundation.
|
|
||||||
|
|
||||||
14. If you wish to incorporate parts of the Library into other free
|
|
||||||
programs whose distribution conditions are incompatible with these,
|
|
||||||
write to the author to ask for permission. For software which is
|
|
||||||
copyrighted by the Free Software Foundation, write to the Free
|
|
||||||
Software Foundation; we sometimes make exceptions for this. Our
|
|
||||||
decision will be guided by the two goals of preserving the free status
|
|
||||||
of all derivatives of our free software and of promoting the sharing
|
|
||||||
and reuse of software generally.
|
|
||||||
|
|
||||||
NO WARRANTY
|
|
||||||
|
|
||||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
|
||||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
|
||||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
|
||||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
|
||||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
|
||||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
|
||||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
|
||||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
|
||||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
|
||||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
|
||||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
|
||||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
|
||||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
|
||||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
|
||||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
||||||
DAMAGES.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Libraries
|
|
||||||
|
|
||||||
If you develop a new library, and you want it to be of the greatest
|
|
||||||
possible use to the public, we recommend making it free software that
|
|
||||||
everyone can redistribute and change. You can do so by permitting
|
|
||||||
redistribution under these terms (or, alternatively, under the terms of the
|
|
||||||
ordinary General Public License).
|
|
||||||
|
|
||||||
To apply these terms, attach the following notices to the library. It is
|
|
||||||
safest to attach them to the start of each source file to most effectively
|
|
||||||
convey the exclusion of warranty; and each file should have at least the
|
|
||||||
"copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the library's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or your
|
|
||||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
|
||||||
necessary. Here is a sample; alter the names:
|
|
||||||
|
|
||||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
|
||||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
|
||||||
|
|
||||||
<signature of Ty Coon>, 1 April 1990
|
|
||||||
Ty Coon, President of Vice
|
|
||||||
|
|
||||||
That's all there is to it!
|
|
@ -1,4 +1,4 @@
|
|||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
SUBDIRS = src instfiles
|
SUBDIRS = src
|
||||||
EXTRA_DIST = bootstrap.sh
|
EXTRA_DIST = bootstrap.sh
|
||||||
|
134
README.md
134
README.md
@ -1,5 +1,9 @@
|
|||||||
[](https://github.com/neutrinolabs/pulseaudio-module-xrdp/actions)
|
[](https://travis-ci.org/neutrinolabs/pulseaudio-module-xrdp)
|
||||||
[](https://gitter.im/neutrinolabs/xrdp-questions)
|
|
||||||
|
The latest version of this document can be found at wiki.
|
||||||
|
|
||||||
|
* https://github.com/neutrinolabs/pulseaudio-module-xrdp/wiki/README
|
||||||
|
|
||||||
|
|
||||||
# Overview
|
# Overview
|
||||||
xrdp implements Audio Output redirection using PulseAudio, which is a sound
|
xrdp implements Audio Output redirection using PulseAudio, which is a sound
|
||||||
@ -11,59 +15,107 @@ Protocol: Audio Output Virtual Channel Extension
|
|||||||
which means it is interoperable with any RDP client which implements it
|
which means it is interoperable with any RDP client which implements it
|
||||||
(most of them including: MS RDP clients, FreeRDP).
|
(most of them including: MS RDP clients, FreeRDP).
|
||||||
|
|
||||||
The client to server audio redirection is implemented as per **Remote Desktop
|
However, our Microphone redirection (client to server) implementation is
|
||||||
Protocol: Audio Input Redirection Virtual Channel Extension
|
proprietary and doesn't implement the
|
||||||
[[MS-RDPEAI]](https://msdn.microsoft.com/en-us/library/dd342521.aspx)**
|
[[MS-RDPEAI]](https://msdn.microsoft.com/en-us/library/dd342521.aspx)
|
||||||
which means it is interoperable with any RDP client which implements it
|
specs. Its only supported by the following clients so far: NeutrinoRDP client
|
||||||
(most of them including: MS RDP clients, FreeRDP).
|
and rdesktop.
|
||||||
|
|
||||||
|
Here is how to build pulseaudio modules for your distro, so you can have audio
|
||||||
|
support through xrdp.
|
||||||
|
|
||||||
|
In this instruction, pulseaudio version is **11.1**. You need to **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
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
pkg-config --modversion libpulse
|
||||||
|
|
||||||
# How to build
|
# How to build
|
||||||
These modules make use of the internal pulseaudio module API. To build
|
|
||||||
them you need access to the pulseaudio sources and configuration.
|
|
||||||
|
|
||||||
*Be aware that the pulseaudio application development packages provided
|
## Debian 9 / Ubuntu
|
||||||
with many distributions do not contain the files necessary to use the
|
|
||||||
pulseaudio module API*. Consequently, the preparation for building these
|
|
||||||
modules can be a little more involved than just installing development
|
|
||||||
tools and packages.
|
|
||||||
|
|
||||||
Consult the Pulseaudio Wiki for instructions on building the modules
|
This instruction also should be applicable to the Ubuntu family.
|
||||||
for your platform:-
|
|
||||||
|
|
||||||
https://github.com/neutrinolabs/pulseaudio-module-xrdp/wiki
|
### 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-11.1` directory in your
|
||||||
|
current directory.
|
||||||
|
|
||||||
|
apt source pulseaudio
|
||||||
|
|
||||||
|
Enter into the directory and build the pulseaudio package.
|
||||||
|
|
||||||
|
cd pulseaudio-11.1
|
||||||
|
./configure
|
||||||
|
|
||||||
|
Finally, let's build xrdp source / sink modules. You'll have two .so files
|
||||||
|
`module-xrdp-sink.so` and `module-xrdp-source.so`.
|
||||||
|
|
||||||
|
git clone https://github.com/neutrinolabs/pulseaudio-module-xrdp.git
|
||||||
|
cd pulseaudio-module-xrdp
|
||||||
|
./bootstrap && ./configure PULSE_DIR=/path/to/pulseaudio-11.1
|
||||||
|
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, extract the tarball and `cd` into the source
|
||||||
|
directory, then run `./configure`.
|
||||||
|
|
||||||
|
wget https://freedesktop.org/software/pulseaudio/releases/pulseaudio-11.1.tar.xz
|
||||||
|
tar xf pulseaudio-11.1.tar.xz
|
||||||
|
cd pulseaudio-11.1
|
||||||
|
./configure
|
||||||
|
|
||||||
|
If additional packages are required to run `./configure`, install requisite
|
||||||
|
packages depending on your environment.
|
||||||
|
|
||||||
|
Finally, let's build xrdp source / sink modules. You'll have two .so files
|
||||||
|
`module-xrdp-sink.so` and `module-xrdp-source.so`.
|
||||||
|
|
||||||
|
git clone https://github.com/neutrinolabs/pulseaudio-module-xrdp.git
|
||||||
|
cd pulseaudio-module-xrdp
|
||||||
|
./bootstrap && ./configure PULSE_DIR=/path/to/pulseaudio-11.1
|
||||||
|
make
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
One the modules have been built, `sudo make install` should do the following:-
|
|
||||||
- Install the modules to the correct directory
|
|
||||||
- Install a script `load_pa_modules.sh` to load the modules when a
|
|
||||||
session is started.
|
|
||||||
On many systems this script is installed by default in
|
|
||||||
/usr/libexec/pulseaudio-module-xrdp/
|
|
||||||
- Install a desktop file `pulseaudio-xrdp.desktop` which will call the
|
|
||||||
`load_pa_modules.sh` script when a desktop is loaded.
|
|
||||||
On many systems this script is installed by default in
|
|
||||||
`/etc/xdg/autostart`
|
|
||||||
|
|
||||||
Note that the modules will only be loaded automatically when the desktop
|
Just `make install` should install built modules to the correct directory.
|
||||||
starts if your desktop supports the XDG autostart specification. Most modern
|
|
||||||
desktops support this.
|
|
||||||
|
|
||||||
You can confirm if the modules are properly installed by following command:
|
You can confirm if the modules properly installed by following command:
|
||||||
```
|
```
|
||||||
ls $(pkg-config --variable=modlibexecdir libpulse) | grep xrdp
|
ls $(pkg-config --variable=modlibexecdir libpulse)
|
||||||
```
|
```
|
||||||
|
|
||||||
If you can see `module-xrdp-sink.so` and `module-xrdp-source.so`,
|
If you can see lots of `module-*.so` and `module-xrdp-sink.so`,
|
||||||
PulseAudio modules are properly built and installed.
|
`module-xrdp-source.so`, PulseAudio modules should be properly built and
|
||||||
|
installed.
|
||||||
|
|
||||||
Enjoy!
|
Enjoy!
|
||||||
|
|
||||||
# See if it works
|
# See if it works
|
||||||
The easiest way to test this is to use the `paplay` command to play an
|
|
||||||
audio file.
|
|
||||||
|
|
||||||
You can also do the following:-
|
To see if it works, run `pavumeter` in the xrdp session. Playback any YouTube
|
||||||
- run `pavumeter` in the xrdp session-
|
video in Firefox. You'll see "Showing signal levels of **xrdp sink**" and
|
||||||
- Playback any YouTube video in Firefox.
|
volume meter moving.
|
||||||
|
|
||||||
You'll see "Showing signal levels of **xrdp sink**" and volume meter moving.
|
|
||||||
|
53
configure.ac
53
configure.ac
@ -2,7 +2,7 @@
|
|||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ([2.65])
|
AC_PREREQ([2.65])
|
||||||
AC_INIT([pulseaudio-module-xrdp], [0.8], [xrdp-devel@googlegroups.com])
|
AC_INIT([pulseaudio-module-xrdp], [0.1], [xrdp-devel@googlegroups.com])
|
||||||
# specify config_ac.h so we don't collide with pulseaudio's config.h
|
# specify config_ac.h so we don't collide with pulseaudio's config.h
|
||||||
AC_CONFIG_HEADERS([config_ac.h])
|
AC_CONFIG_HEADERS([config_ac.h])
|
||||||
AC_CONFIG_SRCDIR([src])
|
AC_CONFIG_SRCDIR([src])
|
||||||
@ -20,16 +20,6 @@ fi
|
|||||||
|
|
||||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||||
|
|
||||||
dnl ------------------------------------------------------------------
|
|
||||||
dnl FIND_CONFIG_H(TOP_DIRECTORY)
|
|
||||||
dnl Find the config.h file under TOP_DIRECTORY
|
|
||||||
dnl
|
|
||||||
dnl Outputs the enclosing directory. Only the first match is returned.
|
|
||||||
dnl ------------------------------------------------------------------
|
|
||||||
m4_define([FIND_CONFIG_H],
|
|
||||||
[find $1 -type f -maxdepth 3 -type f -name config.h | \
|
|
||||||
sed -e 's#/config.h##' -e '2,$d'])
|
|
||||||
|
|
||||||
# get system's pulseaudio version
|
# get system's pulseaudio version
|
||||||
m4_define([pa_major], [`$PKG_CONFIG --modversion libpulse | cut -d. -f1`])
|
m4_define([pa_major], [`$PKG_CONFIG --modversion libpulse | cut -d. -f1`])
|
||||||
m4_define([pa_minor], [`$PKG_CONFIG --modversion libpulse | cut -d. -f2`])
|
m4_define([pa_minor], [`$PKG_CONFIG --modversion libpulse | cut -d. -f2`])
|
||||||
@ -38,9 +28,6 @@ PA_LIBDIR=`$PKG_CONFIG --variable=libdir libpulse`
|
|||||||
PA_MODDIR=`$PKG_CONFIG --variable=modlibexecdir libpulse`
|
PA_MODDIR=`$PKG_CONFIG --variable=modlibexecdir libpulse`
|
||||||
PA_PREFIX=`$PKG_CONFIG --variable=prefix libpulse`
|
PA_PREFIX=`$PKG_CONFIG --variable=prefix libpulse`
|
||||||
|
|
||||||
# Default system-wide autostart directory from XDG autostart specification
|
|
||||||
m4_define([XDG_AUTOSTART_DIR], /etc/xdg/autostart)
|
|
||||||
|
|
||||||
AC_SUBST([PA_MAJOR], [pa_major])
|
AC_SUBST([PA_MAJOR], [pa_major])
|
||||||
AC_SUBST([PA_MINOR], [pa_minor])
|
AC_SUBST([PA_MINOR], [pa_minor])
|
||||||
AC_SUBST([PA_MAJORMINOR], [pa_major].[pa_minor])
|
AC_SUBST([PA_MAJORMINOR], [pa_major].[pa_minor])
|
||||||
@ -58,11 +45,12 @@ AC_PROG_LN_S
|
|||||||
AC_PROG_MAKE_SET
|
AC_PROG_MAKE_SET
|
||||||
|
|
||||||
# Checks for libraries.
|
# Checks for libraries.
|
||||||
|
PKG_CHECK_MODULES([XRDP], [xrdp >= 0.9.0])
|
||||||
|
AC_SUBST(XRDP_CFLAGS)
|
||||||
PKG_CHECK_MODULES([LIBPULSE], [libpulse])
|
PKG_CHECK_MODULES([LIBPULSE], [libpulse])
|
||||||
|
|
||||||
m4_define([PULSE_MSG], [PULSE_DIR not specified. Follow the instructions in README.md.])
|
m4_define([PULSE_MSG], [PULSE_DIR not specified. Follow the instructions in README.md.])
|
||||||
|
|
||||||
# Check PULSE_DIR is specified
|
|
||||||
AC_ARG_VAR([PULSE_DIR], [pulseaudio source code directory])
|
AC_ARG_VAR([PULSE_DIR], [pulseaudio source code directory])
|
||||||
AS_IF([test x"$PULSE_DIR" == x""],
|
AS_IF([test x"$PULSE_DIR" == x""],
|
||||||
cat <<__MSG__
|
cat <<__MSG__
|
||||||
@ -71,31 +59,6 @@ __MSG__
|
|||||||
AC_MSG_ERROR([PULSE_DIR not specified])
|
AC_MSG_ERROR([PULSE_DIR not specified])
|
||||||
)
|
)
|
||||||
|
|
||||||
# Does PULSE_DIR appear to be valid?
|
|
||||||
AS_IF([test -e "$PULSE_DIR/src/pulsecore/macro.h"],,
|
|
||||||
AC_MSG_WARN([PULSE_DIR may not be valid - can't find expected file]))
|
|
||||||
|
|
||||||
# Look for config.h, using PULSE_CONFIG_DIR if specified
|
|
||||||
AC_ARG_VAR([PULSE_CONFIG_DIR], [pulseaudio config.h source code directory (optional)])
|
|
||||||
AS_IF([test x"$PULSE_CONFIG_DIR" == x""],
|
|
||||||
AC_MSG_NOTICE([PULSE_CONFIG_DIR not defined])
|
|
||||||
AC_MSG_CHECKING([Searching for config.h under PULSE_DIR])
|
|
||||||
PULSE_CONFIG_DIR="`FIND_CONFIG_H(\"$PULSE_DIR\")`"
|
|
||||||
[AS_IF([test -e "$PULSE_CONFIG_DIR/config.h" ],
|
|
||||||
AC_MSG_RESULT([$PULSE_CONFIG_DIR/config.h])
|
|
||||||
,
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
AC_MSG_ERROR([Can't find config.h under PULSE_DIR. Define PULSE_CONFIG_DIR?]))]
|
|
||||||
,
|
|
||||||
AC_MSG_NOTICE([PULSE_CONFIG_DIR is defined])
|
|
||||||
AC_MSG_CHECKING([Looking for config.h in PULSE_CONFIG_DIR])
|
|
||||||
[AS_IF([test -e "$PULSE_CONFIG_DIR/config.h"],
|
|
||||||
AC_MSG_RESULT([$PULSE_CONFIG_DIR/config.h])
|
|
||||||
,
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
AC_MSG_ERROR([Can't find config.h in PULSE_CONFIG_DIR.]))])
|
|
||||||
|
|
||||||
|
|
||||||
# use the prefix as same as pulseaudio
|
# use the prefix as same as pulseaudio
|
||||||
AC_PREFIX_PROGRAM(pulseaudio)
|
AC_PREFIX_PROGRAM(pulseaudio)
|
||||||
|
|
||||||
@ -107,13 +70,6 @@ AC_ARG_WITH(
|
|||||||
[modlibexecdir=$withval], [modlibexecdir="${PA_MODDIR}"])
|
[modlibexecdir=$withval], [modlibexecdir="${PA_MODDIR}"])
|
||||||
AC_SUBST(modlibexecdir)
|
AC_SUBST(modlibexecdir)
|
||||||
|
|
||||||
AC_ARG_WITH(
|
|
||||||
[xdgautostart-dir],
|
|
||||||
[AS_HELP_STRING([--with-xdgautostart-dir],
|
|
||||||
Directory to install the desktop file (defaults to XDG_AUTOSTART_DIR))],
|
|
||||||
[xdgautostartdir=$withval], [xdgautostartdir=XDG_AUTOSTART_DIR])
|
|
||||||
AC_SUBST(xdgautostartdir)
|
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_CHECK_HEADERS([fcntl.h limits.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h unistd.h])
|
AC_CHECK_HEADERS([fcntl.h limits.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h unistd.h])
|
||||||
|
|
||||||
@ -126,6 +82,5 @@ AC_TYPE_UINT32_T
|
|||||||
AC_CHECK_FUNCS([memset socket])
|
AC_CHECK_FUNCS([memset socket])
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile
|
AC_CONFIG_FILES([Makefile
|
||||||
src/Makefile
|
src/Makefile])
|
||||||
instfiles/Makefile])
|
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
EXTRA_DIST = \
|
|
||||||
load_pa_modules.sh \
|
|
||||||
pulseaudio-xrdp.desktop.in
|
|
||||||
|
|
||||||
#
|
|
||||||
# substitute directories in service file
|
|
||||||
#
|
|
||||||
CLEANFILES= \
|
|
||||||
pulseaudio-xrdp.desktop
|
|
||||||
|
|
||||||
SUBST_VARS = sed \
|
|
||||||
-e 's|@pkglibexecdir[@]|$(pkglibexecdir)|g'
|
|
||||||
|
|
||||||
subst_verbose = $(subst_verbose_@AM_V@)
|
|
||||||
subst_verbose_ = $(subst_verbose_@AM_DEFAULT_V@)
|
|
||||||
subst_verbose_0 = @echo " SUBST $@";
|
|
||||||
|
|
||||||
SUFFIXES = .in
|
|
||||||
.in:
|
|
||||||
$(subst_verbose)$(SUBST_VARS) $< > $@
|
|
||||||
|
|
||||||
#
|
|
||||||
# files for all platforms
|
|
||||||
#
|
|
||||||
xdgautostart_DATA = \
|
|
||||||
pulseaudio-xrdp.desktop
|
|
||||||
|
|
||||||
pkglibexec_SCRIPTS = \
|
|
||||||
load_pa_modules.sh
|
|
@ -1,54 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
status=0
|
|
||||||
|
|
||||||
if [ -n "$XRDP_SESSION" -a -n "$XRDP_SOCKET_PATH" ]; then
|
|
||||||
# These values are not present on xrdp versions before v0.9.8
|
|
||||||
if [ -z "$XRDP_PULSE_SINK_SOCKET" -o \
|
|
||||||
-z "$XRDP_PULSE_SOURCE_SOCKET" ]; then
|
|
||||||
displaynum=${DISPLAY##*:}
|
|
||||||
displaynum=${displaynum%.*}
|
|
||||||
XRDP_PULSE_SINK_SOCKET=xrdp_chansrv_audio_out_socket_$displaynum
|
|
||||||
XRDP_PULSE_SOURCE_SOCKET=xrdp_chansrv_audio_in_socket_$displaynum
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Don't check for the presence of the sockets, as if the modules
|
|
||||||
# are loaded they won't be there
|
|
||||||
|
|
||||||
# Unload modules
|
|
||||||
pactl unload-module module-xrdp-sink >/dev/null 2>&1
|
|
||||||
pactl unload-module module-xrdp-source >/dev/null 2>&1
|
|
||||||
|
|
||||||
# Reload modules
|
|
||||||
if pactl load-module module-xrdp-sink \
|
|
||||||
xrdp_socket_path=$XRDP_SOCKET_PATH \
|
|
||||||
xrdp_pulse_sink_socket=$XRDP_PULSE_SINK_SOCKET
|
|
||||||
then
|
|
||||||
echo "- pulseaudio xrdp-sink loaded"
|
|
||||||
if pacmd set-default-sink xrdp-sink; then
|
|
||||||
echo "- pulseaudio xrdp-sink set as default"
|
|
||||||
else
|
|
||||||
echo "? Can't set pulseaudio xrdp-sink as default"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "? Can't load pulseaudio xrdp-sink"
|
|
||||||
status=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if pactl load-module module-xrdp-source \
|
|
||||||
xrdp_socket_path=$XRDP_SOCKET_PATH \
|
|
||||||
xrdp_pulse_source_socket=$XRDP_PULSE_SOURCE_SOCKET
|
|
||||||
then
|
|
||||||
echo "- pulseaudio xrdp-source loaded"
|
|
||||||
if pacmd set-default-source xrdp-source; then
|
|
||||||
echo "- pulseaudio xrdp-source set as default"
|
|
||||||
else
|
|
||||||
echo "? Can't set pulseaudio xrdp-source as default"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "? Can't load pulseaudio xrdp-source"
|
|
||||||
status=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit $status
|
|
@ -1,9 +0,0 @@
|
|||||||
[Desktop Entry]
|
|
||||||
Version=1.0
|
|
||||||
Name=PulseAudio xrdp modules
|
|
||||||
Comment=Load PulseAudio Modules for xrdp
|
|
||||||
Exec=@pkglibexecdir@/load_pa_modules.sh
|
|
||||||
Terminal=false
|
|
||||||
Type=Application
|
|
||||||
Categories=
|
|
||||||
GenericName=
|
|
@ -1,197 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# xrdp: A Remote Desktop Protocol server.
|
|
||||||
#
|
|
||||||
# Copyright (C) 2021 Matt Burt, all xrdp contributors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
# Builds the pulseaudio sources on Debian/Ubuntu and writes the internal
|
|
||||||
# pulseaudio files needed to build the xrdp pulseaudio module into a
|
|
||||||
# single directory
|
|
||||||
|
|
||||||
# This script will pollute the machine with all the pulseaudio dependencies
|
|
||||||
# needed to build the pulseaudio dpkg. If this isn't acceptable, consider
|
|
||||||
# running this script in a schroot (or similar) wrapper.
|
|
||||||
|
|
||||||
# Use '-d <dir>' to specify an alternate directory
|
|
||||||
|
|
||||||
|
|
||||||
set -e ; # Exit on any error
|
|
||||||
|
|
||||||
# Target directory for output files
|
|
||||||
PULSE_DIR="$HOME/pulseaudio.src" ; # Default if nothing is specified
|
|
||||||
|
|
||||||
# Argument processing
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
arg="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
case "$arg" in
|
|
||||||
-d) if [ $# -gt 0 ]; then
|
|
||||||
PULSE_DIR="$1"
|
|
||||||
shift
|
|
||||||
else
|
|
||||||
echo "** $arg needs an argument" >&2
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*) echo "** Unrecognised argument '$arg'" >&2
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "$PULSE_DIR" ]; then
|
|
||||||
# Operating system release ?
|
|
||||||
RELEASE="$(lsb_release -si)-$(lsb_release -sr)"
|
|
||||||
codename=$(lsb_release -cs)
|
|
||||||
echo "Building for : $RELEASE ($codename)"
|
|
||||||
|
|
||||||
# Do any special-case stuff related to repositories
|
|
||||||
case $(lsb_release -si) in
|
|
||||||
Ubuntu)
|
|
||||||
# Enable the universe repository. Don't use add-apt-repository
|
|
||||||
# as this has a huge number of dependencies.
|
|
||||||
if [ -f /etc/apt/sources.list ] && \
|
|
||||||
! grep -q '^ *[^#].* universe *' /etc/apt/sources.list; then
|
|
||||||
echo "- Adding 'universe' repository" >&2
|
|
||||||
cp /etc/apt/sources.list /tmp/sources.list
|
|
||||||
while read type url suite rest; do
|
|
||||||
if [ "$type" = deb -a "$rest" = main ]; then
|
|
||||||
case "$suite" in
|
|
||||||
$codename | $codename-updates | $codename-security)
|
|
||||||
echo "deb $url $suite universe"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
done </tmp/sources.list \
|
|
||||||
| sudo tee -a /etc/apt/sources.list >/dev/null
|
|
||||||
rm /tmp/sources.list
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Scan the source repositories. Add sources for all repositories
|
|
||||||
# in this suite.
|
|
||||||
# Ignore other suites. This is needed when running the wrapper in a
|
|
||||||
# derivative-distro (like Linux Mint 21.2 'victoria') with --suite
|
|
||||||
# option (--suite=jammy).
|
|
||||||
echo "- Adding source repositories" >&2
|
|
||||||
SRCLIST=$(find /etc/apt/ /etc/apt/sources.list.d -maxdepth 1 -type f -name '*.list')
|
|
||||||
if [ -n "$SRCLIST" ]; then
|
|
||||||
# Older-style .list files have been detected
|
|
||||||
|
|
||||||
# Create a combined file for all .list sources, adding deb-src
|
|
||||||
# directives.
|
|
||||||
for srclst in $SRCLIST; do
|
|
||||||
while read type url suite rest; do
|
|
||||||
case "$suite" in
|
|
||||||
$codename | $codename-updates | $codename-security)
|
|
||||||
if [ "$type" = deb ]; then
|
|
||||||
echo "deb $url $suite $rest"
|
|
||||||
echo "deb-src $url $suite $rest"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done <$srclst
|
|
||||||
done >/tmp/combined_sources.list
|
|
||||||
|
|
||||||
sudo rm $SRCLIST ;# Remove source respositories
|
|
||||||
|
|
||||||
# remove duplicates from the combined sources.list in order to prevent
|
|
||||||
# apt warnings/errors; this is useful in cases where the user has
|
|
||||||
# already configured source code repositories.
|
|
||||||
sort -u < /tmp/combined_sources.list | \
|
|
||||||
sudo tee /etc/apt/sources.list > /dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Cater for DEB822 .sources files. These can appear alongside the
|
|
||||||
# older format.
|
|
||||||
for src in $(find /etc/apt/sources.list.d -maxdepth 1 -type f -name '*.sources'); do
|
|
||||||
# If we can find a match for the codename in the file, enable
|
|
||||||
# sources for all elements of the file. We assume that different
|
|
||||||
# codenames will be assigned to different files
|
|
||||||
if grep -iq "^suites:.* $codename" $src; then
|
|
||||||
sudo sed -i 's/^Types: deb/Types: deb deb-src/' "$src"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
sudo apt-get update
|
|
||||||
|
|
||||||
# For the CI build on 22.04, it was noted that an incompatible libunwind
|
|
||||||
# development package libunwind-14-dev was installed, which prevented
|
|
||||||
# installation of the default libunwind-dev package.
|
|
||||||
#
|
|
||||||
# Remove any libunwind-*-dev package
|
|
||||||
pkg_list=`dpkg-query -W -f '${Package} ' 'libunwind-*-dev' 2>/dev/null || :`
|
|
||||||
if [ -n "$pkg_list" ]; then
|
|
||||||
echo "- Removing package(s) $pkg_list"
|
|
||||||
sudo apt-get remove -y $pkg_list
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo apt-get build-dep -y pulseaudio
|
|
||||||
# Install any missing dependencies for this software release
|
|
||||||
case "$RELEASE" in
|
|
||||||
Ubuntu-16.04)
|
|
||||||
sudo apt-get install -y libjson-c-dev
|
|
||||||
;;
|
|
||||||
Kali-2022*)
|
|
||||||
sudo apt-get install -y doxygen
|
|
||||||
;;
|
|
||||||
Debian-12)
|
|
||||||
# Debian testing build
|
|
||||||
case "$codename" in
|
|
||||||
bookworm)
|
|
||||||
sudo apt-get install -y doxygen
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
cd "$(dirname $PULSE_DIR)"
|
|
||||||
apt-get source pulseaudio
|
|
||||||
|
|
||||||
build_dir="$(find . -maxdepth 1 -name pulseaudio-[0-9]\*)"
|
|
||||||
if [ -z "$build_dir" ]; then
|
|
||||||
echo "** Can't find build directory in $(ls)" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "$build_dir"
|
|
||||||
if [ -x ./configure ]; then
|
|
||||||
# This version of PA uses autotools to build
|
|
||||||
# This command creates ./config.h
|
|
||||||
./configure
|
|
||||||
elif [ -f ./meson.build ]; then
|
|
||||||
# Meson only
|
|
||||||
rm -rf build
|
|
||||||
# This command creates ./build/config.h
|
|
||||||
meson build
|
|
||||||
else
|
|
||||||
echo "** Unable to configure pulseaudio from files in $(pwd)" >&2
|
|
||||||
false
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "- Removing unnecessary files"
|
|
||||||
# We only need .h files...
|
|
||||||
find . -type f \! -name \*.h -delete
|
|
||||||
# .. in src/ and /build directories
|
|
||||||
find . -mindepth 1 -maxdepth 1 \
|
|
||||||
-name src -o -name build -o -name config.h \
|
|
||||||
-o -exec rm -rf {} +
|
|
||||||
|
|
||||||
echo "- Renaming $(pwd)/$build_dir as $PULSE_DIR"
|
|
||||||
cd ..
|
|
||||||
mv "$build_dir" "$PULSE_DIR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
|
@ -1,276 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# xrdp: A Remote Desktop Protocol server.
|
|
||||||
#
|
|
||||||
# Copyright (C) 2021 Matt Burt, all xrdp contributors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
# Wrapper to call install_pulseaudio_sources.sh and tidy up afterwards
|
|
||||||
#
|
|
||||||
# The following command line switches are supported, for systems based on
|
|
||||||
# Debian or Ubuntu:-
|
|
||||||
#
|
|
||||||
# 1) --mirror= Specify an alternative mirror for debootstrap
|
|
||||||
# 2) --keyring= Specify an alternative keyring for debootstrap
|
|
||||||
# 3) --suite= Specify an alternative suite for debootstrap
|
|
||||||
#
|
|
||||||
# The first two of these are are needed for systems with their own
|
|
||||||
# mirrors and signing keys (i.e. Raspberry PI OS).
|
|
||||||
#
|
|
||||||
# --suite is useful for systems which report their own codename for
|
|
||||||
# `lsb_release -c`, but are otherwise based on a standard distro. For
|
|
||||||
# example Linux Mint 20.04 reports 'una', but is largely based on
|
|
||||||
# Ubuntu 'focal'
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# G L O B A L S
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
# Where the output files are going
|
|
||||||
PULSE_DIRNAME=pulseaudio.src
|
|
||||||
PULSE_DIR=$HOME/$PULSE_DIRNAME
|
|
||||||
|
|
||||||
# Absolute path to the script we're wrapping. This picks it up from
|
|
||||||
# the same directory this file is in
|
|
||||||
WRAPPED_SCRIPT=$(cd $(dirname $0) && pwd)/install_pulseaudio_sources_apt.sh
|
|
||||||
|
|
||||||
# The buildroot directory. Choose fast, temporary storage if available
|
|
||||||
BUILDROOT=/var/lib/pa-build/$USER
|
|
||||||
|
|
||||||
# Extra packages to install in the build root which the wrapped script
|
|
||||||
# may be using. These are packages available by default when using
|
|
||||||
# GitHub actions
|
|
||||||
#
|
|
||||||
# ca-certificates are needed to fetch updates over https
|
|
||||||
#
|
|
||||||
# This list is comma-separated
|
|
||||||
WRAPPED_SCRIPT_DEPS="ca-certificates,sudo,lsb-release"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# S U I T E E X I S T S
|
|
||||||
#
|
|
||||||
# Does the specified debootstrap suite exist?
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
SuiteExists()
|
|
||||||
{
|
|
||||||
[ -f "/usr/share/debootstrap/scripts/$1" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# I N S T A L L R E Q U I R E D P A C K A G E S
|
|
||||||
#
|
|
||||||
# Installs packages required for the build on the host machine
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
InstallRequiredPackages()
|
|
||||||
{
|
|
||||||
set -- \
|
|
||||||
/usr/sbin/debootstrap debootstrap \
|
|
||||||
/usr/bin/schroot schroot \
|
|
||||||
/usr/bin/lsb_release lsb-release
|
|
||||||
|
|
||||||
pkgs=
|
|
||||||
while [ $# -ge 2 ]; do
|
|
||||||
if [ ! -x $1 ]; then
|
|
||||||
pkgs="$pkgs $2"
|
|
||||||
fi
|
|
||||||
shift 2
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -n "$pkgs" ]; then
|
|
||||||
echo "- Need to install packages :$pkgs"
|
|
||||||
echo
|
|
||||||
echo " These can be removed when this script completes with:-"
|
|
||||||
echo " sudo apt-get purge$pkgs && apt-get autoremove"
|
|
||||||
echo
|
|
||||||
sudo apt-get install -y $pkgs
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# R U N W R A P P E D S C R I P T
|
|
||||||
#
|
|
||||||
# Runs the wrapped build script using schroot
|
|
||||||
#
|
|
||||||
# This function definition uses () rather than {} to create an extra
|
|
||||||
# sub-process where we can run 'set -e' without affecting the parent
|
|
||||||
#
|
|
||||||
# Parameters : <script> [<script params>...]
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
RunWrappedScript()
|
|
||||||
(
|
|
||||||
# In this sub-process, fail on error
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Define default args for running program
|
|
||||||
# -c : Define the schroot config to use
|
|
||||||
# -d : Directory to switch to before running command
|
|
||||||
schroot="schroot -c pa-build-$USER -d /build"
|
|
||||||
|
|
||||||
# Update the buildroot
|
|
||||||
$schroot -u root -- apt-get update
|
|
||||||
|
|
||||||
# Allow normal user to sudo without a password. We may need to add the
|
|
||||||
# normal user, as it probably isn't created by debootstrap
|
|
||||||
sudoers_filename=$(mktemp -u /etc/sudoers.d/nopasswd-XXXXXXXX)
|
|
||||||
$schroot -u root -- useradd -m $USER -u $(id -u) || :
|
|
||||||
$schroot -u root -- \
|
|
||||||
/bin/sh -c "echo '$USER ALL=(ALL) NOPASSWD:ALL'>$sudoers_filename"
|
|
||||||
$schroot -u root -- chmod 400 "$sudoers_filename"
|
|
||||||
|
|
||||||
# Call the wrapped script
|
|
||||||
$schroot -- "$@"
|
|
||||||
)
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# M A I N
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
debootstrap_mirror=""
|
|
||||||
debootstrap_switches="--include=$WRAPPED_SCRIPT_DEPS"
|
|
||||||
debootstrap_suite=""
|
|
||||||
|
|
||||||
# Parse command line switches
|
|
||||||
while [ -n "$1" ]; do
|
|
||||||
case "$1" in
|
|
||||||
--mirror=*)
|
|
||||||
debootstrap_mirror="${1#--mirror=}"
|
|
||||||
;;
|
|
||||||
--keyring=*)
|
|
||||||
file="${1#--keyring=}"
|
|
||||||
if [ -f "$file" ]; then
|
|
||||||
debootstrap_switches="$debootstrap_switches $1"
|
|
||||||
else
|
|
||||||
echo "** Ignoring missing keyring $1" >&2
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
--suite=*)
|
|
||||||
debootstrap_suite="${1#--suite=}"
|
|
||||||
if ! SuiteExists "$debootstrap_suite"; then
|
|
||||||
echo "** Unsupported suite '$debootstrap_suite'" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*) echo "** Unrecognised parameter '$1'" >&2
|
|
||||||
exit 1
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
# Start with a few sanity checks
|
|
||||||
if [ -d $PULSE_DIR ]; then
|
|
||||||
echo "** Target directory $PULSE_DIR already exists" >&2
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -x $WRAPPED_SCRIPT ]; then
|
|
||||||
echo "** Can't find wrapped script $WRAPPED_SCRIPT" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -e $BUILDROOT ]; then
|
|
||||||
echo "** Remove old build root $BUILDROOT before running this script"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Do we need extra packages?
|
|
||||||
InstallRequiredPackages || exit $?
|
|
||||||
|
|
||||||
# We should be able to determine the suite now, if it's not specified
|
|
||||||
if [ -z "$debootstrap_suite" ]; then
|
|
||||||
debootstrap_suite=$(lsb_release -cs) ; # e.g. 'bullseye'
|
|
||||||
if [ -z "$debootstrap_suite" ]; then
|
|
||||||
echo "** Can't determine current suite" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! SuiteExists "$debootstrap_suite" ; then
|
|
||||||
echo "** Current distro '$debootstrap_suite' does not appear to be supported by debootstrap" >&2
|
|
||||||
echo " Need --suite switch?" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create the build root
|
|
||||||
log=/var/tmp/pa-build-$USER-debootstrap.log
|
|
||||||
echo "- Creating $debootstrap_suite build root. Log file in $log"
|
|
||||||
sudo debootstrap \
|
|
||||||
$debootstrap_switches \
|
|
||||||
$debootstrap_suite $BUILDROOT "$debootstrap_mirror" >$log 2>&1 || {
|
|
||||||
echo "** debootstrap failed. Check log file $log" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create the config file for schroot
|
|
||||||
schroot_conf=/etc/schroot/chroot.d/pa-build-$USER.conf
|
|
||||||
echo "- Creating schroot config file $schroot_conf"
|
|
||||||
{
|
|
||||||
echo "[pa-build-$USER]"
|
|
||||||
echo "description=Build PA on current system for $USER"
|
|
||||||
echo "directory=$BUILDROOT"
|
|
||||||
echo "root-users=$USER"
|
|
||||||
echo "users=$USER"
|
|
||||||
echo "type=directory"
|
|
||||||
# Make sure we don't clobber /etc/passwd, /etc/group (etc) which
|
|
||||||
# have been created by debootstrap
|
|
||||||
echo "setup.nssdatabases="
|
|
||||||
} | sudo tee $schroot_conf >/dev/null || exit $?
|
|
||||||
|
|
||||||
# Copy some files to the build root
|
|
||||||
for file in $(find /etc/apt/ /etc/apt/sources.list.d/ /etc/apt/mirrors/ \
|
|
||||||
-maxdepth 1 \
|
|
||||||
-type f \( -name '*.list' -o -name '*.sources' \) ); do
|
|
||||||
echo "- Copying $file to the root"
|
|
||||||
sudo install -Dm 0644 $file $BUILDROOT/$file || exit $?
|
|
||||||
done
|
|
||||||
|
|
||||||
for file in $(find /etc/apt/trusted.gpg.d/ \
|
|
||||||
-maxdepth 1 \
|
|
||||||
-type f -name '*.gpg' ); do
|
|
||||||
if [ ! -f "$BUILDROOT/$file" ]; then
|
|
||||||
echo "- Copying $file to the root"
|
|
||||||
sudo install -Dm 0644 $file $BUILDROOT/$file || exit $?
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Create a separate directory in $BUILDROOT to hold the build
|
|
||||||
# artefacts.
|
|
||||||
#
|
|
||||||
# We used to do the build on the user's home directory, but this
|
|
||||||
# isn't supported by schroot out-of-the-box on all configurations -
|
|
||||||
# see https://github.com/neutrinolabs/pulseaudio-module-xrdp/issues/76
|
|
||||||
echo "- Creating the build directory /build"
|
|
||||||
sudo install -d --mode=0775 --owner=$USER --group=$(id -g) \
|
|
||||||
$BUILDROOT/build || exit $?
|
|
||||||
|
|
||||||
# Copy the wrapped script to the buildroot root
|
|
||||||
echo "- Copying the wrapped script to the build directory"
|
|
||||||
sudo install -m 755 $WRAPPED_SCRIPT $BUILDROOT/build/wrapped_script || exit $?
|
|
||||||
|
|
||||||
# Run the wrapped script
|
|
||||||
log=/var/tmp/pa-build-$USER-schroot.log
|
|
||||||
echo "- Building PA sources. Log file in $log"
|
|
||||||
RunWrappedScript /build/wrapped_script -d /build/$PULSE_DIRNAME >$log 2>&1 || {
|
|
||||||
echo "** schroot failed. Check log file $log" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Done! Copy the resulting directory out of the build root
|
|
||||||
echo "- Copying sources out of the build root"
|
|
||||||
cp -pr $BUILDROOT/build/$PULSE_DIRNAME $PULSE_DIR || exit $?
|
|
||||||
|
|
||||||
# Remove the schroot config file as its no longer needed
|
|
||||||
echo "- Removing schroot config file and build root"
|
|
||||||
sudo rm -rf $schroot_conf $BUILDROOT
|
|
||||||
|
|
||||||
echo "- All done. Configure PA xrdp module with PULSE_DIR=$PULSE_DIR"
|
|
||||||
exit 0
|
|
@ -1,6 +1,6 @@
|
|||||||
AM_CFLAGS = -O2 \
|
AM_CFLAGS = -O2 \
|
||||||
-fPIC \
|
-fPIC \
|
||||||
-I $(PULSE_CONFIG_DIR) \
|
-I $(PULSE_DIR) \
|
||||||
-I $(PULSE_DIR)/src \
|
-I $(PULSE_DIR)/src \
|
||||||
$(XRDP_CFLAGS)
|
$(XRDP_CFLAGS)
|
||||||
|
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
/***
|
/**
|
||||||
pulse sink module for xrdp
|
* xrdp: A Remote Desktop Protocol server.
|
||||||
|
* pulse sink
|
||||||
|
*
|
||||||
|
* Copyright (C) Jay Sorg 2013
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
Copyright 2004-2008 Lennart Poettering
|
/*
|
||||||
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
* see pulse-notes.txt
|
||||||
Copyright (C) 2013-2021 Jay Sorg, Neutrino Labs, and all contributors.
|
*/
|
||||||
|
|
||||||
PulseAudio is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Lesser General Public License as published
|
|
||||||
by the Free Software Foundation; either version 2 of the License,
|
|
||||||
or (at your option) any later version.
|
|
||||||
|
|
||||||
PulseAudio is distributed in the hope that it will be useful, but
|
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
|
||||||
along with PulseAudio; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
||||||
USA.
|
|
||||||
***/
|
|
||||||
|
|
||||||
// config.h from pulseaudio sources
|
// config.h from pulseaudio sources
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
@ -59,6 +59,9 @@
|
|||||||
#include <pulsecore/thread-mq.h>
|
#include <pulsecore/thread-mq.h>
|
||||||
#include <pulsecore/rtpoll.h>
|
#include <pulsecore/rtpoll.h>
|
||||||
|
|
||||||
|
#include <xrdp_sockets.h>
|
||||||
|
|
||||||
|
|
||||||
/* defined in pulse/version.h */
|
/* defined in pulse/version.h */
|
||||||
#if PA_PROTOCOL_VERSION > 28
|
#if PA_PROTOCOL_VERSION > 28
|
||||||
/* these used to be defined in pulsecore/macro.h */
|
/* these used to be defined in pulsecore/macro.h */
|
||||||
@ -81,48 +84,16 @@ PA_MODULE_USAGE(
|
|||||||
"format=<sample format> "
|
"format=<sample format> "
|
||||||
"rate=<sample rate> "
|
"rate=<sample rate> "
|
||||||
"channels=<number of channels> "
|
"channels=<number of channels> "
|
||||||
"channel_map=<channel map> "
|
"channel_map=<channel map>");
|
||||||
"description=<description for the sink> "
|
|
||||||
"xrdp_socket_path=<path to XRDP sockets> "
|
|
||||||
"xrdp_pulse_sink_socket=<name of sink socket>");
|
|
||||||
|
|
||||||
#define DEFAULT_SINK_NAME "xrdp-sink"
|
#define DEFAULT_SINK_NAME "xrdp-sink"
|
||||||
#define BLOCK_USEC 30000
|
#define BLOCK_USEC 30000
|
||||||
//#define BLOCK_USEC (PA_USEC_PER_SEC * 2)
|
//#define BLOCK_USEC (PA_USEC_PER_SEC * 2)
|
||||||
#define UNUSED_VAR(x) ((void) (x))
|
|
||||||
|
|
||||||
/* support for the set_state_in_io_thread callback was added in 11.99.1 */
|
|
||||||
#if defined(PA_CHECK_VERSION) && PA_CHECK_VERSION(11, 99, 1)
|
|
||||||
#define USE_SET_STATE_IN_IO_THREAD_CB
|
|
||||||
#else
|
|
||||||
#undef USE_SET_STATE_IN_IO_THREAD_CB
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ** THIS IS A HACK **
|
|
||||||
*
|
|
||||||
* we need to access (struct set_state_data *)->state
|
|
||||||
* from our code, but the struct is currently private to pulsecore/sink.c
|
|
||||||
* The struct was introduced for 11.99.1, and hasn't changed since. Given
|
|
||||||
* the late development status of pulseaudio now (April '25), this is
|
|
||||||
* unlikely to change again */
|
|
||||||
|
|
||||||
#if defined(PA_CHECK_VERSION) && PA_CHECK_VERSION(11, 99, 1)
|
|
||||||
struct set_state_data { /* Copied from pulsecore/sink.c */
|
|
||||||
pa_sink_state_t state;
|
|
||||||
pa_suspend_cause_t suspend_cause;
|
|
||||||
};
|
|
||||||
#define GET_STATE_FROM_SET_STATE_DATA
|
|
||||||
#else
|
|
||||||
#undef GET_STATE_FROM_SET_STATE_DATA
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct userdata {
|
struct userdata {
|
||||||
pa_core *core;
|
pa_core *core;
|
||||||
pa_module *module;
|
pa_module *module;
|
||||||
pa_sink *sink;
|
pa_sink *sink;
|
||||||
pa_device_port *port;
|
|
||||||
pa_card *card;
|
|
||||||
|
|
||||||
pa_thread *thread;
|
pa_thread *thread;
|
||||||
pa_thread_mq thread_mq;
|
pa_thread_mq thread_mq;
|
||||||
@ -134,9 +105,10 @@ struct userdata {
|
|||||||
pa_usec_t last_send_time;
|
pa_usec_t last_send_time;
|
||||||
|
|
||||||
int fd; /* unix domain socket connection to xrdp chansrv */
|
int fd; /* unix domain socket connection to xrdp chansrv */
|
||||||
|
int display_num;
|
||||||
int skip_bytes;
|
int skip_bytes;
|
||||||
|
int got_max_latency;
|
||||||
|
|
||||||
char *sink_socket;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* const valid_modargs[] = {
|
static const char* const valid_modargs[] = {
|
||||||
@ -146,207 +118,54 @@ static const char* const valid_modargs[] = {
|
|||||||
"rate",
|
"rate",
|
||||||
"channels",
|
"channels",
|
||||||
"channel_map",
|
"channel_map",
|
||||||
"xrdp_socket_path",
|
|
||||||
"xrdp_pulse_sink_socket",
|
|
||||||
"description",
|
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static int close_send(struct userdata *u);
|
static int close_send(struct userdata *u);
|
||||||
|
|
||||||
static pa_device_port *xrdp_create_port(struct userdata *u) {
|
|
||||||
pa_device_port_new_data data;
|
|
||||||
pa_device_port *port;
|
|
||||||
|
|
||||||
pa_device_port_new_data_init(&data);
|
|
||||||
|
|
||||||
pa_device_port_new_data_set_name(&data, "xrdp-output");
|
|
||||||
pa_device_port_new_data_set_description(&data, "xrdp output");
|
|
||||||
pa_device_port_new_data_set_direction(&data, PA_DIRECTION_OUTPUT);
|
|
||||||
pa_device_port_new_data_set_available(&data, PA_AVAILABLE_YES);
|
|
||||||
#if defined(PA_CHECK_VERSION) && PA_CHECK_VERSION(14, 0, 0)
|
|
||||||
pa_device_port_new_data_set_type(&data, PA_DEVICE_PORT_TYPE_NETWORK);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
port = pa_device_port_new(u->core, &data, 0);
|
|
||||||
|
|
||||||
pa_device_port_new_data_done(&data);
|
|
||||||
|
|
||||||
if (port == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pa_device_port_ref(port);
|
|
||||||
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
static pa_card_profile *xrdp_create_profile() {
|
|
||||||
pa_card_profile *profile;
|
|
||||||
|
|
||||||
profile = pa_card_profile_new("output:xrdp", "xrdp audio output", 0);
|
|
||||||
profile->priority = 10;
|
|
||||||
profile->n_sinks = 1;
|
|
||||||
profile->n_sources = 0;
|
|
||||||
profile->max_sink_channels = 2;
|
|
||||||
profile->max_source_channels = 0;
|
|
||||||
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
static pa_card *xrdp_create_card(pa_module *m, pa_device_port *port, pa_card_profile *profile) {
|
|
||||||
pa_card_new_data data;
|
|
||||||
pa_card *card;
|
|
||||||
|
|
||||||
pa_card_new_data_init(&data);
|
|
||||||
data.driver = __FILE__;
|
|
||||||
|
|
||||||
pa_card_new_data_set_name(&data, "xrdp.sink");
|
|
||||||
|
|
||||||
pa_hashmap_put(data.ports, port->name, port);
|
|
||||||
pa_hashmap_put(data.profiles, profile->name, profile);
|
|
||||||
|
|
||||||
card = pa_card_new(m->core, &data);
|
|
||||||
|
|
||||||
pa_card_new_data_done(&data);
|
|
||||||
|
|
||||||
if (card == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pa_card_choose_initial_profile(card);
|
|
||||||
|
|
||||||
pa_card_put(card);
|
|
||||||
|
|
||||||
return card;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(PA_CHECK_VERSION) || !PA_CHECK_VERSION(11, 99, 1)
|
|
||||||
/**
|
|
||||||
* Returns a string representation of the sink state
|
|
||||||
*
|
|
||||||
* Later versions of PA provide this function in pulsecore/sink.h
|
|
||||||
*
|
|
||||||
* @param state Sink state
|
|
||||||
* @return string representation of state
|
|
||||||
*/
|
|
||||||
static const char *
|
|
||||||
pa_sink_state_to_string(pa_sink_state_t state)
|
|
||||||
{
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case PA_SINK_INIT:
|
|
||||||
return "INIT";
|
|
||||||
case PA_SINK_RUNNING:
|
|
||||||
return "RUNNING";
|
|
||||||
case PA_SINK_SUSPENDED:
|
|
||||||
return "SUSPENDED";
|
|
||||||
case PA_SINK_IDLE:
|
|
||||||
return "IDLE";
|
|
||||||
case PA_SINK_UNLINKED:
|
|
||||||
return "UNLINKED";
|
|
||||||
}
|
|
||||||
pa_assert_not_reached();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int sink_process_msg(pa_msgobject *o, int code, void *data,
|
static int sink_process_msg(pa_msgobject *o, int code, void *data,
|
||||||
int64_t offset, pa_memchunk *chunk) {
|
int64_t offset, pa_memchunk *chunk) {
|
||||||
|
|
||||||
struct userdata *u = PA_SINK(o)->userdata;
|
struct userdata *u = PA_SINK(o)->userdata;
|
||||||
pa_usec_t now;
|
pa_usec_t now;
|
||||||
long lat;
|
long lat;
|
||||||
pa_sink_state_t sink_state;
|
|
||||||
|
pa_log_debug("sink_process_msg: code %d", code);
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
|
||||||
case PA_SINK_MESSAGE_SET_VOLUME:
|
case PA_SINK_MESSAGE_SET_VOLUME: /* 3 */
|
||||||
pa_log_debug("sink_process_msg: PA_SINK_MESSAGE_SET_VOLUME");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PA_SINK_MESSAGE_SET_MUTE:
|
case PA_SINK_MESSAGE_SET_MUTE: /* 6 */
|
||||||
pa_log_debug("sink_process_msg: PA_SINK_MESSAGE_SET_MUTE");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PA_SINK_MESSAGE_GET_LATENCY:
|
case PA_SINK_MESSAGE_GET_LATENCY: /* 7 */
|
||||||
pa_log_debug("sink_process_msg: PA_SINK_MESSAGE_GET_LATENCY");
|
|
||||||
now = pa_rtclock_now();
|
now = pa_rtclock_now();
|
||||||
lat = u->timestamp > now ? u->timestamp - now : 0ULL;
|
lat = u->timestamp > now ? u->timestamp - now : 0ULL;
|
||||||
pa_log_debug("sink_process_msg: lat %ld", lat);
|
pa_log_debug("sink_process_msg: lat %ld", lat);
|
||||||
*((pa_usec_t*) data) = lat;
|
*((pa_usec_t*) data) = lat;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case PA_SINK_MESSAGE_GET_REQUESTED_LATENCY:
|
case PA_SINK_MESSAGE_GET_REQUESTED_LATENCY: /* 8 */
|
||||||
pa_log_debug("sink_process_msg: PA_SINK_MESSAGE_GET_REQUESTED_LATENCY");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PA_SINK_MESSAGE_SET_STATE:
|
case PA_SINK_MESSAGE_SET_STATE: /* 9 */
|
||||||
#ifdef GET_STATE_FROM_SET_STATE_DATA
|
if (PA_PTR_TO_UINT(data) == PA_SINK_RUNNING) /* 0 */ {
|
||||||
sink_state = ((const struct set_state_data *)data)->state;
|
|
||||||
#else
|
|
||||||
sink_state = PA_PTR_TO_UINT(data);
|
|
||||||
#endif
|
|
||||||
pa_log("sink_process_msg: PA_SINK_MESSAGE_SET_STATE [%s]",
|
|
||||||
pa_sink_state_to_string(sink_state));
|
|
||||||
switch (sink_state)
|
|
||||||
{
|
|
||||||
case PA_SINK_INVALID_STATE:
|
|
||||||
case PA_SINK_INIT:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PA_SINK_RUNNING:
|
|
||||||
pa_log("sink_process_msg: running");
|
pa_log("sink_process_msg: running");
|
||||||
u->timestamp = pa_rtclock_now();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PA_SINK_IDLE:
|
u->timestamp = pa_rtclock_now();
|
||||||
case PA_SINK_SUSPENDED:
|
} else {
|
||||||
case PA_SINK_UNLINKED:
|
|
||||||
pa_log("sink_process_msg: not running");
|
pa_log("sink_process_msg: not running");
|
||||||
close_send(u);
|
close_send(u);
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
pa_assert_not_reached();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
pa_log_debug("sink_process_msg: code %d", code);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pa_sink_process_msg(o, code, data, offset, chunk);
|
return pa_sink_process_msg(o, code, data, offset, chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_SET_STATE_IN_IO_THREAD_CB
|
|
||||||
/* Called from the IO thread. */
|
|
||||||
static int sink_set_state_in_io_thread_cb(pa_sink *s,
|
|
||||||
pa_sink_state_t new_state,
|
|
||||||
pa_suspend_cause_t new_suspend_cause)
|
|
||||||
{
|
|
||||||
struct userdata *u;
|
|
||||||
|
|
||||||
UNUSED_VAR(new_suspend_cause);
|
|
||||||
|
|
||||||
pa_assert(s);
|
|
||||||
pa_assert_se(u = s->userdata);
|
|
||||||
|
|
||||||
if (s->thread_info.state == PA_SINK_SUSPENDED || s->thread_info.state == PA_SINK_INIT)
|
|
||||||
{
|
|
||||||
if (PA_SINK_IS_OPENED(new_state))
|
|
||||||
{
|
|
||||||
pa_log_debug("sink_set_state_in_io_thread_cb: set timestamp");
|
|
||||||
u->timestamp = pa_rtclock_now();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif /* USE_SET_STATE_IN_IO_THREAD_CB */
|
|
||||||
|
|
||||||
static void sink_update_requested_latency_cb(pa_sink *s) {
|
static void sink_update_requested_latency_cb(pa_sink *s) {
|
||||||
struct userdata *u;
|
struct userdata *u;
|
||||||
size_t nbytes;
|
size_t nbytes;
|
||||||
@ -354,11 +173,17 @@ static void sink_update_requested_latency_cb(pa_sink *s) {
|
|||||||
pa_sink_assert_ref(s);
|
pa_sink_assert_ref(s);
|
||||||
pa_assert_se(u = s->userdata);
|
pa_assert_se(u = s->userdata);
|
||||||
|
|
||||||
u->block_usec = pa_sink_get_requested_latency_within_thread(s);
|
u->block_usec = BLOCK_USEC;
|
||||||
|
//u->block_usec = pa_sink_get_requested_latency_within_thread(s);
|
||||||
|
pa_log("1 block_usec %llu", (unsigned long long) u->block_usec);
|
||||||
|
|
||||||
|
u->got_max_latency = 0;
|
||||||
if (u->block_usec == (pa_usec_t) -1) {
|
if (u->block_usec == (pa_usec_t) -1) {
|
||||||
u->block_usec = s->thread_info.max_latency;
|
u->block_usec = s->thread_info.max_latency;
|
||||||
|
pa_log_debug("2 block_usec %llu", (unsigned long long) u->block_usec);
|
||||||
|
u->got_max_latency = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
nbytes = pa_usec_to_bytes(u->block_usec, &s->sample_spec);
|
nbytes = pa_usec_to_bytes(u->block_usec, &s->sample_spec);
|
||||||
pa_sink_set_max_rewind_within_thread(s, nbytes);
|
pa_sink_set_max_rewind_within_thread(s, nbytes);
|
||||||
pa_sink_set_max_request_within_thread(s, nbytes);
|
pa_sink_set_max_request_within_thread(s, nbytes);
|
||||||
@ -370,12 +195,13 @@ static void process_rewind(struct userdata *u, pa_usec_t now) {
|
|||||||
|
|
||||||
pa_assert(u);
|
pa_assert(u);
|
||||||
|
|
||||||
|
/* Figure out how much we shall rewind and reset the counter */
|
||||||
rewind_nbytes = u->sink->thread_info.rewind_nbytes;
|
rewind_nbytes = u->sink->thread_info.rewind_nbytes;
|
||||||
|
u->sink->thread_info.rewind_nbytes = 0;
|
||||||
|
|
||||||
if (!PA_SINK_IS_OPENED(u->sink->thread_info.state) || rewind_nbytes <= 0)
|
pa_assert(rewind_nbytes > 0);
|
||||||
goto do_nothing;
|
pa_log_debug("Requested to rewind %lu bytes.",
|
||||||
|
(unsigned long) rewind_nbytes);
|
||||||
pa_log_debug("Requested to rewind %lu bytes.", (unsigned long) rewind_nbytes);
|
|
||||||
|
|
||||||
if (u->timestamp <= now)
|
if (u->timestamp <= now)
|
||||||
goto do_nothing;
|
goto do_nothing;
|
||||||
@ -391,6 +217,7 @@ static void process_rewind(struct userdata *u, pa_usec_t now) {
|
|||||||
|
|
||||||
pa_sink_process_rewind(u->sink, rewind_nbytes);
|
pa_sink_process_rewind(u->sink, rewind_nbytes);
|
||||||
u->timestamp -= pa_bytes_to_usec(rewind_nbytes, &u->sink->sample_spec);
|
u->timestamp -= pa_bytes_to_usec(rewind_nbytes, &u->sink->sample_spec);
|
||||||
|
u->skip_bytes += rewind_nbytes;
|
||||||
|
|
||||||
pa_log_debug("Rewound %lu bytes.", (unsigned long) rewind_nbytes);
|
pa_log_debug("Rewound %lu bytes.", (unsigned long) rewind_nbytes);
|
||||||
return;
|
return;
|
||||||
@ -405,7 +232,7 @@ struct header {
|
|||||||
int bytes;
|
int bytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int get_display_num_from_display(const char *display_text) {
|
static int get_display_num_from_display(char *display_text) {
|
||||||
int index;
|
int index;
|
||||||
int mode;
|
int mode;
|
||||||
int host_index;
|
int host_index;
|
||||||
@ -469,13 +296,14 @@ static int lsend(int fd, char *data, int bytes) {
|
|||||||
|
|
||||||
static int data_send(struct userdata *u, pa_memchunk *chunk) {
|
static int data_send(struct userdata *u, pa_memchunk *chunk) {
|
||||||
char *data;
|
char *data;
|
||||||
|
char *socket_dir;
|
||||||
int bytes;
|
int bytes;
|
||||||
int sent;
|
int sent;
|
||||||
int fd;
|
int fd;
|
||||||
struct header h;
|
struct header h;
|
||||||
struct sockaddr_un s;
|
struct sockaddr_un s;
|
||||||
|
|
||||||
if (u->fd == -1) {
|
if (u->fd == 0) {
|
||||||
if (u->failed_connect_time != 0) {
|
if (u->failed_connect_time != 0) {
|
||||||
if (pa_rtclock_now() - u->failed_connect_time < 1000000) {
|
if (pa_rtclock_now() - u->failed_connect_time < 1000000) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -484,9 +312,15 @@ static int data_send(struct userdata *u, pa_memchunk *chunk) {
|
|||||||
fd = socket(PF_LOCAL, SOCK_STREAM, 0);
|
fd = socket(PF_LOCAL, SOCK_STREAM, 0);
|
||||||
memset(&s, 0, sizeof(s));
|
memset(&s, 0, sizeof(s));
|
||||||
s.sun_family = AF_UNIX;
|
s.sun_family = AF_UNIX;
|
||||||
pa_strlcpy(s.sun_path, u->sink_socket, sizeof(s.sun_path));
|
bytes = sizeof(s.sun_path) - 1;
|
||||||
|
socket_dir = getenv("XRDP_SOCKET_PATH");
|
||||||
|
if (socket_dir == NULL || socket_dir[0] == '\0')
|
||||||
|
{
|
||||||
|
socket_dir = "/tmp/.xrdp";
|
||||||
|
}
|
||||||
|
snprintf(s.sun_path, bytes, "%s/" CHANSRV_PORT_OUT_BASE_STR,
|
||||||
|
socket_dir, u->display_num);
|
||||||
pa_log_debug("trying to connect to %s", s.sun_path);
|
pa_log_debug("trying to connect to %s", s.sun_path);
|
||||||
|
|
||||||
if (connect(fd, (struct sockaddr *)&s,
|
if (connect(fd, (struct sockaddr *)&s,
|
||||||
sizeof(struct sockaddr_un)) != 0) {
|
sizeof(struct sockaddr_un)) != 0) {
|
||||||
u->failed_connect_time = pa_rtclock_now();
|
u->failed_connect_time = pa_rtclock_now();
|
||||||
@ -502,12 +336,23 @@ static int data_send(struct userdata *u, pa_memchunk *chunk) {
|
|||||||
bytes = chunk->length;
|
bytes = chunk->length;
|
||||||
pa_log_debug("bytes %d", bytes);
|
pa_log_debug("bytes %d", bytes);
|
||||||
|
|
||||||
|
/* from rewind */
|
||||||
|
if (u->skip_bytes > 0) {
|
||||||
|
if (bytes > u->skip_bytes) {
|
||||||
|
bytes -= u->skip_bytes;
|
||||||
|
u->skip_bytes = 0;
|
||||||
|
} else {
|
||||||
|
u->skip_bytes -= bytes;
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
h.code = 0;
|
h.code = 0;
|
||||||
h.bytes = bytes + 8;
|
h.bytes = bytes + 8;
|
||||||
if (lsend(u->fd, (char*)(&h), 8) != 8) {
|
if (lsend(u->fd, (char*)(&h), 8) != 8) {
|
||||||
pa_log("data_send: send failed");
|
pa_log("data_send: send failed");
|
||||||
close(u->fd);
|
close(u->fd);
|
||||||
u->fd = -1;
|
u->fd = 0;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
pa_log_debug("data_send: sent header ok bytes %d", bytes);
|
pa_log_debug("data_send: sent header ok bytes %d", bytes);
|
||||||
@ -521,7 +366,7 @@ static int data_send(struct userdata *u, pa_memchunk *chunk) {
|
|||||||
if (sent != bytes) {
|
if (sent != bytes) {
|
||||||
pa_log("data_send: send failed sent %d bytes %d", sent, bytes);
|
pa_log("data_send: send failed sent %d bytes %d", sent, bytes);
|
||||||
close(u->fd);
|
close(u->fd);
|
||||||
u->fd = -1;
|
u->fd = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,7 +377,7 @@ static int close_send(struct userdata *u) {
|
|||||||
struct header h;
|
struct header h;
|
||||||
|
|
||||||
pa_log("close_send:");
|
pa_log("close_send:");
|
||||||
if (u->fd == -1) {
|
if (u->fd == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
h.code = 1;
|
h.code = 1;
|
||||||
@ -540,7 +385,7 @@ static int close_send(struct userdata *u) {
|
|||||||
if (lsend(u->fd, (char*)(&h), 8) != 8) {
|
if (lsend(u->fd, (char*)(&h), 8) != 8) {
|
||||||
pa_log("close_send: send failed");
|
pa_log("close_send: send failed");
|
||||||
close(u->fd);
|
close(u->fd);
|
||||||
u->fd = -1;
|
u->fd = 0;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
pa_log_debug("close_send: sent header ok");
|
pa_log_debug("close_send: sent header ok");
|
||||||
@ -553,14 +398,15 @@ static void process_render(struct userdata *u, pa_usec_t now) {
|
|||||||
int request_bytes;
|
int request_bytes;
|
||||||
|
|
||||||
pa_assert(u);
|
pa_assert(u);
|
||||||
|
if (u->got_max_latency) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
pa_log_debug("process_render: u->block_usec %llu", (unsigned long long) u->block_usec);
|
pa_log_debug("process_render: u->block_usec %llu", (unsigned long long) u->block_usec);
|
||||||
while (u->timestamp < now + u->block_usec) {
|
while (u->timestamp < now + u->block_usec) {
|
||||||
request_bytes = u->sink->thread_info.max_request;
|
request_bytes = u->sink->thread_info.max_request;
|
||||||
request_bytes = MIN(request_bytes, 16 * 1024);
|
request_bytes = MIN(request_bytes, 16 * 1024);
|
||||||
pa_sink_render(u->sink, request_bytes, &chunk);
|
pa_sink_render(u->sink, request_bytes, &chunk);
|
||||||
if (u->sink->thread_info.state == PA_SINK_RUNNING) {
|
|
||||||
data_send(u, &chunk);
|
data_send(u, &chunk);
|
||||||
}
|
|
||||||
pa_memblock_unref(chunk.memblock);
|
pa_memblock_unref(chunk.memblock);
|
||||||
u->timestamp += pa_bytes_to_usec(chunk.length, &u->sink->sample_spec);
|
u->timestamp += pa_bytes_to_usec(chunk.length, &u->sink->sample_spec);
|
||||||
}
|
}
|
||||||
@ -569,6 +415,8 @@ static void process_render(struct userdata *u, pa_usec_t now) {
|
|||||||
static void thread_func(void *userdata) {
|
static void thread_func(void *userdata) {
|
||||||
|
|
||||||
struct userdata *u = userdata;
|
struct userdata *u = userdata;
|
||||||
|
int ret;
|
||||||
|
pa_usec_t now;
|
||||||
|
|
||||||
pa_assert(u);
|
pa_assert(u);
|
||||||
|
|
||||||
@ -579,26 +427,30 @@ static void thread_func(void *userdata) {
|
|||||||
u->timestamp = pa_rtclock_now();
|
u->timestamp = pa_rtclock_now();
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
pa_usec_t now = 0;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
|
if (u->sink->thread_info.state == PA_SINK_RUNNING) {
|
||||||
|
|
||||||
now = pa_rtclock_now();
|
now = pa_rtclock_now();
|
||||||
}
|
|
||||||
if (PA_UNLIKELY(u->sink->thread_info.rewind_requested)) {
|
if (u->sink->thread_info.rewind_requested) {
|
||||||
|
if (u->sink->thread_info.rewind_nbytes > 0) {
|
||||||
process_rewind(u, now);
|
process_rewind(u, now);
|
||||||
|
} else {
|
||||||
|
pa_sink_process_rewind(u->sink, 0);
|
||||||
}
|
}
|
||||||
/* Render some data and write it to the socket */
|
}
|
||||||
if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
|
|
||||||
if (u->timestamp <= now) {
|
if (u->timestamp <= now) {
|
||||||
|
pa_log_debug("thread_func: calling process_render");
|
||||||
process_render(u, now);
|
process_render(u, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_rtpoll_set_timer_absolute(u->rtpoll, u->timestamp);
|
pa_rtpoll_set_timer_absolute(u->rtpoll, u->timestamp);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
pa_rtpoll_set_timer_disabled(u->rtpoll);
|
pa_rtpoll_set_timer_disabled(u->rtpoll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hmm, nothing to do. Let's sleep */
|
|
||||||
#if defined(PA_CHECK_VERSION) && PA_CHECK_VERSION(6, 0, 0)
|
#if defined(PA_CHECK_VERSION) && PA_CHECK_VERSION(6, 0, 0)
|
||||||
if ((ret = pa_rtpoll_run(u->rtpoll)) < 0) {
|
if ((ret = pa_rtpoll_run(u->rtpoll)) < 0) {
|
||||||
#else
|
#else
|
||||||
@ -611,6 +463,7 @@ static void thread_func(void *userdata) {
|
|||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
/* If this was no regular exit from the loop we have to continue
|
/* If this was no regular exit from the loop we have to continue
|
||||||
* processing messages until we received PA_MESSAGE_SHUTDOWN */
|
* processing messages until we received PA_MESSAGE_SHUTDOWN */
|
||||||
@ -623,39 +476,8 @@ finish:
|
|||||||
pa_log_debug("Thread shutting down");
|
pa_log_debug("Thread shutting down");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_sink_socket(pa_modargs *ma, struct userdata *u) {
|
|
||||||
const char *socket_dir;
|
|
||||||
const char *socket_name;
|
|
||||||
char default_socket_name[64];
|
|
||||||
size_t nbytes;
|
|
||||||
|
|
||||||
socket_dir = pa_modargs_get_value(ma, "xrdp_socket_path",
|
|
||||||
getenv("XRDP_SOCKET_PATH"));
|
|
||||||
if (socket_dir == NULL || socket_dir[0] == '\0') {
|
|
||||||
socket_dir = "/tmp/.xrdp";
|
|
||||||
}
|
|
||||||
|
|
||||||
socket_name = pa_modargs_get_value(ma, "xrdp_pulse_sink_socket",
|
|
||||||
getenv("XRDP_PULSE_SINK_SOCKET"));
|
|
||||||
if (socket_name == NULL || socket_name[0] == '\0')
|
|
||||||
{
|
|
||||||
int display_num = get_display_num_from_display(getenv("DISPLAY"));
|
|
||||||
|
|
||||||
pa_log_debug("Could not obtain sink_socket from environment.");
|
|
||||||
snprintf(default_socket_name, sizeof(default_socket_name),
|
|
||||||
"xrdp_chansrv_audio_out_socket_%d", display_num);
|
|
||||||
socket_name = default_socket_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
nbytes = strlen(socket_dir) + 1 + strlen(socket_name) + 1;
|
|
||||||
u->sink_socket = pa_xmalloc(nbytes);
|
|
||||||
snprintf(u->sink_socket, nbytes, "%s/%s", socket_dir, socket_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int pa__init(pa_module*m) {
|
int pa__init(pa_module*m) {
|
||||||
struct userdata *u = NULL;
|
struct userdata *u = NULL;
|
||||||
pa_device_port *port;
|
|
||||||
pa_card_profile *profile;
|
|
||||||
pa_sample_spec ss;
|
pa_sample_spec ss;
|
||||||
pa_channel_map map;
|
pa_channel_map map;
|
||||||
pa_modargs *ma = NULL;
|
pa_modargs *ma = NULL;
|
||||||
@ -664,17 +486,6 @@ int pa__init(pa_module*m) {
|
|||||||
|
|
||||||
pa_assert(m);
|
pa_assert(m);
|
||||||
|
|
||||||
/* Check the runtime library version matches the build version */
|
|
||||||
if (strcmp(pa_get_library_version(), pa_get_headers_version()) == 0)
|
|
||||||
{
|
|
||||||
pa_log_notice("Build library version %s", pa_get_headers_version());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pa_log_warn("Runtime version '%s' differs from build version '%s'",
|
|
||||||
pa_get_library_version(), pa_get_headers_version());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
|
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
|
||||||
pa_log("Failed to parse module arguments.");
|
pa_log("Failed to parse module arguments.");
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -701,11 +512,8 @@ int pa__init(pa_module*m) {
|
|||||||
pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME));
|
pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME));
|
||||||
pa_sink_new_data_set_sample_spec(&data, &ss);
|
pa_sink_new_data_set_sample_spec(&data, &ss);
|
||||||
pa_sink_new_data_set_channel_map(&data, &map);
|
pa_sink_new_data_set_channel_map(&data, &map);
|
||||||
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, pa_modargs_get_value(ma, "description", "remote audio output"));
|
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, "xrdp sink");
|
||||||
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_CLASS, "sound");
|
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_CLASS, "abstract");
|
||||||
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_FORM_FACTOR, "computer");
|
|
||||||
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_PRODUCT_NAME, "xrdp");
|
|
||||||
|
|
||||||
|
|
||||||
if (pa_modargs_get_proplist(ma, "sink_properties", data.proplist,
|
if (pa_modargs_get_proplist(ma, "sink_properties", data.proplist,
|
||||||
PA_UPDATE_REPLACE) < 0) {
|
PA_UPDATE_REPLACE) < 0) {
|
||||||
@ -713,27 +521,9 @@ int pa__init(pa_module*m) {
|
|||||||
pa_sink_new_data_done(&data);
|
pa_sink_new_data_done(&data);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
port = xrdp_create_port(u);
|
|
||||||
if (port == NULL) {
|
|
||||||
pa_log("Failed to create port object");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile = xrdp_create_profile();
|
|
||||||
|
|
||||||
pa_hashmap_put(port->profiles, profile->name, profile);
|
|
||||||
|
|
||||||
u->card = xrdp_create_card(m, port, profile);
|
|
||||||
if (u->card == NULL) {
|
|
||||||
pa_log("Failed to create card object");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.card = u->card;
|
|
||||||
pa_hashmap_put(data.ports, port->name, port);
|
|
||||||
|
|
||||||
u->sink = pa_sink_new(m->core, &data,
|
u->sink = pa_sink_new(m->core, &data,
|
||||||
PA_SINK_LATENCY | PA_SINK_DYNAMIC_LATENCY | PA_SINK_NETWORK | PA_SINK_HARDWARE);
|
PA_SINK_LATENCY | PA_SINK_DYNAMIC_LATENCY);
|
||||||
pa_sink_new_data_done(&data);
|
pa_sink_new_data_done(&data);
|
||||||
|
|
||||||
if (!u->sink) {
|
if (!u->sink) {
|
||||||
@ -742,9 +532,6 @@ int pa__init(pa_module*m) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
u->sink->parent.process_msg = sink_process_msg;
|
u->sink->parent.process_msg = sink_process_msg;
|
||||||
#ifdef USE_SET_STATE_IN_IO_THREAD_CB
|
|
||||||
u->sink->set_state_in_io_thread = sink_set_state_in_io_thread_cb;
|
|
||||||
#endif
|
|
||||||
u->sink->update_requested_latency = sink_update_requested_latency_cb;
|
u->sink->update_requested_latency = sink_update_requested_latency_cb;
|
||||||
u->sink->userdata = u;
|
u->sink->userdata = u;
|
||||||
|
|
||||||
@ -757,9 +544,7 @@ int pa__init(pa_module*m) {
|
|||||||
pa_sink_set_max_rewind(u->sink, nbytes);
|
pa_sink_set_max_rewind(u->sink, nbytes);
|
||||||
pa_sink_set_max_request(u->sink, nbytes);
|
pa_sink_set_max_request(u->sink, nbytes);
|
||||||
|
|
||||||
set_sink_socket(ma, u);
|
u->display_num = get_display_num_from_display(getenv("DISPLAY"));
|
||||||
|
|
||||||
u->fd = -1;
|
|
||||||
|
|
||||||
#if defined(PA_CHECK_VERSION)
|
#if defined(PA_CHECK_VERSION)
|
||||||
#if PA_CHECK_VERSION(0, 9, 22)
|
#if PA_CHECK_VERSION(0, 9, 22)
|
||||||
@ -774,8 +559,6 @@ int pa__init(pa_module*m) {
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_sink_set_latency_range(u->sink, 0, BLOCK_USEC);
|
|
||||||
|
|
||||||
pa_sink_put(u->sink);
|
pa_sink_put(u->sink);
|
||||||
|
|
||||||
pa_modargs_free(ma);
|
pa_modargs_free(ma);
|
||||||
@ -830,17 +613,5 @@ void pa__done(pa_module*m) {
|
|||||||
pa_rtpoll_free(u->rtpoll);
|
pa_rtpoll_free(u->rtpoll);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u->card)
|
|
||||||
{
|
|
||||||
pa_card_free(u->card);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (u->fd >= 0)
|
|
||||||
{
|
|
||||||
close(u->fd);
|
|
||||||
u->fd = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pa_xfree(u->sink_socket);
|
|
||||||
pa_xfree(u);
|
pa_xfree(u);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
/***
|
/***
|
||||||
pulse source module for xrdp
|
This file is part of PulseAudio.
|
||||||
|
|
||||||
Copyright 2004-2008 Lennart Poettering
|
Copyright 2004-2008 Lennart Poettering
|
||||||
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
Copyright (C) 2013-2021 Jay Sorg, Neutrino Labs, and all contributors.
|
|
||||||
|
|
||||||
PulseAudio is free software; you can redistribute it and/or modify
|
PulseAudio is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published
|
it under the terms of the GNU Lesser General Public License as published
|
||||||
@ -47,6 +46,9 @@
|
|||||||
#include <pulsecore/thread-mq.h>
|
#include <pulsecore/thread-mq.h>
|
||||||
#include <pulsecore/thread.h>
|
#include <pulsecore/thread.h>
|
||||||
|
|
||||||
|
#include <xrdp_sockets.h>
|
||||||
|
|
||||||
|
|
||||||
/* defined in pulse/version.h */
|
/* defined in pulse/version.h */
|
||||||
#if PA_PROTOCOL_VERSION > 28
|
#if PA_PROTOCOL_VERSION > 28
|
||||||
/* these used to be defined in pulsecore/macro.h */
|
/* these used to be defined in pulsecore/macro.h */
|
||||||
@ -69,9 +71,7 @@ PA_MODULE_USAGE(
|
|||||||
"source_name=<name of source> "
|
"source_name=<name of source> "
|
||||||
"channel_map=<channel map> "
|
"channel_map=<channel map> "
|
||||||
"description=<description for the source> "
|
"description=<description for the source> "
|
||||||
"latency_time=<latency time in ms> "
|
"latency_time=<latency time in ms>");
|
||||||
"xrdp_socket_path=<path to XRDP sockets> "
|
|
||||||
"xrdp_pulse_source_socket=<name of source socket>");
|
|
||||||
|
|
||||||
#define DEFAULT_SOURCE_NAME "xrdp-source"
|
#define DEFAULT_SOURCE_NAME "xrdp-source"
|
||||||
#define DEFAULT_LATENCY_TIME 10
|
#define DEFAULT_LATENCY_TIME 10
|
||||||
@ -81,8 +81,6 @@ struct userdata {
|
|||||||
pa_core *core;
|
pa_core *core;
|
||||||
pa_module *module;
|
pa_module *module;
|
||||||
pa_source *source;
|
pa_source *source;
|
||||||
pa_device_port *port;
|
|
||||||
pa_card *card;
|
|
||||||
|
|
||||||
pa_thread *thread;
|
pa_thread *thread;
|
||||||
pa_thread_mq thread_mq;
|
pa_thread_mq thread_mq;
|
||||||
@ -96,7 +94,7 @@ struct userdata {
|
|||||||
|
|
||||||
/* xrdp stuff */
|
/* xrdp stuff */
|
||||||
int fd; /* UDS connection to xrdp chansrv */
|
int fd; /* UDS connection to xrdp chansrv */
|
||||||
char *source_socket;
|
int display_num; /* X display number */
|
||||||
int want_src_data;
|
int want_src_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -108,81 +106,10 @@ static const char* const valid_modargs[] = {
|
|||||||
"channel_map",
|
"channel_map",
|
||||||
"description",
|
"description",
|
||||||
"latency_time",
|
"latency_time",
|
||||||
"xrdp_socket_path",
|
|
||||||
"xrdp_pulse_source_socket",
|
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static pa_device_port *xrdp_create_port(struct userdata *u) {
|
static int get_display_num_from_display(char *display_text) ;
|
||||||
pa_device_port_new_data data;
|
|
||||||
pa_device_port *port;
|
|
||||||
|
|
||||||
pa_device_port_new_data_init(&data);
|
|
||||||
|
|
||||||
pa_device_port_new_data_set_name(&data, "xrdp-input");
|
|
||||||
pa_device_port_new_data_set_description(&data, "xrdp input");
|
|
||||||
pa_device_port_new_data_set_direction(&data, PA_DIRECTION_INPUT);
|
|
||||||
pa_device_port_new_data_set_available(&data, PA_AVAILABLE_YES);
|
|
||||||
#if defined(PA_CHECK_VERSION) && PA_CHECK_VERSION(14, 0, 0)
|
|
||||||
pa_device_port_new_data_set_type(&data, PA_DEVICE_PORT_TYPE_NETWORK);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
port = pa_device_port_new(u->core, &data, 0);
|
|
||||||
|
|
||||||
pa_device_port_new_data_done(&data);
|
|
||||||
|
|
||||||
if (port == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pa_device_port_ref(port);
|
|
||||||
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
static pa_card_profile *xrdp_create_profile() {
|
|
||||||
pa_card_profile *profile;
|
|
||||||
|
|
||||||
profile = pa_card_profile_new("input:xrdp", "xrdp audio input", 0);
|
|
||||||
profile->priority = 10;
|
|
||||||
profile->n_sinks = 0;
|
|
||||||
profile->n_sources = 1;
|
|
||||||
profile->max_sink_channels = 0;
|
|
||||||
profile->max_source_channels = 2;
|
|
||||||
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
static pa_card *xrdp_create_card(pa_module *m, pa_device_port *port, pa_card_profile *profile) {
|
|
||||||
pa_card_new_data data;
|
|
||||||
pa_card *card;
|
|
||||||
|
|
||||||
pa_card_new_data_init(&data);
|
|
||||||
data.driver = __FILE__;
|
|
||||||
|
|
||||||
pa_card_new_data_set_name(&data, "xrdp.source");
|
|
||||||
|
|
||||||
pa_hashmap_put(data.ports, port->name, port);
|
|
||||||
pa_hashmap_put(data.profiles, profile->name, profile);
|
|
||||||
|
|
||||||
card = pa_card_new(m->core, &data);
|
|
||||||
|
|
||||||
pa_card_new_data_done(&data);
|
|
||||||
|
|
||||||
if (card == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pa_card_choose_initial_profile(card);
|
|
||||||
|
|
||||||
pa_card_put(card);
|
|
||||||
|
|
||||||
return card;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_display_num_from_display(const char *display_text) ;
|
|
||||||
|
|
||||||
static int source_process_msg(pa_msgobject *o, int code, void *data,
|
static int source_process_msg(pa_msgobject *o, int code, void *data,
|
||||||
int64_t offset, pa_memchunk *chunk) {
|
int64_t offset, pa_memchunk *chunk) {
|
||||||
@ -253,15 +180,23 @@ static int data_get(struct userdata *u, pa_memchunk *chunk) {
|
|||||||
int read_bytes;
|
int read_bytes;
|
||||||
struct sockaddr_un s;
|
struct sockaddr_un s;
|
||||||
char *data;
|
char *data;
|
||||||
|
char *socket_dir;
|
||||||
char buf[11];
|
char buf[11];
|
||||||
unsigned char ubuf[10];
|
unsigned char ubuf[10];
|
||||||
|
|
||||||
if (u->fd == -1) {
|
if (u->fd == 0) {
|
||||||
/* connect to xrdp unix domain socket */
|
/* connect to xrdp unix domain socket */
|
||||||
fd = socket(PF_LOCAL, SOCK_STREAM, 0);
|
fd = socket(PF_LOCAL, SOCK_STREAM, 0);
|
||||||
memset(&s, 0, sizeof(s));
|
memset(&s, 0, sizeof(s));
|
||||||
s.sun_family = AF_UNIX;
|
s.sun_family = AF_UNIX;
|
||||||
pa_strlcpy(s.sun_path, u->source_socket, sizeof(s.sun_path));
|
bytes = sizeof(s.sun_path) - 1;
|
||||||
|
socket_dir = getenv("XRDP_SOCKET_PATH");
|
||||||
|
if (socket_dir == NULL || socket_dir[0] == '\0')
|
||||||
|
{
|
||||||
|
socket_dir = "/tmp/.xrdp";
|
||||||
|
}
|
||||||
|
snprintf(s.sun_path, bytes, "%s/" CHANSRV_PORT_IN_BASE_STR,
|
||||||
|
socket_dir, u->display_num);
|
||||||
pa_log_debug("Trying to connect to %s", s.sun_path);
|
pa_log_debug("Trying to connect to %s", s.sun_path);
|
||||||
|
|
||||||
if (connect(fd, (struct sockaddr *) &s, sizeof(struct sockaddr_un)) != 0) {
|
if (connect(fd, (struct sockaddr *) &s, sizeof(struct sockaddr_un)) != 0) {
|
||||||
@ -275,6 +210,8 @@ static int data_get(struct userdata *u, pa_memchunk *chunk) {
|
|||||||
u->fd = fd;
|
u->fd = fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data = (char *) pa_memblock_acquire(chunk->memblock);
|
||||||
|
|
||||||
if (!u->want_src_data) {
|
if (!u->want_src_data) {
|
||||||
char buf[12];
|
char buf[12];
|
||||||
|
|
||||||
@ -292,7 +229,8 @@ static int data_get(struct userdata *u, pa_memchunk *chunk) {
|
|||||||
|
|
||||||
if (lsend(u->fd, buf, 11) != 11) {
|
if (lsend(u->fd, buf, 11) != 11) {
|
||||||
close(u->fd);
|
close(u->fd);
|
||||||
u->fd = -1;
|
u->fd = 0;
|
||||||
|
pa_memblock_release(chunk->memblock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
u->want_src_data = 1;
|
u->want_src_data = 1;
|
||||||
@ -314,7 +252,8 @@ static int data_get(struct userdata *u, pa_memchunk *chunk) {
|
|||||||
|
|
||||||
if (lsend(u->fd, buf, 11) != 11) {
|
if (lsend(u->fd, buf, 11) != 11) {
|
||||||
close(u->fd);
|
close(u->fd);
|
||||||
u->fd = -1;
|
u->fd = 0;
|
||||||
|
pa_memblock_release(chunk->memblock);
|
||||||
u->want_src_data = 0;
|
u->want_src_data = 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -322,23 +261,15 @@ static int data_get(struct userdata *u, pa_memchunk *chunk) {
|
|||||||
/* read length of data available */
|
/* read length of data available */
|
||||||
if (lrecv(u->fd, (char *) ubuf, 2) != 2) {
|
if (lrecv(u->fd, (char *) ubuf, 2) != 2) {
|
||||||
close(u->fd);
|
close(u->fd);
|
||||||
u->fd = -1;
|
u->fd = 0;
|
||||||
|
pa_memblock_release(chunk->memblock);
|
||||||
u->want_src_data = 0;
|
u->want_src_data = 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
bytes = ((ubuf[1] << 8) & 0xff00) | (ubuf[0] & 0xff);
|
bytes = ((ubuf[1] << 8) & 0xff00) | (ubuf[0] & 0xff);
|
||||||
|
|
||||||
if (bytes == 0) {
|
if (bytes == 0) {
|
||||||
return 0;
|
pa_memblock_release(chunk->memblock);
|
||||||
}
|
|
||||||
|
|
||||||
chunk->memblock = pa_memblock_new(u->core->mempool, bytes);
|
|
||||||
if (chunk->memblock == NULL) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = (char *) pa_memblock_acquire(chunk->memblock);
|
|
||||||
if (data == NULL) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,12 +277,11 @@ static int data_get(struct userdata *u, pa_memchunk *chunk) {
|
|||||||
read_bytes = lrecv(u->fd, data, bytes);
|
read_bytes = lrecv(u->fd, data, bytes);
|
||||||
if (read_bytes != bytes) {
|
if (read_bytes != bytes) {
|
||||||
close(u->fd);
|
close(u->fd);
|
||||||
u->fd = -1;
|
u->fd = 0;
|
||||||
pa_memblock_release(chunk->memblock);
|
pa_memblock_release(chunk->memblock);
|
||||||
u->want_src_data = 0;
|
u->want_src_data = 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_memblock_release(chunk->memblock);
|
pa_memblock_release(chunk->memblock);
|
||||||
|
|
||||||
return read_bytes;
|
return read_bytes;
|
||||||
@ -368,26 +298,28 @@ static void thread_func(void *userdata) {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
/* Generate some null data */
|
||||||
if (u->source->thread_info.state == PA_SOURCE_RUNNING) {
|
if (u->source->thread_info.state == PA_SOURCE_RUNNING) {
|
||||||
pa_usec_t now;
|
pa_usec_t now;
|
||||||
pa_memchunk chunk;
|
pa_memchunk chunk;
|
||||||
|
|
||||||
now = pa_rtclock_now();
|
now = pa_rtclock_now();
|
||||||
|
|
||||||
memset(&chunk, 0, sizeof(chunk));
|
|
||||||
if ((chunk.length = pa_usec_to_bytes(now - u->timestamp, &u->source->sample_spec)) > 0) {
|
if ((chunk.length = pa_usec_to_bytes(now - u->timestamp, &u->source->sample_spec)) > 0) {
|
||||||
chunk.length *= 4;
|
chunk.length *= 4;
|
||||||
|
chunk.memblock = pa_memblock_new(u->core->mempool, chunk.length);
|
||||||
|
chunk.index = 0;
|
||||||
bytes = data_get(u, &chunk);
|
bytes = data_get(u, &chunk);
|
||||||
if (bytes > 0) {
|
if (bytes > 0)
|
||||||
|
{
|
||||||
chunk.length = bytes;
|
chunk.length = bytes;
|
||||||
pa_source_post(u->source, &chunk);
|
pa_source_post(u->source, &chunk);
|
||||||
|
}
|
||||||
|
pa_memblock_unref(chunk.memblock);
|
||||||
u->timestamp = now;
|
u->timestamp = now;
|
||||||
}
|
}
|
||||||
if (chunk.memblock) {
|
|
||||||
pa_memblock_unref(chunk.memblock);
|
pa_rtpoll_set_timer_absolute(u->rtpoll, u->timestamp + u->latency_time * PA_USEC_PER_MSEC);
|
||||||
}
|
|
||||||
}
|
|
||||||
pa_rtpoll_set_timer_absolute(u->rtpoll, now + u->latency_time * PA_USEC_PER_MSEC);
|
|
||||||
} else {
|
} else {
|
||||||
if (u->want_src_data)
|
if (u->want_src_data)
|
||||||
{
|
{
|
||||||
@ -408,7 +340,7 @@ static void thread_func(void *userdata) {
|
|||||||
|
|
||||||
if (lsend(u->fd, buf, 11) != 11) {
|
if (lsend(u->fd, buf, 11) != 11) {
|
||||||
close(u->fd);
|
close(u->fd);
|
||||||
u->fd = -1;
|
u->fd = 0;
|
||||||
}
|
}
|
||||||
u->want_src_data = 0;
|
u->want_src_data = 0;
|
||||||
pa_log_debug("###### stopped recording");
|
pa_log_debug("###### stopped recording");
|
||||||
@ -439,40 +371,8 @@ finish:
|
|||||||
pa_log_debug("###### thread shutting down");
|
pa_log_debug("###### thread shutting down");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_source_socket(pa_modargs *ma, struct userdata *u) {
|
|
||||||
const char *socket_dir;
|
|
||||||
const char *socket_name;
|
|
||||||
char default_socket_name[64];
|
|
||||||
size_t nbytes;
|
|
||||||
|
|
||||||
|
|
||||||
socket_dir = pa_modargs_get_value(ma, "xrdp_socket_path",
|
|
||||||
getenv("XRDP_SOCKET_PATH"));
|
|
||||||
if (socket_dir == NULL || socket_dir[0] == '\0') {
|
|
||||||
socket_dir = "/tmp/.xrdp";
|
|
||||||
}
|
|
||||||
|
|
||||||
socket_name = pa_modargs_get_value(ma, "xrdp_pulse_source_socket",
|
|
||||||
getenv("XRDP_PULSE_SOURCE_SOCKET"));
|
|
||||||
if (socket_name == NULL || socket_name[0] == '\0')
|
|
||||||
{
|
|
||||||
int display_num = get_display_num_from_display(getenv("DISPLAY"));
|
|
||||||
|
|
||||||
pa_log_debug("Could not obtain source_socket from environment.");
|
|
||||||
snprintf(default_socket_name, sizeof(default_socket_name),
|
|
||||||
"xrdp_chansrv_audio_out_socket_%d", display_num);
|
|
||||||
socket_name = default_socket_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
nbytes = strlen(socket_dir) + 1 + strlen(socket_name) + 1;
|
|
||||||
u->source_socket = pa_xmalloc(nbytes);
|
|
||||||
snprintf(u->source_socket, nbytes, "%s/%s", socket_dir, socket_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int pa__init(pa_module *m) {
|
int pa__init(pa_module *m) {
|
||||||
struct userdata *u = NULL;
|
struct userdata *u = NULL;
|
||||||
pa_device_port *port;
|
|
||||||
pa_card_profile *profile;
|
|
||||||
pa_sample_spec ss;
|
pa_sample_spec ss;
|
||||||
pa_channel_map map;
|
pa_channel_map map;
|
||||||
pa_modargs *ma = NULL;
|
pa_modargs *ma = NULL;
|
||||||
@ -481,21 +381,6 @@ int pa__init(pa_module *m) {
|
|||||||
|
|
||||||
pa_assert(m);
|
pa_assert(m);
|
||||||
|
|
||||||
/* Check the runtime library version matches the build version */
|
|
||||||
if (strcmp(pa_get_library_version(), pa_get_headers_version()) == 0)
|
|
||||||
{
|
|
||||||
pa_log_notice("Build library version %s", pa_get_headers_version());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pa_log_warn("Runtime version '%s' differs from build version '%s'",
|
|
||||||
pa_get_library_version(), pa_get_headers_version());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
|
|
||||||
pa_log("Failed to parse module arguments.");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
|
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
|
||||||
pa_log("Failed to parse module arguments.");
|
pa_log("Failed to parse module arguments.");
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -527,32 +412,10 @@ int pa__init(pa_module *m) {
|
|||||||
pa_source_new_data_set_name(&data, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME));
|
pa_source_new_data_set_name(&data, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME));
|
||||||
pa_source_new_data_set_sample_spec(&data, &ss);
|
pa_source_new_data_set_sample_spec(&data, &ss);
|
||||||
pa_source_new_data_set_channel_map(&data, &map);
|
pa_source_new_data_set_channel_map(&data, &map);
|
||||||
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, pa_modargs_get_value(ma, "description", "remote audio input"));
|
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, pa_modargs_get_value(ma, "description", "xrdp source"));
|
||||||
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_CLASS, "sound");
|
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_CLASS, "abstract");
|
||||||
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_FORM_FACTOR, "microphone");
|
|
||||||
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_PRODUCT_NAME, "xrdp");
|
|
||||||
|
|
||||||
port = xrdp_create_port(u);
|
u->source = pa_source_new(m->core, &data, PA_SOURCE_LATENCY | PA_SOURCE_DYNAMIC_LATENCY);
|
||||||
if (port == NULL) {
|
|
||||||
pa_log("Failed to create port object");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
profile = xrdp_create_profile();
|
|
||||||
|
|
||||||
pa_hashmap_put(port->profiles, profile->name, profile);
|
|
||||||
|
|
||||||
u->card = xrdp_create_card(m, port, profile);
|
|
||||||
if (u->card == NULL) {
|
|
||||||
pa_log("Failed to create card object");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.card = u->card;
|
|
||||||
pa_hashmap_put(data.ports, port->name, port);
|
|
||||||
|
|
||||||
u->source = pa_source_new(m->core, &data, PA_SOURCE_LATENCY |
|
|
||||||
PA_SOURCE_DYNAMIC_LATENCY | PA_SOURCE_NETWORK | PA_SOURCE_HARDWARE);
|
|
||||||
pa_source_new_data_done(&data);
|
pa_source_new_data_done(&data);
|
||||||
|
|
||||||
if (!u->source) {
|
if (!u->source) {
|
||||||
@ -580,10 +443,6 @@ int pa__init(pa_module *m) {
|
|||||||
u->source->thread_info.max_rewind =
|
u->source->thread_info.max_rewind =
|
||||||
pa_usec_to_bytes(u->block_usec, &u->source->sample_spec);
|
pa_usec_to_bytes(u->block_usec, &u->source->sample_spec);
|
||||||
|
|
||||||
set_source_socket(ma, u);
|
|
||||||
|
|
||||||
u->fd = -1;
|
|
||||||
|
|
||||||
#if defined(PA_CHECK_VERSION)
|
#if defined(PA_CHECK_VERSION)
|
||||||
#if PA_CHECK_VERSION(0, 9, 22)
|
#if PA_CHECK_VERSION(0, 9, 22)
|
||||||
if (!(u->thread = pa_thread_new("xrdp-source", thread_func, u))) {
|
if (!(u->thread = pa_thread_new("xrdp-source", thread_func, u))) {
|
||||||
@ -591,7 +450,7 @@ int pa__init(pa_module *m) {
|
|||||||
if (!(u->thread = pa_thread_new(thread_func, u))) {
|
if (!(u->thread = pa_thread_new(thread_func, u))) {
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
if (!(u->thread = pa_thread_new(thread_func, u))) {
|
if (!(u->thread = pa_thread_new(thread_func, u)))
|
||||||
#endif
|
#endif
|
||||||
pa_log("Failed to create thread.");
|
pa_log("Failed to create thread.");
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -601,6 +460,8 @@ int pa__init(pa_module *m) {
|
|||||||
|
|
||||||
pa_modargs_free(ma);
|
pa_modargs_free(ma);
|
||||||
|
|
||||||
|
u->display_num = get_display_num_from_display(getenv("DISPLAY"));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
@ -623,7 +484,6 @@ void pa__done(pa_module*m) {
|
|||||||
if (u->source)
|
if (u->source)
|
||||||
pa_source_unlink(u->source);
|
pa_source_unlink(u->source);
|
||||||
|
|
||||||
|
|
||||||
if (u->thread) {
|
if (u->thread) {
|
||||||
pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL);
|
pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL);
|
||||||
pa_thread_free(u->thread);
|
pa_thread_free(u->thread);
|
||||||
@ -631,25 +491,16 @@ void pa__done(pa_module*m) {
|
|||||||
|
|
||||||
pa_thread_mq_done(&u->thread_mq);
|
pa_thread_mq_done(&u->thread_mq);
|
||||||
|
|
||||||
|
if (u->source)
|
||||||
|
pa_source_unref(u->source);
|
||||||
|
|
||||||
if (u->rtpoll)
|
if (u->rtpoll)
|
||||||
pa_rtpoll_free(u->rtpoll);
|
pa_rtpoll_free(u->rtpoll);
|
||||||
|
|
||||||
if (u->fd >= 0)
|
|
||||||
{
|
|
||||||
close(u->fd);
|
|
||||||
u->fd = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (u->card)
|
|
||||||
{
|
|
||||||
pa_card_free(u->card);
|
|
||||||
}
|
|
||||||
|
|
||||||
pa_xfree(u->source_socket);
|
|
||||||
pa_xfree(u);
|
pa_xfree(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_display_num_from_display(const char *display_text) {
|
static int get_display_num_from_display(char *display_text) {
|
||||||
int index;
|
int index;
|
||||||
int mode;
|
int mode;
|
||||||
int host_index;
|
int host_index;
|
||||||
|
Loading…
Reference in New Issue
Block a user