Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

452 Commits   2 Branches   1 Tag
Index: Makefile
===================================================================
--- Makefile	(nonexistent)
+++ Makefile	(revision 5)
@@ -0,0 +1,64 @@
+
+COMPONENT_TARGETS = $(HARDWARE_NOARCH)
+
+
+include ../../../../build-system/constants.mk
+
+
+url         = $(DOWNLOAD_SERVER)/sources/packages/m/pulseaudio
+
+versions    = 16.1
+pkgname     = pulseaudio
+suffix      = tar.xz
+
+tarballs    = $(addsuffix .$(suffix), $(addprefix $(pkgname)-, $(versions)))
+sha1s       = $(addsuffix .sha1sum, $(tarballs))
+
+patches     = $(CURDIR)/patches/pulseaudio-16.1-autospawn-for-root.patch
+patches    += $(CURDIR)/patches/pulseaudio-16.1-autostart.patch
+patches    += $(CURDIR)/patches/pulseaudio-16.1-no-root-warn.patch
+patches    += $(CURDIR)/patches/pulseaudio-16.1-posix-completion.patch
+patches    += $(CURDIR)/patches/pulseaudio-16.1-soxr-dependency.patch
+
+.NOTPARALLEL: $(patches)
+
+
+BUILD_TARGETS = $(tarballs) $(sha1s) $(patches)
+
+
+include ../../../../build-system/core.mk
+
+
+.PHONY: download_clean
+
+
+$(tarballs):
+	@echo -e "\n======= Downloading source tarballs =======" ; \
+	 for tarball in $(tarballs) ; do \
+	   echo "$(url)/$$tarball" | xargs -n 1 -P 100 wget $(WGET_OPTIONS) - & \
+	 done ; wait
+
+$(sha1s): $(tarballs)
+	@for sha in $@ ; do \
+	   echo -e "\n======= Downloading '$$sha' signature =======\n" ; \
+	   echo "$(url)/$$sha" | xargs -n 1 -P 100 wget $(WGET_OPTIONS) - & wait %1 ; \
+	   touch $$sha ; \
+	   echo -e "\n======= Check the '$$sha' sha1sum =======\n" ; \
+	   sha1sum --check $$sha ; ret="$$?" ; \
+	   if [ "$$ret" == "1" ]; then \
+	     echo -e "\n======= ERROR: Bad '$$sha' sha1sum =======\n" ; \
+	     exit 1 ; \
+	   fi ; \
+	 done
+
+$(patches): $(sha1s)
+	@echo -e "\n======= Create Patches =======\n" ; \
+	 ( cd create-16.1-autospawn-for-root-patch ; ./create.patch.sh ) ; \
+	 ( cd create-16.1-autostart-patch          ; ./create.patch.sh ) ; \
+	 ( cd create-16.1-no-root-warn-patch       ; ./create.patch.sh ) ; \
+	 ( cd create-16.1-posix-completion-patch   ; ./create.patch.sh ) ; \
+	 ( cd create-16.1-soxr-dependency-patch    ; ./create.patch.sh ) ; \
+	 echo -e "\n"
+
+download_clean:
+	@rm -f $(tarballs) $(sha1s) $(patches)
Index: create-16.1-autospawn-for-root-patch/create.patch.sh
===================================================================
--- create-16.1-autospawn-for-root-patch/create.patch.sh	(nonexistent)
+++ create-16.1-autospawn-for-root-patch/create.patch.sh	(revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=16.1
+
+tar --files-from=file.list -xJvf ../pulseaudio-$VERSION.tar.xz
+mv pulseaudio-$VERSION pulseaudio-$VERSION-orig
+
+cp -rf ./pulseaudio-$VERSION-new ./pulseaudio-$VERSION
+
+diff --unified -Nr  pulseaudio-$VERSION-orig  pulseaudio-$VERSION > pulseaudio-$VERSION-autospawn-for-root.patch
+
+mv pulseaudio-$VERSION-autospawn-for-root.patch ../patches
+
+rm -rf ./pulseaudio-$VERSION
+rm -rf ./pulseaudio-$VERSION-orig

Property changes on: create-16.1-autospawn-for-root-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-16.1-autospawn-for-root-patch/file.list
===================================================================
--- create-16.1-autospawn-for-root-patch/file.list	(nonexistent)
+++ create-16.1-autospawn-for-root-patch/file.list	(revision 5)
@@ -0,0 +1,5 @@
+pulseaudio-16.1/man/pulse-client.conf.5.xml.in
+pulseaudio-16.1/src/pulse/client-conf.c
+pulseaudio-16.1/src/pulse/client-conf.h
+pulseaudio-16.1/src/pulse/client.conf.in
+pulseaudio-16.1/src/pulse/context.c
Index: create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/man/pulse-client.conf.5.xml.in
===================================================================
--- create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/man/pulse-client.conf.5.xml.in	(nonexistent)
+++ create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/man/pulse-client.conf.5.xml.in	(revision 5)
@@ -0,0 +1,171 @@
+<?xml version="1.0"?><!--*-nxml-*-->
+<!DOCTYPE manpage SYSTEM "xmltoman.dtd">
+<?xml-stylesheet type="text/xsl" href="xmltoman.xsl" ?>
+
+<!--
+This file is part of PulseAudio.
+
+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.1 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 Lesser General
+Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
+-->
+
+<manpage name="pulse-client.conf" section="5" desc="PulseAudio client configuration file">
+
+  <synopsis>
+    <p><file>~/.config/pulse/client.conf</file></p>
+    <p><file>~/.config/pulse/client.conf.d/*.conf</file></p>
+    <p><file>@PA_DEFAULT_CONFIG_DIR@/client.conf</file></p>
+    <p><file>@PA_DEFAULT_CONFIG_DIR@/client.conf.d/*.conf</file></p>
+  </synopsis>
+
+  <description>
+    <p>The PulseAudio client library reads configuration directives from
+    a configuration file on startup. If the per-user file
+    <file>~/.config/pulse/client.conf</file> exists, it is used, otherwise the
+    system configuration file <file>@PA_DEFAULT_CONFIG_DIR@/client.conf</file>
+    is used. In addition to those main files, configuration directives can also
+    be put in files under directories
+    <file>~/.config/pulse/client.conf.d/</file> and
+    <file>@PA_DEFAULT_CONFIG_DIR@/client.conf.d/</file>. Those files have to
+    have the .conf file name extension, but otherwise the file names can be
+    chosen freely. The files under client.conf.d are processed in alphabetical
+    order. In case the same option is set in multiple files, the last file to
+    set an option overrides earlier files. The main client.conf file is
+    processed first, so options set in files under client.conf.d override the
+    main file.</p>
+
+    <p>The configuration file is a simple collection of variable
+    declarations. If the configuration file parser encounters either ;
+    or # it ignores the rest of the line until its end.</p>
+
+    <p>For the settings that take a boolean argument the values
+    <opt>true</opt>, <opt>yes</opt>, <opt>on</opt> and <opt>1</opt>
+    are equivalent, resp. <opt>false</opt>, <opt>no</opt>,
+    <opt>off</opt>, <opt>0</opt>.</p>
+
+  </description>
+
+  <section name="Directives">
+
+    <option>
+      <p><opt>default-sink=</opt> The default sink to connect to. If
+      specified overwrites the setting in the daemon. The environment
+      variable <opt>$PULSE_SINK</opt> however takes precedence.</p>
+    </option>
+
+    <option>
+      <p><opt>default-source=</opt> The default source to connect
+      to. If specified overwrites the setting in the daemon. The
+      environment variable <opt>$PULSE_SOURCE</opt> however takes
+      precedence.</p>
+    </option>
+
+    <option>
+      <p><opt>default-server=</opt> The default server to connect
+      to. The environment variable <opt>$PULSE_SERVER</opt> takes
+      precedence.</p>
+    </option>
+
+    <option>
+      <p><opt>autospawn=</opt> Autospawn a PulseAudio daemon when needed. Takes
+      a boolean value, defaults to <opt>yes</opt>. Note that setting this to
+      "no" doesn't disable the systemd service. The autospawn option is only
+      meant to be used on systems without systemd. If you use systemd to start
+      PulseAudio, use "systemctl --user stop pulseaudio.service
+      pulseaudio.socket" to stop the daemon temporarily, or "systemctl --user
+      mask pulseaudio.service pulseaudio.socket" to permanently disable the
+      units (the "disable" command of systemctl probably won't work, because
+      the pulseaudio.socket unit is often installed to
+      /usr/lib/systemd/user/sockets.target.wants/, which makes it impossible to
+      disable the unit with the "disable" command).</p>
+    </option>
+
+    <option>
+      <p><opt>allow-autospawn-for-root=</opt> Allow autospawning also for root.
+      Takes a boolean value, defaults to <opt>no</opt>. If the <opt>autospawn
+      </opt> option is disabled, this option has no effect.</p>
+    </option>
+
+    <option>
+      <p><opt>daemon-binary=</opt> Path to the PulseAudio daemon to
+      run when autospawning. Defaults to a path configured at compile
+      time.</p>
+    </option>
+
+    <option>
+      <p><opt>extra-arguments=</opt> Extra arguments to pass to the
+      PulseAudio daemon when autospawning. Defaults to
+      <opt>--log-target=syslog</opt>
+      </p>
+    </option>
+
+    <option>
+      <p><opt>cookie-file=</opt> Specify the path to the PulseAudio
+      authentication cookie. Defaults to
+      <file>~/.config/pulse/cookie</file>.</p>
+    </option>
+
+    <option>
+      <p><opt>enable-shm=</opt> Enable data transfer via POSIX
+      or memfd shared memory. Takes a boolean argument, defaults to
+      <opt>yes</opt>. If set to <opt>no</opt>, communication with
+      the server will be exclusively done through data-copy over
+      sockets.</p>
+    </option>
+
+    <option>
+      <p><opt>enable-memfd=</opt>. Enable data transfer via memfd
+      shared memory. Takes a boolean argument, defaults to
+      <opt>yes</opt>.</p>
+    </option>
+
+    <option>
+      <p><opt>shm-size-bytes=</opt> Sets the shared memory segment
+      size for clients, in bytes. If left unspecified or is set to 0
+      it will default to some system-specific default, usually 64
+      MiB. Please note that usually there is no need to change this
+      value, unless you are running an OS kernel that does not do
+      memory overcommit.</p>
+    </option>
+
+    <option>
+      <p><opt>auto-connect-localhost=</opt> Automatically try to
+      connect to localhost via IP. Enabling this is a potential
+      security hole since connections are only authenticated one-way
+      and a rogue server might hence fool a client into sending it its
+      private (e.g. VoIP call) data. This was enabled by default on
+      PulseAudio version 0.9.21 and older. Defaults to
+      <opt>no</opt>.</p>
+    </option>
+
+    <option>
+      <p><opt>auto-connect-display=</opt> Automatically try to connect
+      to the host X11's $DISPLAY variable is set to. The same security
+      issues apply as to <opt>auto-connect-localhost=</opt>. Defaults
+      to <opt>no</opt>.</p>
+    </option>
+
+  </section>
+
+  <section name="Authors">
+    <p>The PulseAudio Developers &lt;@PACKAGE_BUGREPORT@&gt;;
+    PulseAudio is available from <url href="@PACKAGE_URL@"/></p>
+  </section>
+
+  <section name="See also">
+    <p>
+      <manref name="pulse-daemon.conf" section="5"/>, <manref name="pulseaudio" section="1"/>
+    </p>
+  </section>
+
+</manpage>
Index: create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/man
===================================================================
--- create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/man	(nonexistent)
+++ create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/man	(revision 5)

Property changes on: create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/man
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse/client-conf.c
===================================================================
--- create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse/client-conf.c	(nonexistent)
+++ create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse/client-conf.c	(revision 5)
@@ -0,0 +1,241 @@
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2004-2006 Lennart Poettering
+  Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
+
+  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.1 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, see <http://www.gnu.org/licenses/>.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <pulse/xmalloc.h>
+
+#include <pulsecore/i18n.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/core-error.h>
+#include <pulsecore/log.h>
+#include <pulsecore/conf-parser.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/authkey.h>
+
+#include "client-conf.h"
+
+#ifdef HAVE_X11
+#include <pulse/client-conf-x11.h>
+#endif
+
+#define DEFAULT_CLIENT_CONFIG_FILE PA_DEFAULT_CONFIG_DIR PA_PATH_SEP "client.conf"
+#define DEFAULT_CLIENT_CONFIG_FILE_USER "client.conf"
+
+#define ENV_CLIENT_CONFIG_FILE "PULSE_CLIENTCONFIG"
+#define ENV_DEFAULT_SINK "PULSE_SINK"
+#define ENV_DEFAULT_SOURCE "PULSE_SOURCE"
+#define ENV_DEFAULT_SERVER "PULSE_SERVER"
+#define ENV_DAEMON_BINARY "PULSE_BINARY"
+#define ENV_COOKIE_FILE "PULSE_COOKIE"
+
+static const pa_client_conf default_conf = {
+    .daemon_binary = NULL,
+    .extra_arguments = NULL,
+    .default_sink = NULL,
+    .default_source = NULL,
+    .default_server = NULL,
+    .default_dbus_server = NULL,
+    .cookie_file_from_env = NULL,
+    .cookie_from_x11_valid = false,
+    .cookie_file_from_application = NULL,
+    .cookie_file_from_client_conf = NULL,
+    .autospawn = true,
+    .disable_shm = false,
+    .disable_memfd = false,
+    .shm_size = 0,
+    .auto_connect_localhost = false,
+    .auto_connect_display = false
+};
+
+pa_client_conf *pa_client_conf_new(void) {
+    pa_client_conf *c = pa_xmemdup(&default_conf, sizeof(default_conf));
+
+    c->daemon_binary = pa_xstrdup(PA_BINARY);
+    c->extra_arguments = pa_xstrdup("--log-target=syslog");
+
+    return c;
+}
+
+void pa_client_conf_free(pa_client_conf *c) {
+    pa_assert(c);
+    pa_xfree(c->daemon_binary);
+    pa_xfree(c->extra_arguments);
+    pa_xfree(c->default_sink);
+    pa_xfree(c->default_source);
+    pa_xfree(c->default_server);
+    pa_xfree(c->default_dbus_server);
+    pa_xfree(c->cookie_file_from_env);
+    pa_xfree(c->cookie_file_from_application);
+    pa_xfree(c->cookie_file_from_client_conf);
+    pa_xfree(c);
+}
+
+static void load_env(pa_client_conf *c) {
+    char *e;
+
+    if ((e = getenv(ENV_DEFAULT_SINK))) {
+        pa_xfree(c->default_sink);
+        c->default_sink = pa_xstrdup(e);
+    }
+
+    if ((e = getenv(ENV_DEFAULT_SOURCE))) {
+        pa_xfree(c->default_source);
+        c->default_source = pa_xstrdup(e);
+    }
+
+    if ((e = getenv(ENV_DEFAULT_SERVER))) {
+        pa_xfree(c->default_server);
+        c->default_server = pa_xstrdup(e);
+
+        /* We disable autospawning automatically if a specific server was set */
+        c->autospawn = false;
+    }
+
+    if ((e = getenv(ENV_DAEMON_BINARY))) {
+        pa_xfree(c->daemon_binary);
+        c->daemon_binary = pa_xstrdup(e);
+    }
+
+    if ((e = getenv(ENV_COOKIE_FILE)) && *e) {
+        pa_xfree(c->cookie_file_from_env);
+        c->cookie_file_from_env = pa_xstrdup(e);
+    }
+}
+
+void pa_client_conf_load(pa_client_conf *c, bool load_from_x11, bool load_from_env) {
+    FILE *f = NULL;
+    char *fn = NULL;
+
+    /* Prepare the configuration parse table */
+    pa_config_item table[] = {
+        { "daemon-binary",          pa_config_parse_string,   &c->daemon_binary, NULL },
+        { "extra-arguments",        pa_config_parse_string,   &c->extra_arguments, NULL },
+        { "default-sink",           pa_config_parse_string,   &c->default_sink, NULL },
+        { "default-source",         pa_config_parse_string,   &c->default_source, NULL },
+        { "default-server",         pa_config_parse_string,   &c->default_server, NULL },
+        { "default-dbus-server",    pa_config_parse_string,   &c->default_dbus_server, NULL },
+        { "autospawn",              pa_config_parse_bool,     &c->autospawn, NULL },
+        { "allow-autospawn-for-root", pa_config_parse_bool,   &c->allow_autospawn_for_root, NULL },
+        { "cookie-file",            pa_config_parse_string,   &c->cookie_file_from_client_conf, NULL },
+        { "disable-shm",            pa_config_parse_bool,     &c->disable_shm, NULL },
+        { "enable-shm",             pa_config_parse_not_bool, &c->disable_shm, NULL },
+        { "enable-memfd",           pa_config_parse_not_bool, &c->disable_memfd, NULL },
+        { "shm-size-bytes",         pa_config_parse_size,     &c->shm_size, NULL },
+        { "auto-connect-localhost", pa_config_parse_bool,     &c->auto_connect_localhost, NULL },
+        { "auto-connect-display",   pa_config_parse_bool,     &c->auto_connect_display, NULL },
+        { NULL,                     NULL,                     NULL, NULL },
+    };
+
+    f = pa_open_config_file(DEFAULT_CLIENT_CONFIG_FILE, DEFAULT_CLIENT_CONFIG_FILE_USER, ENV_CLIENT_CONFIG_FILE, &fn);
+    if (f) {
+        pa_config_parse(fn, f, table, NULL, true, NULL);
+        pa_xfree(fn);
+        fclose(f);
+    }
+
+    if (load_from_x11) {
+#ifdef HAVE_X11
+        pa_client_conf_from_x11(c);
+#endif
+    }
+
+    if (load_from_env)
+        load_env(c);
+}
+
+int pa_client_conf_load_cookie(pa_client_conf *c, uint8_t *cookie, size_t cookie_length) {
+    int r;
+    char *fallback_path;
+
+    pa_assert(c);
+    pa_assert(cookie);
+    pa_assert(cookie_length > 0);
+
+    if (c->cookie_file_from_env) {
+        r = pa_authkey_load(c->cookie_file_from_env, true, cookie, cookie_length);
+        if (r >= 0)
+            return 0;
+
+        pa_log_warn("Failed to load cookie from %s (configured with environment variable PULSE_COOKIE): %s",
+                    c->cookie_file_from_env, pa_cstrerror(errno));
+    }
+
+    if (c->cookie_from_x11_valid) {
+        if (cookie_length == sizeof(c->cookie_from_x11)) {
+            memcpy(cookie, c->cookie_from_x11, cookie_length);
+            return 0;
+        }
+
+        pa_log_warn("Failed to load cookie from X11 root window property PULSE_COOKIE: size mismatch.");
+    }
+
+    if (c->cookie_file_from_application) {
+        r = pa_authkey_load(c->cookie_file_from_application, true, cookie, cookie_length);
+        if (r >= 0)
+            return 0;
+
+        pa_log_warn("Failed to load cookie from %s (configured by the application): %s", c->cookie_file_from_application,
+                    pa_cstrerror(errno));
+    }
+
+    if (c->cookie_file_from_client_conf) {
+        r = pa_authkey_load(c->cookie_file_from_client_conf, true, cookie, cookie_length);
+        if (r >= 0)
+            return 0;
+
+        pa_log_warn("Failed to load cookie from %s (configured in client.conf): %s", c->cookie_file_from_client_conf,
+                    pa_cstrerror(errno));
+    }
+
+    r = pa_authkey_load(PA_NATIVE_COOKIE_FILE, false, cookie, cookie_length);
+    if (r >= 0)
+        return 0;
+
+    if (pa_append_to_home_dir(PA_NATIVE_COOKIE_FILE_FALLBACK, &fallback_path) >= 0) {
+        r = pa_authkey_load(fallback_path, false, cookie, cookie_length);
+        pa_xfree(fallback_path);
+        if (r >= 0)
+            return 0;
+    }
+
+    r = pa_authkey_load(PA_NATIVE_COOKIE_FILE, true, cookie, cookie_length);
+    if (r >= 0)
+        return 0;
+
+    pa_log("Failed to load cookie file from %s: %s", PA_NATIVE_COOKIE_FILE, pa_cstrerror(errno));
+    memset(cookie, 0, cookie_length);
+
+    return -1;
+}
+
+void pa_client_conf_set_cookie_file_from_application(pa_client_conf *c, const char *cookie_file) {
+    pa_assert(c);
+    pa_assert(!cookie_file || *cookie_file);
+
+    pa_xfree(c->cookie_file_from_application);
+    c->cookie_file_from_application = pa_xstrdup(cookie_file);
+}
Index: create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse/client-conf.h
===================================================================
--- create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse/client-conf.h	(nonexistent)
+++ create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse/client-conf.h	(revision 5)
@@ -0,0 +1,62 @@
+#ifndef fooclientconfhfoo
+#define fooclientconfhfoo
+
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2004-2006 Lennart Poettering
+
+  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.1 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, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <pulsecore/macro.h>
+#include <pulsecore/native-common.h>
+
+/* A structure containing configuration data for PulseAudio clients. */
+
+typedef struct pa_client_conf {
+    char *daemon_binary;
+    char *extra_arguments;
+    char *default_sink;
+    char *default_source;
+    char *default_server;
+    char *default_dbus_server;
+    char *cookie_file_from_env;
+    uint8_t cookie_from_x11[PA_NATIVE_COOKIE_LENGTH];
+    bool cookie_from_x11_valid;
+    char *cookie_file_from_application;
+    char *cookie_file_from_client_conf;
+    bool autospawn, disable_shm, disable_memfd, auto_connect_localhost, auto_connect_display;
+    bool allow_autospawn_for_root;
+    size_t shm_size;
+} pa_client_conf;
+
+/* Create a new configuration data object and reset it to defaults */
+pa_client_conf *pa_client_conf_new(void);
+void pa_client_conf_free(pa_client_conf *c);
+
+/* Load the configuration data from the client configuration file and
+ * optionally from X11 and/or environment variables, overwriting the current
+ * settings in *c. */
+void pa_client_conf_load(pa_client_conf *c, bool load_from_x11, bool load_from_env);
+
+/* Load the cookie from the cookie sources specified in the configuration, or
+ * if nothing is specified or none of the sources work, load the cookie from
+ * the default source. If the default source doesn't work either, this function
+ * returns a negative value and initializes the cookie to all-zeroes. */
+int pa_client_conf_load_cookie(pa_client_conf *c, uint8_t *cookie, size_t cookie_length);
+
+void pa_client_conf_set_cookie_file_from_application(pa_client_conf *c, const char *cookie_file);
+
+#endif
Index: create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse/client.conf.in
===================================================================
--- create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse/client.conf.in	(nonexistent)
+++ create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse/client.conf.in	(revision 5)
@@ -0,0 +1,36 @@
+# This file is part of PulseAudio.
+#
+# 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, see <http://www.gnu.org/licenses/>.
+
+## Configuration file for PulseAudio clients. See pulse-client.conf(5) for
+## more information. Default values are commented out.  Use either ; or # for
+## commenting.
+
+; default-sink =
+; default-source =
+; default-server =
+; default-dbus-server =
+
+autospawn = yes
+allow-autospawn-for-root = yes
+; daemon-binary = @PA_BINARY@
+; extra-arguments = --log-target=syslog
+
+; cookie-file =
+
+; enable-shm = yes
+; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB
+
+; auto-connect-localhost = no
+; auto-connect-display = no
Index: create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse/context.c
===================================================================
--- create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse/context.c	(nonexistent)
+++ create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse/context.c	(revision 5)
@@ -0,0 +1,1671 @@
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2004-2008 Lennart Poettering
+  Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
+
+  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.1 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, see <http://www.gnu.org/licenses/>.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <signal.h>
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+#include <pulse/version.h>
+#include <pulse/xmalloc.h>
+#include <pulse/util.h>
+#include <pulse/mainloop.h>
+#include <pulse/timeval.h>
+#include <pulse/fork-detect.h>
+#include <pulse/client-conf.h>
+
+#include <pulsecore/core-error.h>
+#include <pulsecore/i18n.h>
+#include <pulsecore/native-common.h>
+#include <pulsecore/pdispatch.h>
+#include <pulsecore/pstream.h>
+#include <pulsecore/hashmap.h>
+#include <pulsecore/socket-client.h>
+#include <pulsecore/pstream-util.h>
+#include <pulsecore/core-rtclock.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/log.h>
+#include <pulsecore/socket.h>
+#include <pulsecore/creds.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/proplist-util.h>
+
+#include "internal.h"
+#include "context.h"
+
+void pa_command_extension(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void pa_command_enable_srbchannel(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void pa_command_disable_srbchannel(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+static void pa_command_register_memfd_shmid(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
+
+static const pa_pdispatch_cb_t command_table[PA_COMMAND_MAX] = {
+    [PA_COMMAND_REQUEST] = pa_command_request,
+    [PA_COMMAND_OVERFLOW] = pa_command_overflow_or_underflow,
+    [PA_COMMAND_UNDERFLOW] = pa_command_overflow_or_underflow,
+    [PA_COMMAND_PLAYBACK_STREAM_KILLED] = pa_command_stream_killed,
+    [PA_COMMAND_RECORD_STREAM_KILLED] = pa_command_stream_killed,
+    [PA_COMMAND_PLAYBACK_STREAM_MOVED] = pa_command_stream_moved,
+    [PA_COMMAND_RECORD_STREAM_MOVED] = pa_command_stream_moved,
+    [PA_COMMAND_PLAYBACK_STREAM_SUSPENDED] = pa_command_stream_suspended,
+    [PA_COMMAND_RECORD_STREAM_SUSPENDED] = pa_command_stream_suspended,
+    [PA_COMMAND_STARTED] = pa_command_stream_started,
+    [PA_COMMAND_SUBSCRIBE_EVENT] = pa_command_subscribe_event,
+    [PA_COMMAND_EXTENSION] = pa_command_extension,
+    [PA_COMMAND_PLAYBACK_STREAM_EVENT] = pa_command_stream_event,
+    [PA_COMMAND_RECORD_STREAM_EVENT] = pa_command_stream_event,
+    [PA_COMMAND_CLIENT_EVENT] = pa_command_client_event,
+    [PA_COMMAND_PLAYBACK_BUFFER_ATTR_CHANGED] = pa_command_stream_buffer_attr,
+    [PA_COMMAND_RECORD_BUFFER_ATTR_CHANGED] = pa_command_stream_buffer_attr,
+    [PA_COMMAND_ENABLE_SRBCHANNEL] = pa_command_enable_srbchannel,
+    [PA_COMMAND_DISABLE_SRBCHANNEL] = pa_command_disable_srbchannel,
+    [PA_COMMAND_REGISTER_MEMFD_SHMID] = pa_command_register_memfd_shmid,
+};
+static void context_free(pa_context *c);
+
+#ifdef HAVE_DBUS
+static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *message, void *userdata);
+#endif
+
+pa_context *pa_context_new(pa_mainloop_api *mainloop, const char *name) {
+    return pa_context_new_with_proplist(mainloop, name, NULL);
+}
+
+static void reset_callbacks(pa_context *c) {
+    pa_assert(c);
+
+    c->state_callback = NULL;
+    c->state_userdata = NULL;
+
+    c->subscribe_callback = NULL;
+    c->subscribe_userdata = NULL;
+
+    c->event_callback = NULL;
+    c->event_userdata = NULL;
+
+    c->ext_device_manager.callback = NULL;
+    c->ext_device_manager.userdata = NULL;
+
+    c->ext_device_restore.callback = NULL;
+    c->ext_device_restore.userdata = NULL;
+
+    c->ext_stream_restore.callback = NULL;
+    c->ext_stream_restore.userdata = NULL;
+}
+
+pa_context *pa_context_new_with_proplist(pa_mainloop_api *mainloop, const char *name, const pa_proplist *p) {
+    pa_context *c;
+    pa_mem_type_t type;
+    const char *force_disable_shm_str;
+
+    pa_assert(mainloop);
+
+    if (pa_detect_fork())
+        return NULL;
+
+    pa_init_i18n();
+
+    c = pa_xnew0(pa_context, 1);
+    PA_REFCNT_INIT(c);
+
+    c->error = pa_xnew0(pa_context_error, 1);
+    assert(c->error);
+
+    c->proplist = p ? pa_proplist_copy(p) : pa_proplist_new();
+
+    if (name)
+        pa_proplist_sets(c->proplist, PA_PROP_APPLICATION_NAME, name);
+
+#ifdef HAVE_DBUS
+    c->system_bus = c->session_bus = NULL;
+#endif
+    c->mainloop = mainloop;
+    c->playback_streams = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
+    c->record_streams = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
+    c->client_index = PA_INVALID_INDEX;
+    c->use_rtclock = pa_mainloop_is_our_api(mainloop);
+
+    PA_LLIST_HEAD_INIT(pa_stream, c->streams);
+    PA_LLIST_HEAD_INIT(pa_operation, c->operations);
+
+    c->error->error = PA_OK;
+    c->state = PA_CONTEXT_UNCONNECTED;
+
+    reset_callbacks(c);
+
+#ifndef MSG_NOSIGNAL
+#ifdef SIGPIPE
+    pa_check_signal_is_blocked(SIGPIPE);
+#endif
+#endif
+
+    c->conf = pa_client_conf_new();
+    pa_client_conf_load(c->conf, true, true);
+
+    force_disable_shm_str = pa_proplist_gets(c->proplist, PA_PROP_CONTEXT_FORCE_DISABLE_SHM);
+    if (force_disable_shm_str) {
+        int b = pa_parse_boolean(force_disable_shm_str);
+        if (b < 0) {
+            pa_log_warn("Ignored invalid value for '%s' property: %s", PA_PROP_CONTEXT_FORCE_DISABLE_SHM, force_disable_shm_str);
+        } else if (b) {
+            c->conf->disable_shm = true;
+        }
+    }
+
+    c->srb_template.readfd = -1;
+    c->srb_template.writefd = -1;
+
+    c->memfd_on_local = (!c->conf->disable_memfd && pa_memfd_is_locally_supported());
+
+    type = (c->conf->disable_shm) ? PA_MEM_TYPE_PRIVATE :
+           ((!c->memfd_on_local) ?
+               PA_MEM_TYPE_SHARED_POSIX : PA_MEM_TYPE_SHARED_MEMFD);
+
+    if (!(c->mempool = pa_mempool_new(type, c->conf->shm_size, true))) {
+
+        if (!c->conf->disable_shm) {
+            pa_log_warn("Failed to allocate shared memory pool. Falling back to a normal private one.");
+            c->mempool = pa_mempool_new(PA_MEM_TYPE_PRIVATE, c->conf->shm_size, true);
+        }
+
+        if (!c->mempool) {
+            context_free(c);
+            return NULL;
+        }
+    }
+
+    return c;
+}
+
+static void context_unlink(pa_context *c) {
+    pa_stream *s;
+
+    pa_assert(c);
+
+    s = c->streams ? pa_stream_ref(c->streams) : NULL;
+    while (s) {
+        pa_stream *n = s->next ? pa_stream_ref(s->next) : NULL;
+        pa_stream_set_state(s, c->state == PA_CONTEXT_FAILED ? PA_STREAM_FAILED : PA_STREAM_TERMINATED);
+        pa_stream_unref(s);
+        s = n;
+    }
+
+    while (c->operations)
+        pa_operation_cancel(c->operations);
+
+    if (c->pdispatch) {
+        pa_pdispatch_unref(c->pdispatch);
+        c->pdispatch = NULL;
+    }
+
+    if (c->pstream) {
+        pa_pstream_unlink(c->pstream);
+        pa_pstream_unref(c->pstream);
+        c->pstream = NULL;
+    }
+
+    if (c->srb_template.memblock) {
+        pa_memblock_unref(c->srb_template.memblock);
+        c->srb_template.memblock = NULL;
+    }
+
+    if (c->client) {
+        pa_socket_client_unref(c->client);
+        c->client = NULL;
+    }
+
+    reset_callbacks(c);
+}
+
+static void context_free(pa_context *c) {
+    pa_assert(c);
+
+    context_unlink(c);
+
+#ifdef HAVE_DBUS
+    if (c->system_bus) {
+        if (c->filter_added)
+            dbus_connection_remove_filter(pa_dbus_wrap_connection_get(c->system_bus), filter_cb, c);
+        pa_dbus_wrap_connection_free(c->system_bus);
+    }
+
+    if (c->session_bus) {
+        if (c->filter_added)
+            dbus_connection_remove_filter(pa_dbus_wrap_connection_get(c->session_bus), filter_cb, c);
+        pa_dbus_wrap_connection_free(c->session_bus);
+    }
+#endif
+
+    if (c->record_streams)
+        pa_hashmap_free(c->record_streams);
+    if (c->playback_streams)
+        pa_hashmap_free(c->playback_streams);
+
+    if (c->mempool)
+        pa_mempool_unref(c->mempool);
+
+    if (c->conf)
+        pa_client_conf_free(c->conf);
+
+    pa_strlist_free(c->server_list);
+
+    if (c->proplist)
+        pa_proplist_free(c->proplist);
+
+    pa_xfree(c->server);
+    pa_xfree(c->error);
+    pa_xfree(c);
+}
+
+pa_context* pa_context_ref(pa_context *c) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_REFCNT_INC(c);
+    return c;
+}
+
+void pa_context_unref(pa_context *c) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    if (PA_REFCNT_DEC(c) <= 0)
+        context_free(c);
+}
+
+void pa_context_set_state(pa_context *c, pa_context_state_t st) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    if (c->state == st)
+        return;
+
+    pa_context_ref(c);
+
+    c->state = st;
+
+    if (c->state_callback)
+        c->state_callback(c, c->state_userdata);
+
+    if (st == PA_CONTEXT_FAILED || st == PA_CONTEXT_TERMINATED)
+        context_unlink(c);
+
+    pa_context_unref(c);
+}
+
+int pa_context_set_error(const pa_context *c, int error) {
+    pa_assert(error >= 0);
+    pa_assert(error < PA_ERR_MAX);
+
+    if (c)
+        c->error->error = error;
+
+    return error;
+}
+
+void pa_context_fail(pa_context *c, int error) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    pa_context_set_error(c, error);
+    pa_context_set_state(c, PA_CONTEXT_FAILED);
+}
+
+static void pstream_die_callback(pa_pstream *p, void *userdata) {
+    pa_context *c = userdata;
+
+    pa_assert(p);
+    pa_assert(c);
+
+    pa_context_fail(c, PA_ERR_CONNECTIONTERMINATED);
+}
+
+static void pstream_packet_callback(pa_pstream *p, pa_packet *packet, pa_cmsg_ancil_data *ancil_data, void *userdata) {
+    pa_context *c = userdata;
+
+    pa_assert(p);
+    pa_assert(packet);
+    pa_assert(c);
+
+    pa_context_ref(c);
+
+    if (pa_pdispatch_run(c->pdispatch, packet, ancil_data, c) < 0)
+        pa_context_fail(c, PA_ERR_PROTOCOL);
+
+    pa_context_unref(c);
+}
+
+static void handle_srbchannel_memblock(pa_context *c, pa_memblock *memblock) {
+    pa_srbchannel *sr;
+    pa_tagstruct *t;
+
+    pa_assert(c);
+
+    /* Memblock sanity check */
+    if (!memblock) {
+        pa_context_fail(c, PA_ERR_PROTOCOL);
+        return;
+    } else if (pa_memblock_is_read_only(memblock)) {
+        pa_context_fail(c, PA_ERR_PROTOCOL);
+        return;
+    } else if (pa_memblock_is_ours(memblock)) {
+        pa_context_fail(c, PA_ERR_PROTOCOL);
+        return;
+    }
+
+    /* Create the srbchannel */
+    c->srb_template.memblock = memblock;
+    pa_memblock_ref(memblock);
+    sr = pa_srbchannel_new_from_template(c->mainloop, &c->srb_template);
+    if (!sr) {
+        pa_log_warn("Failed to create srbchannel from template");
+        c->srb_template.readfd = -1;
+        c->srb_template.writefd = -1;
+        pa_memblock_unref(c->srb_template.memblock);
+        c->srb_template.memblock = NULL;
+        return;
+    }
+
+    /* Ack the enable command */
+    t = pa_tagstruct_new();
+    pa_tagstruct_putu32(t, PA_COMMAND_ENABLE_SRBCHANNEL);
+    pa_tagstruct_putu32(t, c->srb_setup_tag);
+    pa_pstream_send_tagstruct(c->pstream, t);
+
+    /* ...and switch over */
+    pa_pstream_set_srbchannel(c->pstream, sr);
+}
+
+static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t offset, pa_seek_mode_t seek, const pa_memchunk *chunk, void *userdata) {
+    pa_context *c = userdata;
+    pa_stream *s;
+
+    pa_assert(p);
+    pa_assert(chunk);
+    pa_assert(chunk->length > 0);
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    pa_context_ref(c);
+
+    if (c->srb_template.readfd != -1 && c->srb_template.memblock == NULL) {
+        handle_srbchannel_memblock(c, chunk->memblock);
+        pa_context_unref(c);
+        return;
+    }
+
+    if ((s = pa_hashmap_get(c->record_streams, PA_UINT32_TO_PTR(channel)))) {
+
+        if (chunk->memblock) {
+            pa_memblockq_seek(s->record_memblockq, offset, seek, true);
+            pa_memblockq_push_align(s->record_memblockq, chunk);
+        } else
+            pa_memblockq_seek(s->record_memblockq, offset+chunk->length, seek, true);
+
+        if (s->read_callback) {
+            size_t l;
+
+            if ((l = pa_memblockq_get_length(s->record_memblockq)) > 0)
+                s->read_callback(s, l, s->read_userdata);
+        }
+    }
+
+    pa_context_unref(c);
+}
+
+int pa_context_handle_error(pa_context *c, uint32_t command, pa_tagstruct *t, bool fail) {
+    uint32_t err;
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    if (command == PA_COMMAND_ERROR) {
+        pa_assert(t);
+
+        if (pa_tagstruct_getu32(t, &err) < 0 ||
+            !pa_tagstruct_eof(t)) {
+            pa_context_fail(c, PA_ERR_PROTOCOL);
+            return -1;
+        }
+
+    } else if (command == PA_COMMAND_TIMEOUT)
+        err = PA_ERR_TIMEOUT;
+    else {
+        pa_context_fail(c, PA_ERR_PROTOCOL);
+        return -1;
+    }
+
+    if (err == PA_OK) {
+        pa_context_fail(c, PA_ERR_PROTOCOL);
+        return -1;
+    }
+
+    if (err >= PA_ERR_MAX)
+        err = PA_ERR_UNKNOWN;
+
+    if (fail) {
+        pa_context_fail(c, (int) err);
+        return -1;
+    }
+
+    pa_context_set_error(c, (int) err);
+
+    return 0;
+}
+
+static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
+    pa_context *c = userdata;
+
+    pa_assert(pd);
+    pa_assert(c);
+    pa_assert(c->state == PA_CONTEXT_AUTHORIZING || c->state == PA_CONTEXT_SETTING_NAME);
+
+    pa_context_ref(c);
+
+    if (command != PA_COMMAND_REPLY) {
+        pa_context_handle_error(c, command, t, true);
+        goto finish;
+    }
+
+    switch(c->state) {
+        case PA_CONTEXT_AUTHORIZING: {
+            pa_tagstruct *reply;
+            bool shm_on_remote = false;
+            bool memfd_on_remote = false;
+
+            if (pa_tagstruct_getu32(t, &c->version) < 0 ||
+                !pa_tagstruct_eof(t)) {
+                pa_context_fail(c, PA_ERR_PROTOCOL);
+                goto finish;
+            }
+
+            /* Minimum supported version */
+            if (c->version < 8) {
+                pa_context_fail(c, PA_ERR_VERSION);
+                goto finish;
+            }
+
+            /* Starting with protocol version 13 the MSB of the version
+               tag reflects if shm is available for this connection or
+               not. */
+            if ((c->version & PA_PROTOCOL_VERSION_MASK) >= 13) {
+                shm_on_remote = !!(c->version & PA_PROTOCOL_FLAG_SHM);
+
+                /* Starting with protocol version 31, the second MSB of the version
+                 * tag reflects whether memfd is supported on the other PA end. */
+                if ((c->version & PA_PROTOCOL_VERSION_MASK) >= 31)
+                    memfd_on_remote = !!(c->version & PA_PROTOCOL_FLAG_MEMFD);
+
+                /* Reserve the two most-significant _bytes_ of the version tag
+                 * for flags. */
+                c->version &= PA_PROTOCOL_VERSION_MASK;
+            }
+
+            pa_log_debug("Protocol version: remote %u, local %u", c->version, PA_PROTOCOL_VERSION);
+
+            /* Enable shared memory support if possible */
+            if (c->do_shm)
+                if (c->version < 10 || (c->version >= 13 && !shm_on_remote))
+                    c->do_shm = false;
+
+            if (c->do_shm) {
+
+                /* Only enable SHM if both sides are owned by the same
+                 * user. This is a security measure because otherwise
+                 * data private to the user might leak. */
+
+#ifdef HAVE_CREDS
+                const pa_creds *creds;
+                if (!(creds = pa_pdispatch_creds(pd)) || getuid() != creds->uid)
+                    c->do_shm = false;
+#endif
+            }
+
+            pa_log_debug("Negotiated SHM: %s", pa_yes_no(c->do_shm));
+            pa_pstream_enable_shm(c->pstream, c->do_shm);
+
+            c->shm_type = PA_MEM_TYPE_PRIVATE;
+            if (c->do_shm) {
+                if (c->version >= 31 && memfd_on_remote && c->memfd_on_local) {
+                    const char *reason;
+
+                    pa_pstream_enable_memfd(c->pstream);
+                    if (pa_mempool_is_memfd_backed(c->mempool))
+                        if (pa_pstream_register_memfd_mempool(c->pstream, c->mempool, &reason))
+                            pa_log("Failed to regester memfd mempool. Reason: %s", reason);
+
+                    /* Even if memfd pool registration fails, the negotiated SHM type
+                     * shall remain memfd as both endpoints claim to support it. */
+                    c->shm_type = PA_MEM_TYPE_SHARED_MEMFD;
+                } else
+                    c->shm_type = PA_MEM_TYPE_SHARED_POSIX;
+            }
+
+            pa_log_debug("Memfd possible: %s", pa_yes_no(c->memfd_on_local));
+            pa_log_debug("Negotiated SHM type: %s", pa_mem_type_to_string(c->shm_type));
+
+            reply = pa_tagstruct_command(c, PA_COMMAND_SET_CLIENT_NAME, &tag);
+
+            if (c->version >= 13) {
+                pa_init_proplist(c->proplist);
+                pa_tagstruct_put_proplist(reply, c->proplist);
+            } else
+                pa_tagstruct_puts(reply, pa_proplist_gets(c->proplist, PA_PROP_APPLICATION_NAME));
+
+            pa_pstream_send_tagstruct(c->pstream, reply);
+            pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, setup_complete_callback, c, NULL);
+
+            pa_context_set_state(c, PA_CONTEXT_SETTING_NAME);
+            break;
+        }
+
+        case PA_CONTEXT_SETTING_NAME :
+
+            if ((c->version >= 13 && (pa_tagstruct_getu32(t, &c->client_index) < 0 ||
+                                      c->client_index == PA_INVALID_INDEX)) ||
+                !pa_tagstruct_eof(t)) {
+                pa_context_fail(c, PA_ERR_PROTOCOL);
+                goto finish;
+            }
+
+            pa_context_set_state(c, PA_CONTEXT_READY);
+            break;
+
+        default:
+            pa_assert_not_reached();
+    }
+
+finish:
+    pa_context_unref(c);
+}
+
+static void setup_context(pa_context *c, pa_iochannel *io) {
+    uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
+    pa_tagstruct *t;
+    uint32_t tag;
+
+    pa_assert(c);
+    pa_assert(io);
+
+    pa_context_ref(c);
+
+    pa_assert(!c->pstream);
+    c->pstream = pa_pstream_new(c->mainloop, io, c->mempool);
+
+    pa_pstream_set_die_callback(c->pstream, pstream_die_callback, c);
+    pa_pstream_set_receive_packet_callback(c->pstream, pstream_packet_callback, c);
+    pa_pstream_set_receive_memblock_callback(c->pstream, pstream_memblock_callback, c);
+
+    pa_assert(!c->pdispatch);
+    c->pdispatch = pa_pdispatch_new(c->mainloop, c->use_rtclock, command_table, PA_COMMAND_MAX);
+
+    if (pa_client_conf_load_cookie(c->conf, cookie, sizeof(cookie)) < 0)
+        pa_log_info("No cookie loaded. Attempting to connect without.");
+
+    t = pa_tagstruct_command(c, PA_COMMAND_AUTH, &tag);
+
+    c->do_shm =
+        pa_mempool_is_shared(c->mempool) &&
+        c->is_local;
+
+    pa_log_debug("SHM possible: %s", pa_yes_no(c->do_shm));
+
+    /* Starting with protocol version 13 we use the MSB of the version
+     * tag for informing the other side if we could do SHM or not.
+     * Starting from version 31, second MSB is used to flag memfd support. */
+    pa_tagstruct_putu32(t, PA_PROTOCOL_VERSION | (c->do_shm ? PA_PROTOCOL_FLAG_SHM : 0) |
+                        (c->memfd_on_local ? PA_PROTOCOL_FLAG_MEMFD: 0));
+    pa_tagstruct_put_arbitrary(t, cookie, sizeof(cookie));
+
+#ifdef HAVE_CREDS
+{
+    pa_creds ucred;
+
+    if (pa_iochannel_creds_supported(io))
+        pa_iochannel_creds_enable(io);
+
+    ucred.uid = getuid();
+    ucred.gid = getgid();
+
+    pa_pstream_send_tagstruct_with_creds(c->pstream, t, &ucred);
+}
+#else
+    pa_pstream_send_tagstruct(c->pstream, t);
+#endif
+
+    pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, setup_complete_callback, c, NULL);
+
+    pa_context_set_state(c, PA_CONTEXT_AUTHORIZING);
+
+    pa_context_unref(c);
+}
+
+static pa_strlist *prepend_per_user(pa_strlist *l) {
+    char *ufn;
+
+    /* The per-user instance */
+    if ((ufn = pa_runtime_path(PA_NATIVE_DEFAULT_UNIX_SOCKET))) {
+        l = pa_strlist_prepend(l, ufn);
+        pa_xfree(ufn);
+    }
+
+    return l;
+}
+
+#ifndef OS_IS_WIN32
+
+static int context_autospawn(pa_context *c) {
+    pid_t pid;
+    int status, r;
+    struct sigaction sa;
+
+    pa_context_ref(c);
+
+    if (sigaction(SIGCHLD, NULL, &sa) < 0) {
+        pa_log_debug("sigaction() failed: %s", pa_cstrerror(errno));
+        pa_context_fail(c, PA_ERR_INTERNAL);
+        goto fail;
+    }
+
+#ifdef SA_NOCLDWAIT
+    if ((sa.sa_flags & SA_NOCLDWAIT) || sa.sa_handler == SIG_IGN) {
+#else
+    if (sa.sa_handler == SIG_IGN) {
+#endif
+        pa_log_debug("Process disabled waitpid(), cannot autospawn.");
+        pa_context_fail(c, PA_ERR_CONNECTIONREFUSED);
+        goto fail;
+    }
+
+    pa_log_debug("Trying to autospawn...");
+
+    if (c->spawn_api.prefork)
+        c->spawn_api.prefork();
+
+    if ((pid = fork()) < 0) {
+        pa_log_error(_("fork(): %s"), pa_cstrerror(errno));
+        pa_context_fail(c, PA_ERR_INTERNAL);
+
+        if (c->spawn_api.postfork)
+            c->spawn_api.postfork();
+
+        goto fail;
+    } else if (!pid) {
+        /* Child */
+
+        const char *state = NULL;
+        const char * argv[32];
+        unsigned n = 0;
+
+        if (c->spawn_api.atfork)
+            c->spawn_api.atfork();
+
+        /* We leave most of the cleaning up of the process environment
+         * to the executable. We only clean up the file descriptors to
+         * make sure the executable can actually be loaded
+         * correctly. */
+        pa_close_all(-1);
+
+        /* Setup argv */
+        argv[n++] = c->conf->daemon_binary;
+        argv[n++] = "--start";
+
+        while (n < PA_ELEMENTSOF(argv)-1) {
+            char *a;
+
+            if (!(a = pa_split_spaces(c->conf->extra_arguments, &state)))
+                break;
+
+            argv[n++] = a;
+        }
+
+        argv[n++] = NULL;
+        pa_assert(n <= PA_ELEMENTSOF(argv));
+
+        execv(argv[0], (char * const *) argv);
+        _exit(1);
+    }
+
+    /* Parent */
+
+    if (c->spawn_api.postfork)
+        c->spawn_api.postfork();
+
+    do {
+        r = waitpid(pid, &status, 0);
+    } while (r < 0 && errno == EINTR);
+
+    if (r < 0) {
+
+        if (errno != ECHILD) {
+            pa_log(_("waitpid(): %s"), pa_cstrerror(errno));
+            pa_context_fail(c, PA_ERR_INTERNAL);
+            goto fail;
+        }
+
+        /* hmm, something already reaped our child, so we assume
+         * startup worked, even if we cannot know */
+
+    } else if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
+        pa_context_fail(c, PA_ERR_CONNECTIONREFUSED);
+        goto fail;
+    }
+
+    pa_context_unref(c);
+
+    return 0;
+
+fail:
+
+    pa_context_unref(c);
+
+    return -1;
+}
+
+#endif /* OS_IS_WIN32 */
+
+static void on_connection(pa_socket_client *client, pa_iochannel*io, void *userdata);
+
+#ifdef HAVE_DBUS
+static void track_pulseaudio_on_dbus(pa_context *c, DBusBusType type, pa_dbus_wrap_connection **conn) {
+    DBusError error;
+
+    pa_assert(c);
+    pa_assert(conn);
+
+    dbus_error_init(&error);
+
+    if (!(*conn = pa_dbus_wrap_connection_new(c->mainloop, c->use_rtclock, type, &error)) || dbus_error_is_set(&error)) {
+        pa_log_warn("Unable to contact DBUS: %s: %s", error.name, error.message);
+        goto fail;
+    }
+
+    if (!dbus_connection_add_filter(pa_dbus_wrap_connection_get(*conn), filter_cb, c, NULL)) {
+        pa_log_warn("Failed to add filter function");
+        goto fail;
+    }
+    c->filter_added = true;
+
+    if (pa_dbus_add_matches(
+                pa_dbus_wrap_connection_get(*conn), &error,
+                "type='signal',sender='" DBUS_SERVICE_DBUS "',interface='" DBUS_INTERFACE_DBUS "',member='NameOwnerChanged',arg0='org.pulseaudio.Server',arg1=''", NULL) < 0) {
+
+        pa_log_warn("Unable to track org.pulseaudio.Server: %s: %s", error.name, error.message);
+        goto fail;
+    }
+
+    return;
+
+fail:
+    if (*conn) {
+        pa_dbus_wrap_connection_free(*conn);
+        *conn = NULL;
+    }
+
+    dbus_error_free(&error);
+}
+#endif
+
+static int try_next_connection(pa_context *c) {
+    char *u = NULL;
+    int r = -1;
+
+    pa_assert(c);
+    pa_assert(!c->client);
+
+    for (;;) {
+        pa_xfree(u);
+        u = NULL;
+
+        c->server_list = pa_strlist_pop(c->server_list, &u);
+
+        if (!u) {
+
+#ifndef OS_IS_WIN32
+            if (c->do_autospawn) {
+
+                if ((r = context_autospawn(c)) < 0)
+                    goto finish;
+
+                /* Autospawn only once */
+                c->do_autospawn = false;
+
+                /* Connect only to per-user sockets this time */
+                c->server_list = prepend_per_user(c->server_list);
+
+                /* Retry connection */
+                continue;
+            }
+#endif
+
+#ifdef HAVE_DBUS
+            if (c->no_fail && !c->server_specified) {
+                if (!c->session_bus)
+                    track_pulseaudio_on_dbus(c, DBUS_BUS_SESSION, &c->session_bus);
+                if (!c->system_bus)
+                    track_pulseaudio_on_dbus(c, DBUS_BUS_SYSTEM, &c->system_bus);
+
+                if (c->session_bus || c->system_bus) {
+                    pa_log_debug("Waiting for PA on D-Bus...");
+                    break;
+                }
+            } else
+#endif
+                pa_context_fail(c, PA_ERR_CONNECTIONREFUSED);
+
+            goto finish;
+        }
+
+        pa_log_debug("Trying to connect to %s...", u);
+
+        pa_xfree(c->server);
+        c->server = pa_xstrdup(u);
+
+        if (!(c->client = pa_socket_client_new_string(c->mainloop, c->use_rtclock, u, PA_NATIVE_DEFAULT_PORT)))
+            continue;
+
+        c->is_local = pa_socket_client_is_local(c->client);
+        pa_socket_client_set_callback(c->client, on_connection, c);
+        break;
+    }
+
+    r = 0;
+
+finish:
+    pa_xfree(u);
+
+    return r;
+}
+
+static void on_connection(pa_socket_client *client, pa_iochannel*io, void *userdata) {
+    pa_context *c = userdata;
+    int saved_errno = errno;
+
+    pa_assert(client);
+    pa_assert(c);
+    pa_assert(c->state == PA_CONTEXT_CONNECTING);
+
+    pa_context_ref(c);
+
+    pa_socket_client_unref(client);
+    c->client = NULL;
+
+    if (!io) {
+        /* Try the next item in the list */
+        if (saved_errno == ECONNREFUSED ||
+            saved_errno == ETIMEDOUT ||
+            saved_errno == EHOSTUNREACH) {
+            try_next_connection(c);
+            goto finish;
+        }
+
+        pa_context_fail(c, PA_ERR_CONNECTIONREFUSED);
+        goto finish;
+    }
+
+    setup_context(c, io);
+
+finish:
+    pa_context_unref(c);
+}
+
+#ifdef HAVE_DBUS
+static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *message, void *userdata) {
+    pa_context *c = userdata;
+    bool is_session;
+
+    pa_assert(bus);
+    pa_assert(message);
+    pa_assert(c);
+
+    if (c->state != PA_CONTEXT_CONNECTING)
+        goto finish;
+
+    if (!c->no_fail)
+        goto finish;
+
+    /* FIXME: We probably should check if this is actually the NameOwnerChanged we were looking for */
+
+    is_session = c->session_bus && bus == pa_dbus_wrap_connection_get(c->session_bus);
+    pa_log_debug("Rock!! PulseAudio might be back on %s bus", is_session ? "session" : "system");
+
+    if (is_session)
+        /* The user instance via PF_LOCAL */
+        c->server_list = prepend_per_user(c->server_list);
+    else
+        /* The system wide instance via PF_LOCAL */
+        c->server_list = pa_strlist_prepend(c->server_list, PA_SYSTEM_RUNTIME_PATH PA_PATH_SEP PA_NATIVE_DEFAULT_UNIX_SOCKET);
+
+    if (!c->client)
+        try_next_connection(c);
+
+finish:
+    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+#endif
+
+int pa_context_connect(
+        pa_context *c,
+        const char *server,
+        pa_context_flags_t flags,
+        const pa_spawn_api *api) {
+
+    int r = -1;
+
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY(c, !pa_detect_fork(), PA_ERR_FORKED);
+    PA_CHECK_VALIDITY(c, c->state == PA_CONTEXT_UNCONNECTED, PA_ERR_BADSTATE);
+    PA_CHECK_VALIDITY(c, !(flags & ~(PA_CONTEXT_NOAUTOSPAWN|PA_CONTEXT_NOFAIL)), PA_ERR_INVALID);
+    PA_CHECK_VALIDITY(c, !server || *server, PA_ERR_INVALID);
+
+    if (server)
+        c->conf->autospawn = false;
+    else
+        server = c->conf->default_server;
+
+    pa_context_ref(c);
+
+    c->no_fail = !!(flags & PA_CONTEXT_NOFAIL);
+    c->server_specified = !!server;
+    pa_assert(!c->server_list);
+
+    if (server) {
+        if (!(c->server_list = pa_strlist_parse(server))) {
+            pa_context_fail(c, PA_ERR_INVALIDSERVER);
+            goto finish;
+        }
+
+    } else {
+        char *d;
+
+        /* Prepend in reverse order */
+
+        /* Follow the X display */
+        if (c->conf->auto_connect_display) {
+            if ((d = getenv("DISPLAY"))) {
+                d = pa_xstrndup(d, strcspn(d, ":"));
+
+                if (*d)
+                    c->server_list = pa_strlist_prepend(c->server_list, d);
+
+                pa_xfree(d);
+            }
+        }
+
+        /* Add TCP/IP on the localhost */
+        if (c->conf->auto_connect_localhost) {
+#if defined(HAVE_IPV6) && !defined(OS_IS_WIN32)
+            /* FIXME: pa_socket_client does not support IPv6 on Windows */
+            c->server_list = pa_strlist_prepend(c->server_list, "tcp6:[::1]");
+#endif
+            c->server_list = pa_strlist_prepend(c->server_list, "tcp4:127.0.0.1");
+        }
+
+        /* The system wide instance via PF_LOCAL */
+#ifndef OS_IS_WIN32
+        c->server_list = pa_strlist_prepend(c->server_list, PA_SYSTEM_RUNTIME_PATH PA_PATH_SEP PA_NATIVE_DEFAULT_UNIX_SOCKET);
+#else
+        /* see change_user in src/daemon/main.c */
+        char *run_path = pa_sprintf_malloc("%s" PA_PATH_SEP "run" PA_PATH_SEP PA_NATIVE_DEFAULT_UNIX_SOCKET, pa_win32_get_system_appdata());
+        c->server_list = pa_strlist_prepend(c->server_list, run_path);
+        pa_xfree(run_path);
+#endif
+
+        /* The user instance via PF_LOCAL */
+        c->server_list = prepend_per_user(c->server_list);
+    }
+
+    /* Set up autospawning */
+    if (!(flags & PA_CONTEXT_NOAUTOSPAWN) && c->conf->autospawn) {
+
+#ifdef HAVE_GETUID
+        if (!c->conf->allow_autospawn_for_root && getuid() == 0)
+            pa_log_debug("Not doing autospawn since we are root.");
+        else {
+            c->do_autospawn = true;
+
+            if (api)
+                c->spawn_api = *api;
+        }
+#endif
+    }
+
+    pa_context_set_state(c, PA_CONTEXT_CONNECTING);
+    r = try_next_connection(c);
+
+finish:
+    pa_context_unref(c);
+
+    return r;
+}
+
+void pa_context_disconnect(pa_context *c) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    if (pa_detect_fork())
+        return;
+
+    if (PA_CONTEXT_IS_GOOD(c->state))
+        pa_context_set_state(c, PA_CONTEXT_TERMINATED);
+}
+
+pa_context_state_t pa_context_get_state(const pa_context *c) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    return c->state;
+}
+
+int pa_context_errno(const pa_context *c) {
+
+    if (!c)
+        return PA_ERR_INVALID;
+
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    return c->error->error;
+}
+
+void pa_context_set_state_callback(pa_context *c, pa_context_notify_cb_t cb, void *userdata) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    if (pa_detect_fork())
+        return;
+
+    if (c->state == PA_CONTEXT_TERMINATED || c->state == PA_CONTEXT_FAILED)
+        return;
+
+    c->state_callback = cb;
+    c->state_userdata = userdata;
+}
+
+void pa_context_set_event_callback(pa_context *c, pa_context_event_cb_t cb, void *userdata) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    if (pa_detect_fork())
+        return;
+
+    if (c->state == PA_CONTEXT_TERMINATED || c->state == PA_CONTEXT_FAILED)
+        return;
+
+    c->event_callback = cb;
+    c->event_userdata = userdata;
+}
+
+int pa_context_is_pending(const pa_context *c) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY(c, !pa_detect_fork(), PA_ERR_FORKED);
+    PA_CHECK_VALIDITY(c, PA_CONTEXT_IS_GOOD(c->state), PA_ERR_BADSTATE);
+
+    return (c->pstream && pa_pstream_is_pending(c->pstream)) ||
+        (c->pdispatch && pa_pdispatch_is_pending(c->pdispatch)) ||
+        c->client;
+}
+
+static void set_dispatch_callbacks(pa_operation *o);
+
+static void pdispatch_drain_callback(pa_pdispatch*pd, void *userdata) {
+    set_dispatch_callbacks(userdata);
+}
+
+static void pstream_drain_callback(pa_pstream *s, void *userdata) {
+    set_dispatch_callbacks(userdata);
+}
+
+static void set_dispatch_callbacks(pa_operation *o) {
+    int done = 1;
+
+    pa_assert(o);
+    pa_assert(PA_REFCNT_VALUE(o) >= 1);
+    pa_assert(o->context);
+    pa_assert(PA_REFCNT_VALUE(o->context) >= 1);
+    pa_assert(o->context->state == PA_CONTEXT_READY);
+
+    pa_pstream_set_drain_callback(o->context->pstream, NULL, NULL);
+    pa_pdispatch_set_drain_callback(o->context->pdispatch, NULL, NULL);
+
+    if (pa_pdispatch_is_pending(o->context->pdispatch)) {
+        pa_pdispatch_set_drain_callback(o->context->pdispatch, pdispatch_drain_callback, o);
+        done = 0;
+    }
+
+    if (pa_pstream_is_pending(o->context->pstream)) {
+        pa_pstream_set_drain_callback(o->context->pstream, pstream_drain_callback, o);
+        done = 0;
+    }
+
+    if (done) {
+        if (o->callback) {
+            pa_context_notify_cb_t cb = (pa_context_notify_cb_t) o->callback;
+            cb(o->context, o->userdata);
+        }
+
+        pa_operation_done(o);
+        pa_operation_unref(o);
+    }
+}
+
+pa_operation* pa_context_drain(pa_context *c, pa_context_notify_cb_t cb, void *userdata) {
+    pa_operation *o;
+
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, pa_context_is_pending(c), PA_ERR_BADSTATE);
+
+    o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
+    set_dispatch_callbacks(pa_operation_ref(o));
+
+    return o;
+}
+
+void pa_context_simple_ack_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
+    pa_operation *o = userdata;
+    int success = 1;
+
+    pa_assert(pd);
+    pa_assert(o);
+    pa_assert(PA_REFCNT_VALUE(o) >= 1);
+
+    if (!o->context)
+        goto finish;
+
+    if (command != PA_COMMAND_REPLY) {
+        if (pa_context_handle_error(o->context, command, t, false) < 0)
+            goto finish;
+
+        success = 0;
+    } else if (!pa_tagstruct_eof(t)) {
+        pa_context_fail(o->context, PA_ERR_PROTOCOL);
+        goto finish;
+    }
+
+    if (o->callback) {
+        pa_context_success_cb_t cb = (pa_context_success_cb_t) o->callback;
+        cb(o->context, success, o->userdata);
+    }
+
+finish:
+    pa_operation_done(o);
+    pa_operation_unref(o);
+}
+
+pa_operation* pa_context_send_simple_command(pa_context *c, uint32_t command, pa_pdispatch_cb_t internal_cb, pa_operation_cb_t cb, void *userdata) {
+    pa_tagstruct *t;
+    pa_operation *o;
+    uint32_t tag;
+
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
+
+    o = pa_operation_new(c, NULL, cb, userdata);
+
+    t = pa_tagstruct_command(c, command, &tag);
+    pa_pstream_send_tagstruct(c->pstream, t);
+    pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, internal_cb, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
+
+    return o;
+}
+
+pa_operation* pa_context_exit_daemon(pa_context *c, pa_context_success_cb_t cb, void *userdata) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    return pa_context_send_simple_command(c, PA_COMMAND_EXIT, pa_context_simple_ack_callback, (pa_operation_cb_t) cb, userdata);
+}
+
+pa_operation* pa_context_set_default_sink(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata) {
+    pa_tagstruct *t;
+    pa_operation *o;
+    uint32_t tag;
+
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
+
+    o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
+    t = pa_tagstruct_command(c, PA_COMMAND_SET_DEFAULT_SINK, &tag);
+    pa_tagstruct_puts(t, name);
+    pa_pstream_send_tagstruct(c->pstream, t);
+    pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT,  pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
+
+    return o;
+}
+
+pa_operation* pa_context_set_default_source(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata) {
+    pa_tagstruct *t;
+    pa_operation *o;
+    uint32_t tag;
+
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
+
+    o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
+    t = pa_tagstruct_command(c, PA_COMMAND_SET_DEFAULT_SOURCE, &tag);
+    pa_tagstruct_puts(t, name);
+    pa_pstream_send_tagstruct(c->pstream, t);
+    pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT,  pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
+
+    return o;
+}
+
+int pa_context_is_local(const pa_context *c) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY_RETURN_ANY(c, !pa_detect_fork(), PA_ERR_FORKED, -1);
+    PA_CHECK_VALIDITY_RETURN_ANY(c, PA_CONTEXT_IS_GOOD(c->state), PA_ERR_BADSTATE, -1);
+
+    return c->is_local;
+}
+
+pa_operation* pa_context_set_name(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata) {
+    pa_operation *o;
+
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+    pa_assert(name);
+
+    PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
+
+    if (c->version >= 13) {
+        pa_proplist *p = pa_proplist_new();
+
+        pa_proplist_sets(p, PA_PROP_APPLICATION_NAME, name);
+        o = pa_context_proplist_update(c, PA_UPDATE_REPLACE, p, cb, userdata);
+        pa_proplist_free(p);
+    } else {
+        pa_tagstruct *t;
+        uint32_t tag;
+
+        o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
+        t = pa_tagstruct_command(c, PA_COMMAND_SET_CLIENT_NAME, &tag);
+        pa_tagstruct_puts(t, name);
+        pa_pstream_send_tagstruct(c->pstream, t);
+        pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT,  pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
+    }
+
+    return o;
+}
+
+const char* pa_get_library_version(void) {
+    return pa_get_headers_version();
+}
+
+const char* pa_context_get_server(const pa_context *c) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, c->server, PA_ERR_NOENTITY);
+
+    if (*c->server == '{') {
+        char *e = strchr(c->server+1, '}');
+        return e ? e+1 : c->server;
+    }
+
+    return c->server;
+}
+
+uint32_t pa_context_get_protocol_version(const pa_context *c) {
+    return PA_PROTOCOL_VERSION;
+}
+
+uint32_t pa_context_get_server_protocol_version(const pa_context *c) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY_RETURN_ANY(c, !pa_detect_fork(), PA_ERR_FORKED, PA_INVALID_INDEX);
+    PA_CHECK_VALIDITY_RETURN_ANY(c, PA_CONTEXT_IS_GOOD(c->state), PA_ERR_BADSTATE, PA_INVALID_INDEX);
+
+    return c->version;
+}
+
+pa_tagstruct *pa_tagstruct_command(pa_context *c, uint32_t command, uint32_t *tag) {
+    pa_tagstruct *t;
+
+    pa_assert(c);
+    pa_assert(tag);
+
+    t = pa_tagstruct_new();
+    pa_tagstruct_putu32(t, command);
+    pa_tagstruct_putu32(t, *tag = c->ctag++);
+
+    return t;
+}
+
+uint32_t pa_context_get_index(const pa_context *c) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY_RETURN_ANY(c, !pa_detect_fork(), PA_ERR_FORKED, PA_INVALID_INDEX);
+    PA_CHECK_VALIDITY_RETURN_ANY(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE, PA_INVALID_INDEX);
+    PA_CHECK_VALIDITY_RETURN_ANY(c, c->version >= 13, PA_ERR_NOTSUPPORTED, PA_INVALID_INDEX);
+
+    return c->client_index;
+}
+
+pa_operation *pa_context_proplist_update(pa_context *c, pa_update_mode_t mode, const pa_proplist *p, pa_context_success_cb_t cb, void *userdata) {
+    pa_operation *o;
+    pa_tagstruct *t;
+    uint32_t tag;
+
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, mode == PA_UPDATE_SET || mode == PA_UPDATE_MERGE || mode == PA_UPDATE_REPLACE, PA_ERR_INVALID);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 13, PA_ERR_NOTSUPPORTED);
+
+    o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
+
+    t = pa_tagstruct_command(c, PA_COMMAND_UPDATE_CLIENT_PROPLIST, &tag);
+    pa_tagstruct_putu32(t, (uint32_t) mode);
+    pa_tagstruct_put_proplist(t, p);
+
+    pa_pstream_send_tagstruct(c->pstream, t);
+    pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
+
+    /* Please note that we don't update c->proplist here, because we
+     * don't export that field */
+
+    return o;
+}
+
+pa_operation *pa_context_proplist_remove(pa_context *c, const char *const keys[], pa_context_success_cb_t cb, void *userdata) {
+    pa_operation *o;
+    pa_tagstruct *t;
+    uint32_t tag;
+    const char * const *k;
+
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, keys && keys[0], PA_ERR_INVALID);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
+    PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 13, PA_ERR_NOTSUPPORTED);
+
+    o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
+
+    t = pa_tagstruct_command(c, PA_COMMAND_REMOVE_CLIENT_PROPLIST, &tag);
+
+    for (k = keys; *k; k++)
+        pa_tagstruct_puts(t, *k);
+
+    pa_tagstruct_puts(t, NULL);
+
+    pa_pstream_send_tagstruct(c->pstream, t);
+    pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
+
+    /* Please note that we don't update c->proplist here, because we
+     * don't export that field */
+
+    return o;
+}
+
+void pa_command_extension(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
+    pa_context *c = userdata;
+    uint32_t idx;
+    const char *name;
+
+    pa_assert(pd);
+    pa_assert(command == PA_COMMAND_EXTENSION);
+    pa_assert(t);
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    pa_context_ref(c);
+
+    if (c->version < 15) {
+        pa_context_fail(c, PA_ERR_PROTOCOL);
+        goto finish;
+    }
+
+    if (pa_tagstruct_getu32(t, &idx) < 0 ||
+        pa_tagstruct_gets(t, &name) < 0) {
+        pa_context_fail(c, PA_ERR_PROTOCOL);
+        goto finish;
+    }
+
+    if (pa_streq(name, "module-device-manager"))
+        pa_ext_device_manager_command(c, tag, t);
+    else if (pa_streq(name, "module-device-restore"))
+        pa_ext_device_restore_command(c, tag, t);
+    else if (pa_streq(name, "module-stream-restore"))
+        pa_ext_stream_restore_command(c, tag, t);
+    else
+        pa_log(_("Received message for unknown extension '%s'"), name);
+
+finish:
+    pa_context_unref(c);
+}
+
+static void pa_command_enable_srbchannel(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
+    pa_context *c = userdata;
+
+#ifdef HAVE_CREDS
+    pa_cmsg_ancil_data *ancil = NULL;
+
+    pa_assert(pd);
+    pa_assert(command == PA_COMMAND_ENABLE_SRBCHANNEL);
+    pa_assert(t);
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    ancil = pa_pdispatch_take_ancil_data(pd);
+    if (!ancil)
+        goto fail;
+
+    /* Currently only one srb channel is supported, might change in future versions */
+    if (c->srb_template.readfd != -1)
+        goto fail;
+
+    if (ancil->nfd != 2 || ancil->fds[0] == -1 || ancil->fds[1] == -1)
+        goto fail;
+
+    pa_context_ref(c);
+
+    c->srb_template.readfd = ancil->fds[0];
+    c->srb_template.writefd = ancil->fds[1];
+    c->srb_setup_tag = tag;
+
+    pa_context_unref(c);
+
+    ancil->close_fds_on_cleanup = false;
+    return;
+
+fail:
+    if (ancil)
+        pa_cmsg_ancil_data_close_fds(ancil);
+
+    pa_context_fail(c, PA_ERR_PROTOCOL);
+    return;
+#else
+    pa_assert(c);
+    pa_context_fail(c, PA_ERR_PROTOCOL);
+#endif
+}
+
+static void pa_command_disable_srbchannel(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
+    pa_context *c = userdata;
+    pa_tagstruct *t2;
+
+    pa_assert(pd);
+    pa_assert(command == PA_COMMAND_DISABLE_SRBCHANNEL);
+    pa_assert(t);
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    pa_pstream_set_srbchannel(c->pstream, NULL);
+
+    c->srb_template.readfd = -1;
+    c->srb_template.writefd = -1;
+    if (c->srb_template.memblock) {
+        pa_memblock_unref(c->srb_template.memblock);
+        c->srb_template.memblock = NULL;
+    }
+
+    /* Send disable command back again */
+    t2 = pa_tagstruct_new();
+    pa_tagstruct_putu32(t2, PA_COMMAND_DISABLE_SRBCHANNEL);
+    pa_tagstruct_putu32(t2, tag);
+    pa_pstream_send_tagstruct(c->pstream, t2);
+}
+
+static void pa_command_register_memfd_shmid(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
+    pa_context *c = userdata;
+
+    pa_assert(pd);
+    pa_assert(command == PA_COMMAND_REGISTER_MEMFD_SHMID);
+    pa_assert(t);
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    if (pa_common_command_register_memfd_shmid(c->pstream, pd, c->version, command, t))
+        pa_context_fail(c, PA_ERR_PROTOCOL);
+}
+
+void pa_command_client_event(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
+    pa_context *c = userdata;
+    pa_proplist *pl = NULL;
+    const char *event;
+
+    pa_assert(pd);
+    pa_assert(command == PA_COMMAND_CLIENT_EVENT);
+    pa_assert(t);
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    pa_context_ref(c);
+
+    if (c->version < 15) {
+        pa_context_fail(c, PA_ERR_PROTOCOL);
+        goto finish;
+    }
+
+    pl = pa_proplist_new();
+
+    if (pa_tagstruct_gets(t, &event) < 0 ||
+        pa_tagstruct_get_proplist(t, pl) < 0 ||
+        !pa_tagstruct_eof(t) || !event) {
+        pa_context_fail(c, PA_ERR_PROTOCOL);
+        goto finish;
+    }
+
+    if (c->event_callback)
+        c->event_callback(c, event, pl, c->event_userdata);
+
+finish:
+    pa_context_unref(c);
+
+    if (pl)
+        pa_proplist_free(pl);
+}
+
+pa_time_event* pa_context_rttime_new(const pa_context *c, pa_usec_t usec, pa_time_event_cb_t cb, void *userdata) {
+    struct timeval tv;
+
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+    pa_assert(c->mainloop);
+
+    if (usec == PA_USEC_INVALID)
+        return c->mainloop->time_new(c->mainloop, NULL, cb, userdata);
+
+    pa_timeval_rtstore(&tv, usec, c->use_rtclock);
+
+    return c->mainloop->time_new(c->mainloop, &tv, cb, userdata);
+}
+
+void pa_context_rttime_restart(const pa_context *c, pa_time_event *e, pa_usec_t usec) {
+    struct timeval tv;
+
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+    pa_assert(c->mainloop);
+
+    if (usec == PA_USEC_INVALID)
+        c->mainloop->time_restart(e, NULL);
+    else {
+        pa_timeval_rtstore(&tv, usec, c->use_rtclock);
+        c->mainloop->time_restart(e, &tv);
+    }
+}
+
+size_t pa_context_get_tile_size(const pa_context *c, const pa_sample_spec *ss) {
+    size_t fs, mbs;
+
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY_RETURN_ANY(c, !pa_detect_fork(), PA_ERR_FORKED, (size_t) -1);
+    PA_CHECK_VALIDITY_RETURN_ANY(c, !ss || pa_sample_spec_valid(ss), PA_ERR_INVALID, (size_t) -1);
+
+    fs = ss ? pa_frame_size(ss) : 1;
+    mbs = PA_ROUND_DOWN(pa_mempool_block_size_max(c->mempool), fs);
+    return PA_MAX(mbs, fs);
+}
+
+int pa_context_load_cookie_from_file(pa_context *c, const char *cookie_file_path) {
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY(c, !pa_detect_fork(), PA_ERR_FORKED);
+    PA_CHECK_VALIDITY(c, c->state == PA_CONTEXT_UNCONNECTED, PA_ERR_BADSTATE);
+    PA_CHECK_VALIDITY(c, !cookie_file_path || *cookie_file_path, PA_ERR_INVALID);
+
+    pa_client_conf_set_cookie_file_from_application(c->conf, cookie_file_path);
+
+    return 0;
+}
Index: create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse
===================================================================
--- create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse	(nonexistent)
+++ create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse	(revision 5)

Property changes on: create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src/pulse
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src
===================================================================
--- create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src	(nonexistent)
+++ create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src	(revision 5)

Property changes on: create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new
===================================================================
--- create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new	(nonexistent)
+++ create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new	(revision 5)

Property changes on: create-16.1-autospawn-for-root-patch/pulseaudio-16.1-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-autospawn-for-root-patch
===================================================================
--- create-16.1-autospawn-for-root-patch	(nonexistent)
+++ create-16.1-autospawn-for-root-patch	(revision 5)

Property changes on: create-16.1-autospawn-for-root-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-autostart-patch/create.patch.sh
===================================================================
--- create-16.1-autostart-patch/create.patch.sh	(nonexistent)
+++ create-16.1-autostart-patch/create.patch.sh	(revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=16.1
+
+tar --files-from=file.list -xJvf ../pulseaudio-$VERSION.tar.xz
+mv pulseaudio-$VERSION pulseaudio-$VERSION-orig
+
+cp -rf ./pulseaudio-$VERSION-new ./pulseaudio-$VERSION
+
+diff --unified -Nr  pulseaudio-$VERSION-orig  pulseaudio-$VERSION > pulseaudio-$VERSION-autostart.patch
+
+mv pulseaudio-$VERSION-autostart.patch ../patches
+
+rm -rf ./pulseaudio-$VERSION
+rm -rf ./pulseaudio-$VERSION-orig

Property changes on: create-16.1-autostart-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-16.1-autostart-patch/file.list
===================================================================
--- create-16.1-autostart-patch/file.list	(nonexistent)
+++ create-16.1-autostart-patch/file.list	(revision 5)
@@ -0,0 +1,2 @@
+pulseaudio-16.1/src/daemon/meson.build
+pulseaudio-16.1/src/daemon/start-pulseaudio-x11.in
Index: create-16.1-autostart-patch/pulseaudio-16.1-new/src/daemon/meson.build
===================================================================
--- create-16.1-autostart-patch/pulseaudio-16.1-new/src/daemon/meson.build	(nonexistent)
+++ create-16.1-autostart-patch/pulseaudio-16.1-new/src/daemon/meson.build	(revision 5)
@@ -0,0 +1,174 @@
+pulseaudio_sources = [
+  'caps.c',
+  'cmdline.c',
+  'cpulimit.c',
+  'daemon-conf.c',
+  'dumpmodules.c',
+  'ltdl-bind-now.c',
+  'main.c',
+]
+
+pulseaudio_headers = [
+  'caps.h',
+  'cmdline.h',
+  'cpulimit.h',
+  'daemon-conf.h',
+  'dumpmodules.h',
+  'ltdl-bind-now.h',
+]
+
+if dbus_dep.found()
+  pulseaudio_sources += 'server-lookup.c'
+  pulseaudio_headers += 'server-lookup.h'
+endif
+
+# FIXME: dependencies
+executable('pulseaudio',
+  pulseaudio_sources,
+  pulseaudio_headers,
+  install: true,
+  install_rpath : privlibdir,
+  include_directories : [configinc, topinc],
+  link_args : ['-ffast-math'],
+  link_with : [libpulsecore],
+  dependencies : [ltdl_dep, cap_dep, dbus_dep, libsystemd_dep, dl_dep, libintl_dep, platform_dep, platform_socket_dep, libpulsecommon_dep, libpulse_dep],
+  c_args : pa_c_args,
+)
+
+if x11_dep.found()
+  conf = configuration_data()
+  conf.set('PACTL_BINARY', join_paths(bindir, 'pactl'))
+  conf.set('PA_BINARY', join_paths(bindir, 'pulseaudio'))
+
+  configure_file(
+    input : 'start-pulseaudio-x11.in',
+    output : 'start-pulseaudio-x11',
+    configuration : conf,
+    install : true,
+    install_dir : bindir,
+  )
+
+  configure_file(
+    input : 'start-pulseaudio-x11.in',
+    output : '00-pulseaudio-x11',
+    configuration : conf,
+    install : true,
+    install_dir : join_paths(sysconfdir, 'xdg', 'Xwayland-session.d'),
+  )
+
+  desktop_file = i18n.merge_file(
+    input : 'pulseaudio.desktop.in',
+    output : 'pulseaudio.desktop',
+    po_dir : po_dir,
+    type : 'desktop',
+    install : true,
+    install_dir : join_paths(sysconfdir, 'xdg', 'autostart'),
+  )
+
+  desktop_utils = find_program('desktop-file-validate', required: false)
+  if desktop_utils.found()
+    test('Validate desktop file', desktop_utils,
+      args: [ desktop_file ],
+    )
+  endif
+endif
+
+# Configuration files
+
+m4 = find_program('m4', required: true)
+
+daemon_conf = configuration_data()
+daemon_conf.merge_from(cdata)
+daemon_conf.set('PA_DEFAULT_CONFIG_DIR', cdata.get_unquoted('PA_DEFAULT_CONFIG_DIR'))
+
+daemon_template_file = configure_file(
+  input : 'daemon.conf.in',
+  output : 'daemon.conf.tmp',
+  configuration : daemon_conf,
+)
+
+custom_target('daemon.conf',
+  input : daemon_template_file,
+  output : 'daemon.conf',
+  capture : true,
+  command : [m4, '@INPUT@'],
+  build_by_default : true,
+  install : true,
+  install_dir : pulsesysconfdir,
+)
+
+default_conf = configuration_data()
+default_conf.merge_from(cdata)
+default_conf.set('PA_BINARY', cdata.get_unquoted('PA_BINARY'))
+default_conf.set('PA_SOEXT', cdata.get_unquoted('PA_SOEXT'))
+default_conf.set10('HAVE_AF_UNIX', cc.has_header('sys/un.h') ? true : cc.has_header('winsock2.h'))
+default_conf.set10('OS_IS_WIN32', host_machine.system() == 'windows')
+default_conf.set10('HAVE_MKFIFO', cc.has_function('mkfifo'))
+
+default_template_file = configure_file(
+  input : 'default.pa.in',
+  output : 'default.pa.tmp',
+  configuration : default_conf,
+)
+
+custom_target('default.pa',
+  input : default_template_file,
+  output : 'default.pa',
+  capture : true,
+  command : [m4, '@INPUT@'],
+  build_by_default : true,
+  install : true,
+  install_dir : pulsesysconfdir,
+)
+
+system_conf = configuration_data()
+system_conf.merge_from(default_conf)
+
+system_template_file = configure_file(
+  input : 'system.pa.in',
+  output : 'system.pa.tmp',
+  configuration : system_conf,
+)
+
+custom_target('system.pa',
+  input : system_template_file,
+  output : 'system.pa',
+  capture : true,
+  command : [m4, '@INPUT@'],
+  build_by_default : true,
+  install : true,
+  install_dir : pulsesysconfdir,
+)
+
+if dbus_dep.found()
+  install_data('pulseaudio-system.conf',
+    install_dir : join_paths(sysconfdir, 'dbus-1', 'system.d')
+  )
+endif
+
+if systemd_dep.found()
+  sd_user_service_conf = configuration_data()
+  sd_user_service_conf.set('PA_BINARY', cdata.get_unquoted('PA_BINARY'))
+  sd_user_service_conf.set('PACTL_BINARY', join_paths(bindir, 'pactl'))
+  sd_user_service_conf.set('PA_X11_BINARY', join_paths(bindir, 'start-pulseaudio-x11'))
+
+  sd_user_service_file = configure_file(
+    input : 'systemd/user/pulseaudio.service.in',
+    output : 'pulseaudio.service',
+    configuration : sd_user_service_conf,
+    install : true,
+    install_dir : systemduserunitdir,
+  )
+
+  sd_user_x11_service_file = configure_file(
+    input : 'systemd/user/pulseaudio-x11.service.in',
+    output : 'pulseaudio-x11.service',
+    configuration : sd_user_service_conf,
+    install : true,
+    install_dir : systemduserunitdir,
+  )
+
+  install_data('systemd/user/pulseaudio.socket',
+    install_dir: systemduserunitdir,
+  )
+endif
Index: create-16.1-autostart-patch/pulseaudio-16.1-new/src/daemon/start-pulseaudio-x11.in
===================================================================
--- create-16.1-autostart-patch/pulseaudio-16.1-new/src/daemon/start-pulseaudio-x11.in	(nonexistent)
+++ create-16.1-autostart-patch/pulseaudio-16.1-new/src/daemon/start-pulseaudio-x11.in	(revision 5)
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+# This file is part of PulseAudio.
+#
+# 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, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+if [ -n "$1" ] ; then
+    case $1 in
+    stop)
+      @PACTL_BINARY@ unload-module module-x11-publish > /dev/null
+      @PACTL_BINARY@ unload-module module-x11-cork-request > /dev/null
+      @PACTL_BINARY@ unload-module module-device-manager > /dev/null
+      @PACTL_BINARY@ unload-module module-x11-xsmp > /dev/null
+      exit 0
+      ;;
+    start)
+      # Let it continue further down
+      ;;
+    *)
+      echo "Unknown argument $1"
+      exit 1
+      ;;
+    esac
+fi
+
+# probe to test if autospawn works, else resort to starting manually
+@PACTL_BINARY@ info > /dev/null 2>&1 || @PA_BINARY@ --start "$@"
+
+if [ x"$DISPLAY" != x ] ; then
+
+    @PACTL_BINARY@ load-module module-x11-publish "display=$DISPLAY xauthority=$XAUTHORITY" > /dev/null
+    @PACTL_BINARY@ load-module module-x11-cork-request "display=$DISPLAY xauthority=$XAUTHORITY" > /dev/null
+
+    # KDE plasma versions older than 5.17.0 use module-device-manager's routing API.
+    # Check for current plasma version and load module if it's necessary.
+    if [ x"$KDE_FULL_SESSION" = x"true" ]; then
+        plasmaversion="$(plasmashell -v 2>/dev/null | sed -n 's/^plasmashell \([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)/\1*1000000+\2*1000+\3/p' | head -1)"
+        if [ -n "$plasmaversion" ] && [ "$(($plasmaversion))" -lt "5017000" ]; then
+            @PACTL_BINARY@ load-module module-device-manager "do_routing=1" > /dev/null
+        fi
+    fi
+
+    if [ x"$SESSION_MANAGER" != x ] ; then
+	@PACTL_BINARY@ load-module module-x11-xsmp "display=$DISPLAY xauthority=$XAUTHORITY session_manager=$SESSION_MANAGER" > /dev/null
+    fi
+fi

Property changes on: create-16.1-autostart-patch/pulseaudio-16.1-new/src/daemon/start-pulseaudio-x11.in
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-16.1-autostart-patch/pulseaudio-16.1-new/src/daemon
===================================================================
--- create-16.1-autostart-patch/pulseaudio-16.1-new/src/daemon	(nonexistent)
+++ create-16.1-autostart-patch/pulseaudio-16.1-new/src/daemon	(revision 5)

Property changes on: create-16.1-autostart-patch/pulseaudio-16.1-new/src/daemon
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-autostart-patch/pulseaudio-16.1-new/src
===================================================================
--- create-16.1-autostart-patch/pulseaudio-16.1-new/src	(nonexistent)
+++ create-16.1-autostart-patch/pulseaudio-16.1-new/src	(revision 5)

Property changes on: create-16.1-autostart-patch/pulseaudio-16.1-new/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-autostart-patch/pulseaudio-16.1-new
===================================================================
--- create-16.1-autostart-patch/pulseaudio-16.1-new	(nonexistent)
+++ create-16.1-autostart-patch/pulseaudio-16.1-new	(revision 5)

Property changes on: create-16.1-autostart-patch/pulseaudio-16.1-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-autostart-patch
===================================================================
--- create-16.1-autostart-patch	(nonexistent)
+++ create-16.1-autostart-patch	(revision 5)

Property changes on: create-16.1-autostart-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-no-root-warn-patch/create.patch.sh
===================================================================
--- create-16.1-no-root-warn-patch/create.patch.sh	(nonexistent)
+++ create-16.1-no-root-warn-patch/create.patch.sh	(revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=16.1
+
+tar --files-from=file.list -xJvf ../pulseaudio-$VERSION.tar.xz
+mv pulseaudio-$VERSION pulseaudio-$VERSION-orig
+
+cp -rf ./pulseaudio-$VERSION-new ./pulseaudio-$VERSION
+
+diff --unified -Nr  pulseaudio-$VERSION-orig  pulseaudio-$VERSION > pulseaudio-$VERSION-no-root-warn.patch
+
+mv pulseaudio-$VERSION-no-root-warn.patch ../patches
+
+rm -rf ./pulseaudio-$VERSION
+rm -rf ./pulseaudio-$VERSION-orig

Property changes on: create-16.1-no-root-warn-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-16.1-no-root-warn-patch/file.list
===================================================================
--- create-16.1-no-root-warn-patch/file.list	(nonexistent)
+++ create-16.1-no-root-warn-patch/file.list	(revision 5)
@@ -0,0 +1 @@
+pulseaudio-16.1/src/daemon/main.c
Index: create-16.1-no-root-warn-patch/pulseaudio-16.1-new/src/daemon/main.c
===================================================================
--- create-16.1-no-root-warn-patch/pulseaudio-16.1-new/src/daemon/main.c	(nonexistent)
+++ create-16.1-no-root-warn-patch/pulseaudio-16.1-new/src/daemon/main.c	(revision 5)
@@ -0,0 +1,1436 @@
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2004-2006 Lennart Poettering
+  Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
+
+  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.1 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, see <http://www.gnu.org/licenses/>.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <signal.h>
+#include <stddef.h>
+#include <ltdl.h>
+#include <limits.h>
+#include <unistd.h>
+#include <locale.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+#ifdef HAVE_GRP_H
+#include <grp.h>
+#endif
+
+#ifdef HAVE_LIBWRAP
+#include <syslog.h>
+#include <tcpd.h>
+#endif
+
+#ifdef HAVE_DBUS
+#include <dbus/dbus.h>
+#endif
+
+#ifdef HAVE_SYSTEMD_DAEMON
+#include <systemd/sd-daemon.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#include <aclapi.h>
+#include <sddl.h>
+#endif
+
+#include <pulse/client-conf.h>
+#include <pulse/mainloop.h>
+#include <pulse/mainloop-signal.h>
+#include <pulse/timeval.h>
+#include <pulse/xmalloc.h>
+
+#include <pulsecore/i18n.h>
+#include <pulsecore/lock-autospawn.h>
+#include <pulsecore/socket.h>
+#include <pulsecore/core-error.h>
+#include <pulsecore/core-rtclock.h>
+#include <pulsecore/core-scache.h>
+#include <pulsecore/core.h>
+#include <pulsecore/module.h>
+#include <pulsecore/cli-command.h>
+#include <pulsecore/log.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/sioman.h>
+#include <pulsecore/cli-text.h>
+#include <pulsecore/pid.h>
+#include <pulsecore/random.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/shm.h>
+#include <pulsecore/memtrap.h>
+#include <pulsecore/strlist.h>
+#ifdef HAVE_DBUS
+#include <pulsecore/dbus-shared.h>
+#endif
+#include <pulsecore/cpu.h>
+
+#include "cmdline.h"
+#include "cpulimit.h"
+#include "daemon-conf.h"
+#include "dumpmodules.h"
+#include "caps.h"
+#include "ltdl-bind-now.h"
+#include "server-lookup.h"
+
+#ifdef DISABLE_LIBTOOL_PRELOAD
+/* FIXME: work around a libtool bug by making sure we have 2 elements. Bug has
+ * been reported: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29576 */
+LT_DLSYM_CONST lt_dlsymlist lt_preloaded_symbols[] = {
+    { "@PROGRAM@", NULL },
+    { NULL, NULL }
+};
+#endif
+
+#ifdef HAVE_LIBWRAP
+/* Only one instance of these variables */
+int allow_severity = LOG_INFO;
+int deny_severity = LOG_WARNING;
+#endif
+
+#ifdef HAVE_OSS_WRAPPER
+/* padsp looks for this symbol in the running process and disables
+ * itself if it finds it and it is set to 7 (which is actually a bit
+ * mask). For details see padsp. */
+int __padsp_disabled__ = 7;
+#endif
+
+static void signal_callback(pa_mainloop_api* m, pa_signal_event *e, int sig, void *userdata) {
+    pa_module *module = NULL;
+
+    pa_log_info("Got signal %s.", pa_sig2str(sig));
+
+    switch (sig) {
+#ifdef SIGUSR1
+        case SIGUSR1:
+            pa_module_load(&module, userdata, "module-cli", NULL);
+            break;
+#endif
+
+#ifdef SIGUSR2
+        case SIGUSR2:
+            pa_module_load(&module, userdata, "module-cli-protocol-unix", NULL);
+            break;
+#endif
+
+#ifdef SIGHUP
+        case SIGHUP: {
+            char *c = pa_full_status_string(userdata);
+            pa_log_notice("%s", c);
+            pa_xfree(c);
+            return;
+        }
+#endif
+
+        case SIGINT:
+        case SIGTERM:
+        default:
+            pa_log_info("Exiting.");
+            m->quit(m, 0);
+            break;
+    }
+}
+
+
+#if defined(OS_IS_WIN32)
+
+static int change_user(void) {
+    pa_log_info("Overriding system runtime/config base dir to '%s'.", pa_win32_get_system_appdata());
+
+    /* On other platforms, these paths are compiled into PulseAudio. This isn't
+     * suitable on Windows. Firstly, Windows doesn't follow the FHS or use Unix
+     * paths and the build system can't handle Windows-style paths properly.
+     * Secondly, the idiomatic location for a service's state and shared data is
+     * ProgramData, and the location of special folders is dynamic on Windows.
+     * Also, this method of handling paths is consistent with how they are
+     * handled on Windows in other parts of PA. Note that this is only needed
+     * in system-wide mode since paths in user instances are already handled
+     * properly.
+     */
+
+    char *run_path = pa_sprintf_malloc("%s" PA_PATH_SEP "run", pa_win32_get_system_appdata());
+    char *lib_path = pa_sprintf_malloc("%s" PA_PATH_SEP "lib", pa_win32_get_system_appdata());
+
+    /* https://docs.microsoft.com/en-us/windows/win32/secauthz/ace-strings */
+    /* https://docs.microsoft.com/en-us/windows/win32/secauthz/modifying-the-acls-of-an-object-in-c-- */
+    /* https://docs.microsoft.com/en-us/windows/win32/api/sddl/nf-sddl-convertstringsecuritydescriptortosecuritydescriptora */
+    {
+        mkdir(run_path);
+        PSECURITY_DESCRIPTOR sd;
+        if (ConvertStringSecurityDescriptorToSecurityDescriptorA(
+            "D:PAI"                   /* DACL, disable inheritance from parent, enable propagation to children */
+            "(A;OICI;FA;;;SY)"        /* give system full access */
+            "(A;OICI;FA;;;CO)"        /* give owner full access */
+            "(A;OICI;FA;;;BA)"        /* give administrators full access */
+            "(A;OICI;0x1200a9;;;WD)", /* give everyone read/write/execute access */
+            SDDL_REVISION_1, &sd, NULL
+        )) {
+            PACL acl;
+            BOOL acl_present, acl_default;
+            if (GetSecurityDescriptorDacl(sd, &acl_present, &acl, &acl_default)) {
+                if (SetNamedSecurityInfo(run_path, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION | PROTECTED_DACL_SECURITY_INFORMATION, NULL, NULL, acl, NULL) != ERROR_SUCCESS) {
+                    pa_log_warn("Failed to set DACL for runtime dir: failed to apply DACL: error %lu.", GetLastError());
+                }
+                LocalFree(acl);
+            } else {
+                pa_log_warn("Failed to set DACL for runtime dir: failed to get security descriptor DACL: error %lu.", GetLastError());
+            }
+        } else {
+            pa_log_warn("Failed to set DACL for runtime dir: failed to parse security descriptor: error %lu.", GetLastError());
+        }
+    }
+    {
+        mkdir(lib_path);
+        PSECURITY_DESCRIPTOR sd;
+        if (ConvertStringSecurityDescriptorToSecurityDescriptorA(
+            "D:PAI"             /* DACL, disable inheritance from parent, enable propagation to children */
+            "(A;OICI;FA;;;SY)"  /* give system full access */
+            "(A;OICI;FA;;;CO)"  /* give owner full access */
+            "(A;OICI;FA;;;BA)", /* give administrators full access */
+            SDDL_REVISION_1, &sd, NULL
+        )) {
+            PACL acl;
+            BOOL acl_present, acl_default;
+            if (GetSecurityDescriptorDacl(sd, &acl_present, &acl, &acl_default)) {
+                if (SetNamedSecurityInfo(lib_path, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION | PROTECTED_DACL_SECURITY_INFORMATION, NULL, NULL, acl, NULL) != ERROR_SUCCESS) {
+                    pa_log_warn("Failed to set DACL for lib dir: failed to apply DACL: error %lu.", GetLastError());
+                }
+                LocalFree(acl);
+            } else {
+                pa_log_warn("Failed to set DACL for lib dir: failed to get security descriptor DACL: error %lu.", GetLastError());
+            }
+        } else {
+            pa_log_warn("Failed to set DACL for lib dir: failed to parse security descriptor: error %lu.", GetLastError());
+        }
+    }
+
+    pa_set_env("HOME", run_path);
+    if (!getenv("PULSE_RUNTIME_PATH"))
+        pa_set_env("PULSE_RUNTIME_PATH", run_path);
+    if (!getenv("PULSE_CONFIG_PATH"))
+        pa_set_env("PULSE_CONFIG_PATH", lib_path);
+    if (!getenv("PULSE_STATE_PATH"))
+        pa_set_env("PULSE_STATE_PATH", lib_path);
+
+    pa_xfree(run_path);
+    pa_xfree(lib_path);
+
+    pa_log_info("Not changing user for system instance on Windows.");
+    return 0;
+}
+
+#elif defined(HAVE_PWD_H) && defined(HAVE_GRP_H)
+
+static int change_user(void) {
+    struct passwd *pw;
+    struct group * gr;
+    int r;
+
+    /* This function is called only in system-wide mode. It creates a
+     * runtime dir in /var/run/ with proper UID/GID and drops privs
+     * afterwards. */
+
+    if (!(pw = getpwnam(PA_SYSTEM_USER))) {
+        pa_log(_("Failed to find user '%s'."), PA_SYSTEM_USER);
+        return -1;
+    }
+
+    if (!(gr = getgrnam(PA_SYSTEM_GROUP))) {
+        pa_log(_("Failed to find group '%s'."), PA_SYSTEM_GROUP);
+        return -1;
+    }
+
+    pa_log_info("Found user '%s' (UID %lu) and group '%s' (GID %lu).",
+                PA_SYSTEM_USER, (unsigned long) pw->pw_uid,
+                PA_SYSTEM_GROUP, (unsigned long) gr->gr_gid);
+
+    if (pw->pw_gid != gr->gr_gid) {
+        pa_log(_("GID of user '%s' and of group '%s' don't match."), PA_SYSTEM_USER, PA_SYSTEM_GROUP);
+        return -1;
+    }
+
+    if (!pa_streq(pw->pw_dir, PA_SYSTEM_RUNTIME_PATH))
+        pa_log_warn(_("Home directory of user '%s' is not '%s', ignoring."), PA_SYSTEM_USER, PA_SYSTEM_RUNTIME_PATH);
+
+    if (pa_make_secure_dir(PA_SYSTEM_RUNTIME_PATH, 0755, pw->pw_uid, gr->gr_gid, true) < 0) {
+        pa_log(_("Failed to create '%s': %s"), PA_SYSTEM_RUNTIME_PATH, pa_cstrerror(errno));
+        return -1;
+    }
+
+    if (pa_make_secure_dir(PA_SYSTEM_STATE_PATH, 0700, pw->pw_uid, gr->gr_gid, true) < 0) {
+        pa_log(_("Failed to create '%s': %s"), PA_SYSTEM_STATE_PATH, pa_cstrerror(errno));
+        return -1;
+    }
+
+    /* We don't create the config dir here, because we don't need to write to it */
+
+    if (initgroups(PA_SYSTEM_USER, gr->gr_gid) != 0) {
+        pa_log(_("Failed to change group list: %s"), pa_cstrerror(errno));
+        return -1;
+    }
+
+#if defined(HAVE_SETRESGID)
+    r = setresgid(gr->gr_gid, gr->gr_gid, gr->gr_gid);
+#elif defined(HAVE_SETEGID)
+    if ((r = setgid(gr->gr_gid)) >= 0)
+        r = setegid(gr->gr_gid);
+#elif defined(HAVE_SETREGID)
+    r = setregid(gr->gr_gid, gr->gr_gid);
+#else
+#error "No API to drop privileges"
+#endif
+
+    if (r < 0) {
+        pa_log(_("Failed to change GID: %s"), pa_cstrerror(errno));
+        return -1;
+    }
+
+#if defined(HAVE_SETRESUID)
+    r = setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid);
+#elif defined(HAVE_SETEUID)
+    if ((r = setuid(pw->pw_uid)) >= 0)
+        r = seteuid(pw->pw_uid);
+#elif defined(HAVE_SETREUID)
+    r = setreuid(pw->pw_uid, pw->pw_uid);
+#else
+#error "No API to drop privileges"
+#endif
+
+    if (r < 0) {
+        pa_log(_("Failed to change UID: %s"), pa_cstrerror(errno));
+        return -1;
+    }
+
+    pa_drop_caps();
+
+    pa_set_env("USER", PA_SYSTEM_USER);
+    pa_set_env("USERNAME", PA_SYSTEM_USER);
+    pa_set_env("LOGNAME", PA_SYSTEM_USER);
+    pa_set_env("HOME", PA_SYSTEM_RUNTIME_PATH);
+
+    /* Relevant for pa_runtime_path() */
+    if (!getenv("PULSE_RUNTIME_PATH"))
+        pa_set_env("PULSE_RUNTIME_PATH", PA_SYSTEM_RUNTIME_PATH);
+
+    if (!getenv("PULSE_CONFIG_PATH"))
+        pa_set_env("PULSE_CONFIG_PATH", PA_SYSTEM_CONFIG_PATH);
+
+    if (!getenv("PULSE_STATE_PATH"))
+        pa_set_env("PULSE_STATE_PATH", PA_SYSTEM_STATE_PATH);
+
+    pa_log_info("Successfully changed user to \"" PA_SYSTEM_USER "\".");
+
+    return 0;
+}
+
+#else /* HAVE_PWD_H && HAVE_GRP_H */
+
+static int change_user(void) {
+    pa_log(_("System wide mode unsupported on this platform."));
+    return -1;
+}
+
+#endif /* HAVE_PWD_H && HAVE_GRP_H */
+
+#ifdef HAVE_SYS_RESOURCE_H
+
+static int set_one_rlimit(const pa_rlimit *r, int resource, const char *name) {
+    struct rlimit rl;
+    pa_assert(r);
+
+    if (!r->is_set)
+        return 0;
+
+    rl.rlim_cur = rl.rlim_max = r->value;
+
+    if (setrlimit(resource, &rl) < 0) {
+        pa_log_info("setrlimit(%s, (%u, %u)) failed: %s", name, (unsigned) r->value, (unsigned) r->value, pa_cstrerror(errno));
+        return -1;
+    }
+
+    return 0;
+}
+
+static void set_all_rlimits(const pa_daemon_conf *conf) {
+    set_one_rlimit(&conf->rlimit_fsize, RLIMIT_FSIZE, "RLIMIT_FSIZE");
+    set_one_rlimit(&conf->rlimit_data, RLIMIT_DATA, "RLIMIT_DATA");
+    set_one_rlimit(&conf->rlimit_stack, RLIMIT_STACK, "RLIMIT_STACK");
+    set_one_rlimit(&conf->rlimit_core, RLIMIT_CORE, "RLIMIT_CORE");
+#ifdef RLIMIT_RSS
+    set_one_rlimit(&conf->rlimit_rss, RLIMIT_RSS, "RLIMIT_RSS");
+#endif
+#ifdef RLIMIT_NPROC
+    set_one_rlimit(&conf->rlimit_nproc, RLIMIT_NPROC, "RLIMIT_NPROC");
+#endif
+#ifdef RLIMIT_NOFILE
+    set_one_rlimit(&conf->rlimit_nofile, RLIMIT_NOFILE, "RLIMIT_NOFILE");
+#endif
+#ifdef RLIMIT_MEMLOCK
+    set_one_rlimit(&conf->rlimit_memlock, RLIMIT_MEMLOCK, "RLIMIT_MEMLOCK");
+#endif
+#ifdef RLIMIT_AS
+    set_one_rlimit(&conf->rlimit_as, RLIMIT_AS, "RLIMIT_AS");
+#endif
+#ifdef RLIMIT_LOCKS
+    set_one_rlimit(&conf->rlimit_locks, RLIMIT_LOCKS, "RLIMIT_LOCKS");
+#endif
+#ifdef RLIMIT_SIGPENDING
+    set_one_rlimit(&conf->rlimit_sigpending, RLIMIT_SIGPENDING, "RLIMIT_SIGPENDING");
+#endif
+#ifdef RLIMIT_MSGQUEUE
+    set_one_rlimit(&conf->rlimit_msgqueue, RLIMIT_MSGQUEUE, "RLIMIT_MSGQUEUE");
+#endif
+#ifdef RLIMIT_NICE
+    set_one_rlimit(&conf->rlimit_nice, RLIMIT_NICE, "RLIMIT_NICE");
+#endif
+#ifdef RLIMIT_RTPRIO
+    set_one_rlimit(&conf->rlimit_rtprio, RLIMIT_RTPRIO, "RLIMIT_RTPRIO");
+#endif
+#ifdef RLIMIT_RTTIME
+    set_one_rlimit(&conf->rlimit_rttime, RLIMIT_RTTIME, "RLIMIT_RTTIME");
+#endif
+}
+#endif
+
+static char *check_configured_address(void) {
+    char *default_server = NULL;
+    pa_client_conf *c = pa_client_conf_new();
+
+    pa_client_conf_load(c, true, true);
+
+    if (c->default_server && *c->default_server)
+        default_server = pa_xstrdup(c->default_server);
+
+    pa_client_conf_free(c);
+
+    return default_server;
+}
+
+#ifdef HAVE_DBUS
+static pa_dbus_connection *register_dbus_name(pa_core *c, DBusBusType bus, const char* name) {
+    DBusError error;
+    pa_dbus_connection *conn;
+
+    dbus_error_init(&error);
+
+    if (!(conn = pa_dbus_bus_get(c, bus, &error)) || dbus_error_is_set(&error)) {
+        pa_log_warn("Unable to contact D-Bus: %s: %s", error.name, error.message);
+        goto fail;
+    }
+
+    if (dbus_bus_request_name(pa_dbus_connection_get(conn), name, DBUS_NAME_FLAG_DO_NOT_QUEUE, &error) == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+        pa_log_debug("Got %s!", name);
+        return conn;
+    }
+
+    if (dbus_error_is_set(&error))
+        pa_log_error("Failed to acquire %s: %s: %s", name, error.name, error.message);
+    else
+        pa_log_error("D-Bus name %s already taken.", name);
+
+    /* PA cannot be started twice by the same user and hence we can
+     * ignore mostly the case that a name is already taken. */
+
+fail:
+    if (conn)
+        pa_dbus_connection_unref(conn);
+
+    dbus_error_free(&error);
+    return NULL;
+}
+#endif
+
+#ifdef OS_IS_WIN32
+#define SVC_NAME "PulseAudio"
+static bool is_svc = true;
+static int argc;
+static char **argv;
+static int real_main(int s_argc, char *s_argv[]);
+static SERVICE_STATUS_HANDLE svc_status;
+
+DWORD svc_callback(DWORD ctl, DWORD evt, LPVOID data, LPVOID userdata) {
+    pa_mainloop **m = userdata;
+    switch (ctl) {
+    case SERVICE_CONTROL_STOP:
+    case SERVICE_CONTROL_SHUTDOWN:
+        if (m) {
+            pa_log_info("Exiting.");
+            pa_mainloop_get_api(*m)->quit(pa_mainloop_get_api(*m), 0);
+        }
+        return NO_ERROR;
+    case SERVICE_CONTROL_INTERROGATE:
+        return NO_ERROR;
+    }
+    return ERROR_CALL_NOT_IMPLEMENTED;
+}
+
+int main(int p_argc, char *p_argv[]) {
+    argc = p_argc;
+    argv = p_argv;
+    if (StartServiceCtrlDispatcherA((SERVICE_TABLE_ENTRYA[]){
+        {SVC_NAME, (LPSERVICE_MAIN_FUNCTIONA) real_main},
+        {0},
+    })) return 0;
+    is_svc = false;
+    return real_main(0, NULL);
+}
+
+static int real_main(int s_argc, char *s_argv[]) {
+#else
+int main(int argc, char *argv[]) {
+#endif
+    pa_core *c = NULL;
+    pa_strbuf *buf = NULL;
+    pa_daemon_conf *conf = NULL;
+    pa_mainloop *mainloop = NULL;
+    char *s;
+    char *configured_address;
+    int r = 0, retval = 1, d = 0;
+    bool valid_pid_file = false;
+    bool ltdl_init = false;
+    int n_fds = 0, *passed_fds = NULL;
+    const char *e;
+#ifdef HAVE_FORK
+    int daemon_pipe[2] = { -1, -1 };
+    int daemon_pipe2[2] = { -1, -1 };
+#endif
+    int autospawn_fd = -1;
+    bool autospawn_locked = false;
+#ifdef HAVE_DBUS
+    pa_dbusobj_server_lookup *server_lookup = NULL; /* /org/pulseaudio/server_lookup */
+    pa_dbus_connection *lookup_service_bus = NULL; /* Always the user bus. */
+    pa_dbus_connection *server_bus = NULL; /* The bus where we reserve org.pulseaudio.Server, either the user or the system bus. */
+    bool start_server;
+#endif
+
+#ifdef OS_IS_WIN32
+    if (is_svc && !(svc_status = RegisterServiceCtrlHandlerExA(SVC_NAME, (LPHANDLER_FUNCTION_EX) svc_callback, &mainloop))) {
+        pa_log("Failed to register service control handler.");
+        goto finish;
+    }
+
+    if (is_svc) {
+        SetServiceStatus(svc_status, &(SERVICE_STATUS){
+            .dwServiceType      = SERVICE_WIN32,
+            .dwCurrentState     = SERVICE_START_PENDING,
+            .dwControlsAccepted = 0,
+            .dwWin32ExitCode    = NO_ERROR,
+            .dwWaitHint         = 3000,
+        });
+    }
+#endif
+
+    pa_log_set_ident("pulseaudio");
+    pa_log_set_level(PA_LOG_NOTICE);
+    pa_log_set_flags(PA_LOG_COLORS|PA_LOG_PRINT_FILE|PA_LOG_PRINT_LEVEL, PA_LOG_RESET);
+
+#if !defined(HAVE_BIND_NOW) && defined(__linux__) && defined(__OPTIMIZE__)
+    /*
+       Disable lazy relocations to make usage of external libraries
+       more deterministic for our RT threads. We abuse __OPTIMIZE__ as
+       a check whether we are a debug build or not. This all is
+       admittedly a bit snake-oilish.
+    */
+
+    if (!getenv("LD_BIND_NOW")) {
+        char *rp;
+        char *canonical_rp;
+
+        /* We have to execute ourselves, because the libc caches the
+         * value of $LD_BIND_NOW on initialization. */
+
+        pa_set_env("LD_BIND_NOW", "1");
+
+        if ((canonical_rp = pa_realpath(PA_BINARY))) {
+
+            if ((rp = pa_readlink("/proc/self/exe"))) {
+
+                if (pa_streq(rp, canonical_rp))
+                    pa_assert_se(execv(rp, argv) == 0);
+                else
+                    pa_log_warn("/proc/self/exe does not point to %s, cannot self execute. Are you playing games?", canonical_rp);
+
+                pa_xfree(rp);
+
+            } else
+                pa_log_warn("Couldn't read /proc/self/exe, cannot self execute. Running in a chroot()?");
+
+            pa_xfree(canonical_rp);
+
+        } else
+            pa_log_warn("Couldn't canonicalize binary path, cannot self execute.");
+    }
+#endif
+
+#ifdef HAVE_SYSTEMD_DAEMON
+    n_fds = sd_listen_fds(0);
+    if (n_fds > 0) {
+        int i = n_fds;
+
+        passed_fds = pa_xnew(int, n_fds+2);
+        passed_fds[n_fds] = passed_fds[n_fds+1] = -1;
+        while (i--)
+            passed_fds[i] = SD_LISTEN_FDS_START + i;
+    }
+#endif
+
+    if (!passed_fds) {
+        n_fds = 0;
+        passed_fds = pa_xnew(int, 2);
+        passed_fds[0] = passed_fds[1] = -1;
+    }
+
+    if ((e = getenv("PULSE_PASSED_FD"))) {
+        int passed_fd = atoi(e);
+        if (passed_fd > 2)
+            passed_fds[n_fds] = passed_fd;
+    }
+
+    /* We might be autospawned, in which case have no idea in which
+     * context we have been started. Let's cleanup our execution
+     * context as good as possible */
+
+    pa_reset_personality();
+    pa_drop_root();
+    pa_close_allv(passed_fds);
+    pa_xfree(passed_fds);
+    pa_reset_sigs(-1);
+    pa_unblock_sigs(-1);
+    pa_reset_priority();
+
+    /* Load locale from the environment. */
+    setlocale(LC_ALL, "");
+
+    /* Set LC_NUMERIC to C so that floating point strings are consistently
+     * formatted and parsed across locales. */
+    setlocale(LC_NUMERIC, "C");
+
+    pa_init_i18n();
+
+    conf = pa_daemon_conf_new();
+
+    if (pa_daemon_conf_load(conf, NULL) < 0)
+        goto finish;
+
+    if (pa_daemon_conf_env(conf) < 0)
+        goto finish;
+
+    if (pa_cmdline_parse(conf, argc, argv, &d) < 0) {
+        pa_log(_("Failed to parse command line."));
+        goto finish;
+    }
+
+    if (conf->log_target)
+        pa_log_set_target(conf->log_target);
+    else {
+        pa_log_target target = { .type = PA_LOG_STDERR, .file = NULL };
+        pa_log_set_target(&target);
+    }
+
+    pa_log_set_level(conf->log_level);
+    if (conf->log_meta)
+        pa_log_set_flags(PA_LOG_PRINT_META, PA_LOG_SET);
+    if (conf->log_time)
+        pa_log_set_flags(PA_LOG_PRINT_TIME, PA_LOG_SET);
+    pa_log_set_show_backtrace(conf->log_backtrace);
+
+#ifdef HAVE_DBUS
+    /* conf->system_instance and conf->local_server_type control almost the
+     * same thing; make them agree about what is requested. */
+    switch (conf->local_server_type) {
+        case PA_SERVER_TYPE_UNSET:
+            conf->local_server_type = conf->system_instance ? PA_SERVER_TYPE_SYSTEM : PA_SERVER_TYPE_USER;
+            break;
+        case PA_SERVER_TYPE_USER:
+        case PA_SERVER_TYPE_NONE:
+            conf->system_instance = false;
+            break;
+        case PA_SERVER_TYPE_SYSTEM:
+            conf->system_instance = true;
+            break;
+        default:
+            pa_assert_not_reached();
+    }
+
+    start_server = conf->local_server_type == PA_SERVER_TYPE_USER || (getuid() == 0 && conf->local_server_type == PA_SERVER_TYPE_SYSTEM);
+
+    if (!start_server && conf->local_server_type == PA_SERVER_TYPE_SYSTEM) {
+        pa_log_notice(_("System mode refused for non-root user. Only starting the D-Bus server lookup service."));
+        conf->system_instance = false;
+    }
+#endif
+
+    LTDL_SET_PRELOADED_SYMBOLS();
+    pa_ltdl_init();
+    ltdl_init = true;
+
+    if (conf->dl_search_path)
+        lt_dlsetsearchpath(conf->dl_search_path);
+
+#ifdef OS_IS_WIN32
+    {
+        WSADATA data;
+        WSAStartup(MAKEWORD(2, 0), &data);
+    }
+#endif
+
+    pa_random_seed();
+
+    switch (conf->cmd) {
+        case PA_CMD_DUMP_MODULES:
+            pa_dump_modules(conf, argc-d, argv+d);
+            retval = 0;
+            goto finish;
+
+        case PA_CMD_DUMP_CONF: {
+
+            if (d < argc) {
+                pa_log("Too many arguments.");
+                goto finish;
+            }
+
+            s = pa_daemon_conf_dump(conf);
+            fputs(s, stdout);
+            pa_xfree(s);
+            retval = 0;
+            goto finish;
+        }
+
+        case PA_CMD_DUMP_RESAMPLE_METHODS: {
+            int i;
+
+            if (d < argc) {
+                pa_log("Too many arguments.");
+                goto finish;
+            }
+
+            for (i = 0; i < PA_RESAMPLER_MAX; i++)
+                if (pa_resample_method_supported(i))
+                    printf("%s\n", pa_resample_method_to_string(i));
+
+            retval = 0;
+            goto finish;
+        }
+
+        case PA_CMD_HELP :
+            pa_cmdline_help(argv[0]);
+            retval = 0;
+            goto finish;
+
+        case PA_CMD_VERSION :
+
+            if (d < argc) {
+                pa_log("Too many arguments.");
+                goto finish;
+            }
+
+            printf(PACKAGE_NAME" "PACKAGE_VERSION"\n");
+            retval = 0;
+            goto finish;
+
+        case PA_CMD_CHECK: {
+            pid_t pid;
+
+            if (d < argc) {
+                pa_log("Too many arguments.");
+                goto finish;
+            }
+
+            if (pa_pid_file_check_running(&pid, "pulseaudio") < 0)
+                pa_log_info("Daemon not running");
+            else {
+                pa_log_info("Daemon running as PID %u", pid);
+                retval = 0;
+            }
+
+            goto finish;
+
+        }
+        case PA_CMD_KILL:
+
+            if (d < argc) {
+                pa_log("Too many arguments.");
+                goto finish;
+            }
+
+            if (pa_pid_file_kill(SIGINT, NULL, "pulseaudio") < 0)
+                pa_log(_("Failed to kill daemon: %s"), pa_cstrerror(errno));
+            else
+                retval = 0;
+
+            goto finish;
+
+        case PA_CMD_CLEANUP_SHM:
+
+            if (d < argc) {
+                pa_log("Too many arguments.");
+                goto finish;
+            }
+
+            if (pa_shm_cleanup() >= 0)
+                retval = 0;
+
+            goto finish;
+
+        default:
+            pa_assert(conf->cmd == PA_CMD_DAEMON || conf->cmd == PA_CMD_START);
+    }
+
+    if (d < argc) {
+        pa_log("Too many arguments.");
+        goto finish;
+    }
+
+#ifdef HAVE_GETUID
+#ifndef HAVE_DBUS /* A similar, only a notice worthy check was done earlier, if D-Bus is enabled. */
+    if (getuid() != 0 && conf->system_instance) {
+        pa_log(_("Root privileges required."));
+        goto finish;
+    }
+#endif
+#endif  /* HAVE_GETUID */
+
+    if (conf->cmd == PA_CMD_START && conf->system_instance) {
+        pa_log(_("--start not supported for system instances."));
+        goto finish;
+    }
+
+    if (conf->cmd == PA_CMD_START && (configured_address = check_configured_address())) {
+        /* There is an server address in our config, but where did it come from?
+         * By default a standard X11 login will load module-x11-publish which will
+         * inject PULSE_SERVER X11 property. If the PA daemon crashes, we will end
+         * up hitting this code path. So we have to check to see if our configured_address
+         * is the same as the value that would go into this property so that we can
+         * recover (i.e. autospawn) from a crash.
+         */
+        char *ufn;
+        bool start_anyway = false;
+
+        if ((ufn = pa_runtime_path(PA_NATIVE_DEFAULT_UNIX_SOCKET))) {
+            char *id;
+
+            if ((id = pa_machine_id())) {
+                pa_strlist *server_list;
+                char formatted_ufn[256];
+
+                pa_snprintf(formatted_ufn, sizeof(formatted_ufn), "{%s}unix:%s", id, ufn);
+                pa_xfree(id);
+
+                if ((server_list = pa_strlist_parse(configured_address))) {
+                    char *u = NULL;
+
+                    /* We only need to check the first server */
+                    server_list = pa_strlist_pop(server_list, &u);
+                    pa_strlist_free(server_list);
+
+                    start_anyway = (u && pa_streq(formatted_ufn, u));
+                    pa_xfree(u);
+                }
+            }
+            pa_xfree(ufn);
+        }
+
+        if (!start_anyway) {
+            pa_log_notice(_("User-configured server at %s, refusing to start/autospawn."), configured_address);
+            pa_xfree(configured_address);
+            retval = 0;
+            goto finish;
+        }
+
+        pa_log_notice(_("User-configured server at %s, which appears to be local. Probing deeper."), configured_address);
+        pa_xfree(configured_address);
+    }
+
+    if (conf->system_instance && !conf->disallow_exit)
+        pa_log_warn(_("Running in system mode, but --disallow-exit not set."));
+
+    if (conf->system_instance && !conf->disallow_module_loading)
+        pa_log_warn(_("Running in system mode, but --disallow-module-loading not set."));
+
+    if (conf->system_instance && !conf->disable_shm) {
+        pa_log_notice(_("Running in system mode, forcibly disabling SHM mode."));
+        conf->disable_shm = true;
+    }
+
+    if (conf->system_instance && conf->exit_idle_time >= 0) {
+        pa_log_notice(_("Running in system mode, forcibly disabling exit idle time."));
+        conf->exit_idle_time = -1;
+    }
+
+    if (conf->cmd == PA_CMD_START) {
+        /* If we shall start PA only when it is not running yet, we
+         * first take the autospawn lock to make things
+         * synchronous. */
+
+        /* This locking and thread synchronisation code doesn't work reliably
+         * on kFreeBSD (Debian bug #705435), or in upstream FreeBSD ports
+         * (bug reference: ports/128947, patched in SVN r231972). */
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
+        if ((autospawn_fd = pa_autospawn_lock_init()) < 0) {
+            pa_log("Failed to initialize autospawn lock");
+            goto finish;
+        }
+
+        if ((pa_autospawn_lock_acquire(true) < 0)) {
+            pa_log("Failed to acquire autospawn lock");
+            goto finish;
+        }
+
+        autospawn_locked = true;
+#endif
+    }
+
+    if (conf->daemonize) {
+#ifdef HAVE_FORK
+        pid_t child;
+#endif
+
+        if (pa_stdio_acquire() < 0) {
+            pa_log(_("Failed to acquire stdio."));
+            goto finish;
+        }
+
+#ifdef HAVE_FORK
+        if (pipe(daemon_pipe) < 0) {
+            pa_log(_("pipe() failed: %s"), pa_cstrerror(errno));
+            goto finish;
+        }
+
+        if ((child = fork()) < 0) {
+            pa_log(_("fork() failed: %s"), pa_cstrerror(errno));
+            pa_close_pipe(daemon_pipe);
+            goto finish;
+        }
+
+        if (child != 0) {
+            ssize_t n;
+            /* Father */
+
+            pa_assert_se(pa_close(daemon_pipe[1]) == 0);
+            daemon_pipe[1] = -1;
+
+            if ((n = pa_loop_read(daemon_pipe[0], &retval, sizeof(retval), NULL)) != sizeof(retval)) {
+
+                if (n < 0)
+                    pa_log(_("read() failed: %s"), pa_cstrerror(errno));
+
+                retval = 1;
+            }
+
+            if (retval)
+                pa_log(_("Daemon startup failed."));
+            else
+                pa_log_info("Daemon startup successful.");
+
+            goto finish;
+        }
+
+        if (autospawn_fd >= 0) {
+            /* The lock file is unlocked from the parent, so we need
+             * to close it in the child */
+
+            pa_autospawn_lock_release();
+            pa_autospawn_lock_done(true);
+
+            autospawn_locked = false;
+            autospawn_fd = -1;
+        }
+
+        pa_assert_se(pa_close(daemon_pipe[0]) == 0);
+        daemon_pipe[0] = -1;
+#endif
+
+        if (!conf->log_target) {
+#ifdef HAVE_SYSTEMD_JOURNAL
+            pa_log_target target = { .type = PA_LOG_JOURNAL, .file = NULL };
+#else
+            pa_log_target target = { .type = PA_LOG_SYSLOG, .file = NULL };
+#endif
+            pa_log_set_target(&target);
+        }
+
+#ifdef HAVE_SETSID
+        if (setsid() < 0) {
+            pa_log(_("setsid() failed: %s"), pa_cstrerror(errno));
+            goto finish;
+        }
+#endif
+
+#ifdef HAVE_FORK
+        /* We now are a session and process group leader. Let's fork
+         * again and let the father die, so that we'll become a
+         * process that can never acquire a TTY again, in a session and
+         * process group without leader */
+
+        if (pipe(daemon_pipe2) < 0) {
+            pa_log(_("pipe() failed: %s"), pa_cstrerror(errno));
+            goto finish;
+        }
+
+        if ((child = fork()) < 0) {
+            pa_log(_("fork() failed: %s"), pa_cstrerror(errno));
+            pa_close_pipe(daemon_pipe2);
+            goto finish;
+        }
+
+        if (child != 0) {
+            ssize_t n;
+            /* Father */
+
+            pa_assert_se(pa_close(daemon_pipe2[1]) == 0);
+            daemon_pipe2[1] = -1;
+
+            if ((n = pa_loop_read(daemon_pipe2[0], &retval, sizeof(retval), NULL)) != sizeof(retval)) {
+
+                if (n < 0)
+                    pa_log(_("read() failed: %s"), pa_cstrerror(errno));
+
+                retval = 1;
+            }
+
+            /* We now have to take care of signalling the first fork with
+             * the return value we've received from this fork... */
+            pa_assert(daemon_pipe[1] >= 0);
+
+            pa_loop_write(daemon_pipe[1], &retval, sizeof(retval), NULL);
+            pa_close(daemon_pipe[1]);
+            daemon_pipe[1] = -1;
+
+            goto finish;
+        }
+
+        pa_assert_se(pa_close(daemon_pipe2[0]) == 0);
+        daemon_pipe2[0] = -1;
+
+        /* We no longer need the (first) daemon_pipe as it's handled in our child above */
+        pa_close_pipe(daemon_pipe);
+#endif
+
+#ifdef SIGTTOU
+        signal(SIGTTOU, SIG_IGN);
+#endif
+#ifdef SIGTTIN
+        signal(SIGTTIN, SIG_IGN);
+#endif
+#ifdef SIGTSTP
+        signal(SIGTSTP, SIG_IGN);
+#endif
+
+        pa_nullify_stdfds();
+    }
+
+    pa_set_env_and_record("PULSE_INTERNAL", "1");
+    pa_assert_se(chdir("/") == 0);
+    umask(0077);
+
+#ifdef HAVE_SYS_RESOURCE_H
+    set_all_rlimits(conf);
+#endif
+    pa_rtclock_hrtimer_enable();
+
+    if (conf->high_priority)
+        pa_raise_priority(conf->nice_level);
+
+    if (conf->system_instance)
+        if (change_user() < 0)
+            goto finish;
+
+    pa_set_env_and_record("PULSE_SYSTEM", conf->system_instance ? "1" : "0");
+
+    pa_log_info("This is PulseAudio %s", PACKAGE_VERSION);
+    pa_log_debug("Compilation CFLAGS: %s", PA_CFLAGS);
+
+#ifdef HAVE_LIBSAMPLERATE
+    pa_log_warn("Compiled with DEPRECATED libsamplerate support!");
+#endif
+
+    s = pa_uname_string();
+    pa_log_debug("Running on host: %s", s);
+    pa_xfree(s);
+
+    pa_log_debug("Found %u CPUs.", pa_ncpus());
+
+    pa_log_info("Page size is %zu bytes", pa_page_size());
+
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+    pa_log_debug("Compiled with Valgrind support: yes");
+#else
+    pa_log_debug("Compiled with Valgrind support: no");
+#endif
+
+    pa_log_debug("Running in valgrind mode: %s", pa_yes_no(pa_in_valgrind()));
+
+    pa_log_debug("Running in VM: %s", pa_yes_no(pa_running_in_vm()));
+
+#ifdef HAVE_RUNNING_FROM_BUILD_TREE
+    pa_log_debug("Running from build tree: %s", pa_yes_no(pa_run_from_build_tree()));
+#else
+    pa_log_debug("Running from build tree: no");
+#endif
+
+#ifdef __OPTIMIZE__
+    pa_log_debug("Optimized build: yes");
+#else
+    pa_log_debug("Optimized build: no");
+#endif
+
+#ifdef NDEBUG
+    pa_log_debug("NDEBUG defined, all asserts disabled.");
+#elif defined(FASTPATH)
+    pa_log_debug("FASTPATH defined, only fast path asserts disabled.");
+#else
+    pa_log_debug("All asserts enabled.");
+#endif
+
+    if (!(s = pa_machine_id())) {
+        pa_log(_("Failed to get machine ID"));
+        goto finish;
+    }
+    pa_log_info("Machine ID is %s.", s);
+    pa_xfree(s);
+
+    if ((s = pa_session_id())) {
+        pa_log_info("Session ID is %s.", s);
+        pa_xfree(s);
+    }
+
+    if (!(s = pa_get_runtime_dir()))
+        goto finish;
+    pa_log_info("Using runtime directory %s.", s);
+    pa_xfree(s);
+
+    if (!(s = pa_get_state_dir()))
+        goto finish;
+    pa_log_info("Using state directory %s.", s);
+    pa_xfree(s);
+
+    pa_log_info("Using modules directory %s.", conf->dl_search_path);
+
+    pa_log_info("Running in system mode: %s", pa_yes_no(pa_in_system_mode()));
+
+    if (pa_in_system_mode())
+        pa_log_warn(_("OK, so you are running PA in system mode. Please make sure that you actually do want to do that.\n"
+                      "Please read http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/ for an explanation why system mode is usually a bad idea."));
+
+    if (conf->use_pid_file) {
+        int z;
+
+        if ((z = pa_pid_file_create("pulseaudio")) != 0) {
+
+            if (conf->cmd == PA_CMD_START && z > 0) {
+                /* If we are already running and with are run in
+                 * --start mode, then let's return this as success. */
+
+                retval = 0;
+                goto finish;
+            }
+
+            pa_log(_("pa_pid_file_create() failed."));
+            goto finish;
+        }
+
+        valid_pid_file = true;
+    }
+
+    pa_disable_sigpipe();
+
+    if (pa_rtclock_hrtimer())
+        pa_log_info("System supports high resolution timers");
+    else
+        pa_log_info("System appears to not support high resolution timers");
+
+    if (conf->lock_memory) {
+#if defined(HAVE_SYS_MMAN_H) && !defined(__ANDROID__)
+        if (mlockall(MCL_FUTURE) < 0)
+            pa_log_warn("mlockall() failed: %s", pa_cstrerror(errno));
+        else
+            pa_log_info("Successfully locked process into memory.");
+#else
+        pa_log_warn("Memory locking requested but not supported on platform.");
+#endif
+    }
+
+    pa_memtrap_install();
+
+    pa_assert_se(mainloop = pa_mainloop_new());
+
+    if (!(c = pa_core_new(pa_mainloop_get_api(mainloop), !conf->disable_shm,
+                          !conf->disable_shm && !conf->disable_memfd && pa_memfd_is_locally_supported(),
+                          conf->shm_size))) {
+        pa_log(_("pa_core_new() failed."));
+        goto finish;
+    }
+
+    c->default_sample_spec = conf->default_sample_spec;
+    c->alternate_sample_rate = conf->alternate_sample_rate;
+    c->default_channel_map = conf->default_channel_map;
+    c->default_n_fragments = conf->default_n_fragments;
+    c->default_fragment_size_msec = conf->default_fragment_size_msec;
+    c->deferred_volume_safety_margin_usec = conf->deferred_volume_safety_margin_usec;
+    c->deferred_volume_extra_delay_usec = conf->deferred_volume_extra_delay_usec;
+    c->lfe_crossover_freq = conf->lfe_crossover_freq;
+    c->exit_idle_time = conf->exit_idle_time;
+    c->scache_idle_time = conf->scache_idle_time;
+    c->resample_method = conf->resample_method;
+    c->realtime_priority = conf->realtime_priority;
+    c->realtime_scheduling = conf->realtime_scheduling;
+    c->avoid_resampling = conf->avoid_resampling;
+    c->disable_remixing = conf->disable_remixing;
+    c->remixing_use_all_sink_channels = conf->remixing_use_all_sink_channels;
+    c->remixing_produce_lfe = conf->remixing_produce_lfe;
+    c->remixing_consume_lfe = conf->remixing_consume_lfe;
+    c->deferred_volume = conf->deferred_volume;
+    c->running_as_daemon = conf->daemonize;
+    c->disallow_exit = conf->disallow_exit;
+    c->flat_volumes = conf->flat_volumes;
+    c->rescue_streams = conf->rescue_streams;
+#ifdef HAVE_DBUS
+    c->server_type = conf->local_server_type;
+#endif
+
+    pa_core_check_idle(c);
+
+    c->state = PA_CORE_RUNNING;
+
+    pa_cpu_init(&c->cpu_info);
+
+    pa_assert_se(pa_signal_init(pa_mainloop_get_api(mainloop)) == 0);
+    pa_signal_new(SIGINT, signal_callback, c);
+    pa_signal_new(SIGTERM, signal_callback, c);
+#ifdef SIGUSR1
+    pa_signal_new(SIGUSR1, signal_callback, c);
+#endif
+#ifdef SIGUSR2
+    pa_signal_new(SIGUSR2, signal_callback, c);
+#endif
+#ifdef SIGHUP
+    pa_signal_new(SIGHUP, signal_callback, c);
+#endif
+
+    if (!conf->no_cpu_limit)
+        pa_assert_se(pa_cpu_limit_init(pa_mainloop_get_api(mainloop)) == 0);
+
+    buf = pa_strbuf_new();
+
+#ifdef HAVE_DBUS
+    pa_assert_se(dbus_threads_init_default());
+
+    if (start_server)
+#endif
+    {
+        const char *command_source = NULL;
+
+        if (conf->load_default_script_file) {
+            FILE *f;
+
+            if ((f = pa_daemon_conf_open_default_script_file(conf))) {
+                r = pa_cli_command_execute_file_stream(c, f, buf, &conf->fail);
+                fclose(f);
+                command_source = pa_daemon_conf_get_default_script_file(conf);
+            }
+        }
+
+        if (r >= 0) {
+            r = pa_cli_command_execute(c, conf->script_commands, buf, &conf->fail);
+            command_source = _("command line arguments");
+        }
+
+        pa_log_error("%s", s = pa_strbuf_to_string_free(buf));
+        pa_xfree(s);
+
+        if (r < 0 && conf->fail) {
+            pa_log(_("Failed to initialize daemon due to errors while executing startup commands. Source of commands: %s"), command_source);
+            goto finish;
+        }
+
+        if (!c->modules || pa_idxset_size(c->modules) == 0) {
+            pa_log(_("Daemon startup without any loaded modules, refusing to work."));
+            goto finish;
+        }
+#ifdef HAVE_DBUS
+    } else {
+        /* When we just provide the D-Bus server lookup service, we don't want
+         * any modules to be loaded. We haven't loaded any so far, so one might
+         * think there's no way to contact the server, but receiving certain
+         * signals could still cause modules to load. */
+        conf->disallow_module_loading = true;
+#endif
+    }
+
+    /* We completed the initial module loading, so let's disable it
+     * from now on, if requested */
+    c->disallow_module_loading = conf->disallow_module_loading;
+
+#ifdef HAVE_DBUS
+    if (!conf->system_instance) {
+        if ((server_lookup = pa_dbusobj_server_lookup_new(c))) {
+            if (!(lookup_service_bus = register_dbus_name(c, DBUS_BUS_SESSION, "org.PulseAudio1")))
+                goto finish;
+        }
+    }
+
+    if (start_server)
+        server_bus = register_dbus_name(c, conf->system_instance ? DBUS_BUS_SYSTEM : DBUS_BUS_SESSION, "org.pulseaudio.Server");
+#endif
+
+#ifdef HAVE_FORK
+    if (daemon_pipe2[1] >= 0) {
+        int ok = 0;
+        pa_loop_write(daemon_pipe2[1], &ok, sizeof(ok), NULL);
+        pa_close(daemon_pipe2[1]);
+        daemon_pipe2[1] = -1;
+    }
+#endif
+
+    pa_log_info("Daemon startup complete.");
+
+#ifdef HAVE_SYSTEMD_DAEMON
+    sd_notify(0, "READY=1");
+#endif
+
+#ifdef OS_IS_WIN32
+    if (is_svc) {
+        SetServiceStatus(svc_status, &(SERVICE_STATUS){
+            .dwServiceType      = SERVICE_WIN32,
+            .dwCurrentState     = SERVICE_RUNNING,
+            .dwControlsAccepted = SERVICE_ACCEPT_STOP|SERVICE_ACCEPT_SHUTDOWN,
+            .dwWin32ExitCode    = NO_ERROR,
+            .dwWaitHint         = 0,
+        });
+    }
+#endif
+
+    retval = 0;
+    if (pa_mainloop_run(mainloop, &retval) < 0)
+        goto finish;
+
+    pa_log_info("Daemon shutdown initiated.");
+
+#ifdef HAVE_SYSTEMD_DAEMON
+    sd_notify(0, "STOPPING=1");
+#endif
+
+#ifdef OS_IS_WIN32
+    if (is_svc) {
+        SetServiceStatus(svc_status, &(SERVICE_STATUS){
+            .dwServiceType      = SERVICE_WIN32,
+            .dwCurrentState     = SERVICE_STOP_PENDING,
+            .dwControlsAccepted = 0,
+            .dwWin32ExitCode    = NO_ERROR,
+            .dwWaitHint         = 2000,
+        });
+    }
+#endif
+
+finish:
+#ifdef HAVE_DBUS
+    if (server_bus)
+        pa_dbus_connection_unref(server_bus);
+    if (lookup_service_bus)
+        pa_dbus_connection_unref(lookup_service_bus);
+    if (server_lookup)
+        pa_dbusobj_server_lookup_free(server_lookup);
+#endif
+
+    if (autospawn_fd >= 0) {
+        if (autospawn_locked)
+            pa_autospawn_lock_release();
+
+        pa_autospawn_lock_done(false);
+    }
+
+    if (c) {
+        /* Ensure all the modules/samples are unloaded when the core is still ref'ed,
+         * as unlink callback hooks in modules may need the core to be ref'ed */
+        pa_module_unload_all(c);
+        pa_scache_free_all(c);
+
+        pa_core_unref(c);
+        pa_log_info("Daemon terminated.");
+    }
+
+    if (!conf->no_cpu_limit)
+        pa_cpu_limit_done();
+
+    pa_signal_done();
+
+#ifdef HAVE_FORK
+    /* If we have daemon_pipe[1] still open, this means we've failed after
+     * the first fork, but before the second. Therefore just write to it. */
+    if (daemon_pipe[1] >= 0)
+        pa_loop_write(daemon_pipe[1], &retval, sizeof(retval), NULL);
+    else if (daemon_pipe2[1] >= 0)
+        pa_loop_write(daemon_pipe2[1], &retval, sizeof(retval), NULL);
+
+    pa_close_pipe(daemon_pipe2);
+    pa_close_pipe(daemon_pipe);
+#endif
+
+    if (mainloop)
+        pa_mainloop_free(mainloop);
+
+    if (conf)
+        pa_daemon_conf_free(conf);
+
+    if (valid_pid_file)
+        pa_pid_file_remove();
+
+    /* This has no real purpose except making things valgrind-clean */
+    pa_unset_env_recorded();
+
+#ifdef OS_IS_WIN32
+    WSACleanup();
+#endif
+
+    if (ltdl_init)
+        pa_ltdl_done();
+
+#ifdef HAVE_DBUS
+    dbus_shutdown();
+#endif
+
+#ifdef OS_IS_WIN32
+    if (is_svc) {
+        SetServiceStatus(svc_status, &(SERVICE_STATUS){
+            .dwServiceType      = SERVICE_WIN32,
+            .dwCurrentState     = SERVICE_STOPPED,
+            .dwControlsAccepted = 0,
+            .dwWin32ExitCode    = retval ? ERROR_PROCESS_ABORTED : NO_ERROR,
+            .dwWaitHint         = 0,
+        });
+    }
+#endif
+
+    return retval;
+}
Index: create-16.1-no-root-warn-patch/pulseaudio-16.1-new/src/daemon
===================================================================
--- create-16.1-no-root-warn-patch/pulseaudio-16.1-new/src/daemon	(nonexistent)
+++ create-16.1-no-root-warn-patch/pulseaudio-16.1-new/src/daemon	(revision 5)

Property changes on: create-16.1-no-root-warn-patch/pulseaudio-16.1-new/src/daemon
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-no-root-warn-patch/pulseaudio-16.1-new/src
===================================================================
--- create-16.1-no-root-warn-patch/pulseaudio-16.1-new/src	(nonexistent)
+++ create-16.1-no-root-warn-patch/pulseaudio-16.1-new/src	(revision 5)

Property changes on: create-16.1-no-root-warn-patch/pulseaudio-16.1-new/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-no-root-warn-patch/pulseaudio-16.1-new
===================================================================
--- create-16.1-no-root-warn-patch/pulseaudio-16.1-new	(nonexistent)
+++ create-16.1-no-root-warn-patch/pulseaudio-16.1-new	(revision 5)

Property changes on: create-16.1-no-root-warn-patch/pulseaudio-16.1-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-no-root-warn-patch
===================================================================
--- create-16.1-no-root-warn-patch	(nonexistent)
+++ create-16.1-no-root-warn-patch	(revision 5)

Property changes on: create-16.1-no-root-warn-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-posix-completion-patch/create.patch.sh
===================================================================
--- create-16.1-posix-completion-patch/create.patch.sh	(nonexistent)
+++ create-16.1-posix-completion-patch/create.patch.sh	(revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=16.1
+
+tar --files-from=file.list -xJvf ../pulseaudio-$VERSION.tar.xz
+mv pulseaudio-$VERSION pulseaudio-$VERSION-orig
+
+cp -rf ./pulseaudio-$VERSION-new ./pulseaudio-$VERSION
+
+diff --unified -Nr  pulseaudio-$VERSION-orig  pulseaudio-$VERSION > pulseaudio-$VERSION-posix-completion.patch
+
+mv pulseaudio-$VERSION-posix-completion.patch ../patches
+
+rm -rf ./pulseaudio-$VERSION
+rm -rf ./pulseaudio-$VERSION-orig

Property changes on: create-16.1-posix-completion-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-16.1-posix-completion-patch/file.list
===================================================================
--- create-16.1-posix-completion-patch/file.list	(nonexistent)
+++ create-16.1-posix-completion-patch/file.list	(revision 5)
@@ -0,0 +1 @@
+pulseaudio-16.1/shell-completion/bash/pactl
Index: create-16.1-posix-completion-patch/pulseaudio-16.1-new/shell-completion/bash/pactl
===================================================================
--- create-16.1-posix-completion-patch/pulseaudio-16.1-new/shell-completion/bash/pactl	(nonexistent)
+++ create-16.1-posix-completion-patch/pulseaudio-16.1-new/shell-completion/bash/pactl	(revision 5)
@@ -0,0 +1,579 @@
+#!/bin/bash
+
+__cards () {
+    (pactl list cards short 2> /dev/null) |\
+    while IFS=$'\t' read idx name _; do
+        printf "%s %s\n" "$idx" "$name"
+    done
+}
+
+__sinks () {
+    (pactl list sinks short 2> /dev/null) |\
+    while IFS=$'\t' read _ name _ _ _; do
+        printf "%s\n" "$name"
+    done
+}
+
+__sinks_idx () {
+    (pactl list sinks short 2> /dev/null) |\
+    while IFS=$'\t' read idx _ _ _ _; do
+        printf "%s\n" "$idx"
+    done
+}
+
+__sources () {
+    (pactl list sources short 2> /dev/null) |\
+    while IFS=$'\t' read _ name _ _ _; do
+        printf "%s\n" "$name"
+    done
+}
+
+__sink_inputs () {
+    (pactl list sink-inputs short 2> /dev/null) |\
+    while IFS=$'\t' read idx _ _ _ _; do
+        printf "%s\n" "$idx"
+    done
+}
+
+__source_outputs () {
+    (pactl list source-outputs short 2> /dev/null) |\
+    while IFS=$'\t' read idx _ _ _ _; do
+        printf "%s\n" "$idx"
+    done
+}
+
+__ports () {
+    pactl list cards 2> /dev/null | awk -- \
+        '/^\tPorts:/ {
+            flag=1; next
+         }
+
+         /^\t[A-Za-z]/ {
+             flag=0
+         }
+
+         flag {
+             if (/^\t\t[A-Za-z]/)
+                 ports = ports substr($0, 3, index($0, ":")-3) " "
+         }
+
+         END {
+             print ports
+         }'
+}
+
+__profiles () {
+    pactl list cards 2> /dev/null | awk -- \
+        '/^\tProfiles:/ {
+            flag=1; next
+        }
+
+        /^\t[A-Za-z]/ {
+            flag=0
+        }
+
+        flag {
+            if (/^\t\t[A-Za-z]/)
+                profiles = profiles substr($0, 3, index($0, ": ")-3) " "
+        }
+
+        END {
+            print profiles
+        }'
+}
+
+__all_modules () {
+    (pulseaudio --dump-modules 2> /dev/null) |\
+    while read name; do
+        name=${name%% *}
+        printf "%s\n" "$name"
+    done
+}
+
+__loaded_modules () {
+    (pactl list modules short 2> /dev/null) |\
+    while IFS=$'\t' read idx name _; do
+        printf "%s %s\n" "$idx" "$name"
+    done
+}
+
+__resample_methods () {
+    (pulseaudio --dump-resample-methods 2> /dev/null) |\
+    while read name; do
+        printf "%s\n" "$name"
+    done
+}
+
+_pacat_file_formats () {
+    (pacat --list-file-formats 2> /dev/null) |\
+    while IFS=$'\t' read name _; do
+        printf "%s\n" "$name"
+    done
+}
+
+in_array() {
+    local i
+    for i in "${@:2}"; do
+        [[ $1 = "$i" ]] && return
+    done
+}
+
+_pactl() {
+    local cur prev words cword preprev word command
+    local comps
+    local flags='-h --help --version -s --server= --client-name='
+    local list_types='short sinks sources sink-inputs source-outputs cards
+                    modules samples clients message-handlers'
+    local commands=(stat info list exit upload-sample play-sample remove-sample
+                    load-module unload-module move-sink-input move-source-output
+                    suspend-sink suspend-source set-card-profile set-default-sink
+                    set-sink-port set-default-source set-source-port set-sink-volume
+                    set-source-volume set-sink-input-volume set-source-output-volume
+                    set-sink-mute set-source-mute set-sink-input-mute
+                    set-source-output-mute set-sink-formats set-port-latency-offset
+                    subscribe send-message help)
+
+    _init_completion -n = || return
+    preprev=${words[$cword-2]}
+
+    for word in "${COMP_WORDS[@]}"; do
+        if in_array "$word" "${commands[@]}"; then
+            command=$word
+            break
+        fi
+    done
+
+    case $preprev in
+        list) COMPREPLY=($(compgen -W 'short' -- "$cur")) ;;
+
+        play-sample)
+            comps=$(__sinks)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        move-sink-input)
+            comps=$(__sinks)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        move-source-output)
+            comps=$(__sources)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        set-card-profile)
+            comps=$(__profiles)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        set-*-port)
+            comps=$(__ports)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        set-*-mute) COMPREPLY=($(compgen -W 'true false toggle' -- "$cur")) ;;
+
+        set-sink-formats)
+            ;; #TODO
+
+        set-port-*)
+            comps=$(__ports)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+        --server)
+            compopt +o nospace
+            _known_hosts_real "$cur"
+            ;;
+    esac
+    [[ $COMPREPLY ]] && return 0
+
+    case $prev in
+        list) COMPREPLY=($(compgen -W '${list_types[*]}' -- "$cur")) ;;
+
+        upload-sample) _filedir ;;
+
+        play-sample) ;; # TODO
+
+        remove-sample) ;; # TODO
+
+        load-module)
+            comps=$(__all_modules)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        unload-module)
+            comps=$(__loaded_modules)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        set-card*)
+            comps=$(__cards)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        *sink-input*)
+            comps=$(__sink_inputs)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        *source-output*)
+            comps=$(__source_outputs)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        set-sink-formats)
+            comps=$(__sinks_idx)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        *sink*)
+            comps=$(__sinks)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        *source*)
+            comps=$(__sources)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        set-port*)
+            comps=$(__cards)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        -s)
+            _known_hosts_real "$cur" ;;
+    esac
+    [[ $COMPREPLY ]] && return 0
+
+    case $cur in
+        --server=*)
+            cur=${cur#*=}
+            _known_hosts_real "$cur"
+            ;;
+
+        -*)
+            COMPREPLY=($(compgen -W '${flags[*]}' -- "$cur"))
+            [[ $COMPREPLY == *= ]] && compopt -o nospace
+            ;;
+
+        *)
+            [[ -z $command ]] && COMPREPLY=($(compgen -W '${commands[*]}' -- "$cur"))
+            ;;
+    esac
+}
+complete -F _pactl pactl
+
+_pacmd() {
+    local cur prev words cword preprev word command
+    local comps
+    local flags='-h --help --version'
+    local commands=(exit help list-modules list-cards list-sinks list-sources list-clients
+                    list-samples list-sink-inputs list-source-outputs stat info
+                    load-module unload-module describe-module set-sink-volume
+                    set-source-volume set-sink-input-volume set-source-output-volume
+                    set-sink-mute set-source-mut set-sink-input-mute
+                    set-source-output-mute update-sink-proplist update-source-proplist
+                    update-sink-input-proplist update-source-output-proplist
+                    set-default-sink set-default-source kill-client kill-sink-input
+                    kill-source-output play-sample remove-sample load-sample
+                    load-sample-lazy load-sample-dir-lazy play-file dump
+                    move-sink-input move-source-output suspend-sink suspend-source
+                    suspend set-card-profile set-sink-port set-source-port
+                    set-port-latency-offset set-log-target set-log-level set-log-meta
+                    set-log-time set-log-backtrace send-message)
+    _init_completion -n = || return
+    preprev=${words[$cword-2]}
+
+    for word in "${COMP_WORDS[@]}"; do
+        if in_array "$word" "${commands[@]}"; then
+            command=$word
+            break
+        fi
+    done
+
+    case $preprev in
+        play-sample|play-file)
+            comps=$(__sinks)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        load-sample*) _filedir ;;
+
+        move-sink-input)
+            comps=$(__sinks)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        move-source-output)
+            comps=$(__sources)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        set-card-profile)
+            comps=$(__profiles)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        set-*port*)
+            comps=$(__ports)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        set-*-mute) COMPREPLY=($(compgen -W 'true false' -- "$cur"));;
+
+        set-sink-formats)
+            ;; #TODO
+    esac
+
+    case $prev in
+        list-*) ;;
+        describe-module|load-module)
+            comps=$(__all_modules)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        unload-module)
+            comps=$(__loaded_modules)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        load-sample-dir-lazy) _filedir -d ;;
+        play-file) _filedir ;;
+
+        *sink-input*)
+            comps=$(__sink_inputs)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        *source-output*)
+            comps=$(__source_outputs)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        *sink*)
+            comps=$(__sinks)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        *source*)
+            comps=$(__sources)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        set-card*)
+            comps=$(__cards)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        set-port-*)
+            comps=$(__cards)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        set-log-target)
+            COMPREPLY=($(compgen -W 'auto syslog stderr file: newfile:' -- "$cur"))
+            ;;
+
+        set-log-level)
+            COMPREPLY=($(compgen -W '{0..4}' -- "$cur"))
+            ;;
+
+        set-log-meta|set-log-time|suspend)
+            COMPREPLY=($(compgen -W 'true false' -- "$cur"))
+            ;;
+    esac
+
+    case $cur in
+        -*) COMPREPLY=($(compgen -W '${flags[*]}' -- "$cur")) ;;
+        suspend)
+            COMPREPLY=($(compgen -W 'suspend suspend-sink suspend-source' -- "$cur"))
+            ;;
+
+        load-sample)
+            COMPREPLY=($(compgen -W 'load-sample load-sample-lazy load-sample-dir-lazy' -- "$cur"))
+            ;;
+
+        *)
+            [[ -z $command ]] && COMPREPLY=($(compgen -W '${commands[*]}' -- "$cur"))
+            ;;
+    esac
+}
+complete -F _pacmd pacmd
+
+_pasuspender () {
+    local cur prev
+    local flags='-h --help --version -s --server='
+
+    _init_completion -n = || return
+
+    case $cur in
+        --server=*)
+            cur=${cur#*=}
+            _known_hosts_real "$cur"
+            ;;
+
+        -*)
+            COMPREPLY=($(compgen -W '${flags[*]}' -- "$cur"))
+            [[ $COMPREPLY == *= ]] && compopt -o nospace
+            ;;
+    esac
+
+    case $prev in
+        -s) _known_hosts_real "$cur" ;;
+    esac
+}
+complete -F _pasuspender pasuspender
+
+_padsp () {
+    local cur prev
+    local flags='-h -s -n -m -M -S -D -d'
+
+    _get_comp_words_by_ref cur prev
+
+    case $cur in
+        -*) COMPREPLY=($(compgen -W '${flags[*]}' -- "$cur")) ;;
+    esac
+
+    case $prev in
+        -s) _known_hosts_real "$cur" ;;
+    esac
+}
+complete -F _padsp padsp
+
+_pacat () {
+    local cur prev comps
+    local flags='-h --help --version -r --record -p --playback -v --verbose -s
+                --server= -d --device= -n --client-name= --stream-name= --volume=
+                --rate= --format= --channels= --channel-map= --fix-format --fix-rate
+                --fix-channels --no-remix --no-remap --latency= --process-time=
+                --latency-msec= --process-time-msec= --property= --raw --passthrough
+                --file-format= --list-file-formats --monitor-stream='
+
+    _init_completion -n = || return
+
+    case $cur in
+        --server=*)
+            cur=${cur#*=}
+            _known_hosts_real "$cur"
+            ;;
+
+        --device=*)
+            cur=${cur#*=}
+            comps=$(__sinks)
+            comps+=" "$(__sources)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        --monitor-stream=*)
+            cur=${cur#*=}
+            comps=$(__sink_inputs)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        --rate=*)
+            cur=${cur#*=}
+            COMPREPLY=($(compgen -W '32000 44100 48000 9600 192000' -- "$cur"))
+            ;;
+
+        --file-format=*)
+            cur=${cur#*=}
+            comps=$(_pacat_file_formats)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        --*=*)
+            ;;
+
+        -*)
+            COMPREPLY=($(compgen -W '${flags[*]}' -- "$cur"))
+            [[ $COMPREPLY == *= ]] && compopt -o nospace
+            ;;
+        *) _filedir ;;
+    esac
+
+    case $prev in
+        -s) _known_hosts_real "$cur" ;;
+        -d)
+            comps=$(__sinks)
+            comps+=" "$(__sources)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+    esac
+}
+complete -F _pacat pacat paplay parec parecord
+
+_pulseaudio()
+{
+    local cur prev words cword
+    local flags='-h --help --version --dump-conf --dump-resample-methods --cleanup-shm
+                --start -k --kill --check --system= -D --daemonize= --fail= --high-priority=
+                --realtime= --disallow-module-loading= --disallow-exit= --exit-idle-time=
+                --scache-idle-time= --log-level= -v --log-target= --log-meta= --log-time=
+                --log-backtrace= -p --dl-search-path= --resample-method= --use-pit-file=
+                --no-cpu-limit= --disable-shm= --enable-memfd= -L --load= -F --file= -C -n'
+    _init_completion -n = || return
+
+    case $cur in
+        --system=*|--daemonize=*|--fail=*|--high-priority=*|--realtime=*| \
+            --disallow-*=*|--log-meta=*|--log-time=*|--use-pid-file=*| \
+            --no-cpu-limit=*|--disable-shm=*|--enable-memfd=*)
+            cur=${cur#*=}
+            COMPREPLY=($(compgen -W 'true false' -- "$cur"))
+            ;;
+
+        --log-target=*)
+            cur=${cur#*=}
+            COMPREPLY=($(compgen -W 'auto syslog stderr file: newfile:' -- "$cur"))
+            ;;
+
+        --log-level=*)
+            cur=${cur#*=}
+            COMPREPLY=($(compgen -W '{0..4}' -- "$cur"))
+            ;;
+
+        --dl-search-path=*)
+            cur=${cur#*=}
+            _filedir -d
+            ;;
+
+        --file=*)
+            cur=${cur#*=}
+            _filedir
+            ;;
+
+        --resample-method=*)
+            cur=${cur#*=}
+            comps=$(__resample_methods)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        --load=*)
+            cur=${cur#*=}
+            comps=$(__all_modules)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+
+        --*=*)
+            ;;
+
+        -*)
+            COMPREPLY=($(compgen -W '${flags[*]}' -- "$cur"))
+            [[ $COMPREPLY == *= ]] && compopt -o nospace
+            ;;
+    esac
+
+    case $prev in
+        -D) COMPREPLY=($(compgen -W 'true false' -- "$cur")) ;;
+        -p) _filedir -d ;;
+        -F) _filedir ;;
+        -L)
+            cur=${cur#*=}
+            comps=$(__all_modules)
+            COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
+            ;;
+    esac
+}
+complete -F _pulseaudio pulseaudio
+
+#vim: set ft=zsh sw=4 ts=4 noet
Index: create-16.1-posix-completion-patch/pulseaudio-16.1-new/shell-completion/bash
===================================================================
--- create-16.1-posix-completion-patch/pulseaudio-16.1-new/shell-completion/bash	(nonexistent)
+++ create-16.1-posix-completion-patch/pulseaudio-16.1-new/shell-completion/bash	(revision 5)

Property changes on: create-16.1-posix-completion-patch/pulseaudio-16.1-new/shell-completion/bash
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-posix-completion-patch/pulseaudio-16.1-new/shell-completion
===================================================================
--- create-16.1-posix-completion-patch/pulseaudio-16.1-new/shell-completion	(nonexistent)
+++ create-16.1-posix-completion-patch/pulseaudio-16.1-new/shell-completion	(revision 5)

Property changes on: create-16.1-posix-completion-patch/pulseaudio-16.1-new/shell-completion
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-posix-completion-patch/pulseaudio-16.1-new
===================================================================
--- create-16.1-posix-completion-patch/pulseaudio-16.1-new	(nonexistent)
+++ create-16.1-posix-completion-patch/pulseaudio-16.1-new	(revision 5)

Property changes on: create-16.1-posix-completion-patch/pulseaudio-16.1-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-posix-completion-patch
===================================================================
--- create-16.1-posix-completion-patch	(nonexistent)
+++ create-16.1-posix-completion-patch	(revision 5)

Property changes on: create-16.1-posix-completion-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-soxr-dependency-patch/create.patch.sh
===================================================================
--- create-16.1-soxr-dependency-patch/create.patch.sh	(nonexistent)
+++ create-16.1-soxr-dependency-patch/create.patch.sh	(revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=16.1
+
+tar --files-from=file.list -xJvf ../pulseaudio-$VERSION.tar.xz
+mv pulseaudio-$VERSION pulseaudio-$VERSION-orig
+
+cp -rf ./pulseaudio-$VERSION-new ./pulseaudio-$VERSION
+
+diff --unified -Nr  pulseaudio-$VERSION-orig  pulseaudio-$VERSION > pulseaudio-$VERSION-soxr-dependency.patch
+
+mv pulseaudio-$VERSION-soxr-dependency.patch ../patches
+
+rm -rf ./pulseaudio-$VERSION
+rm -rf ./pulseaudio-$VERSION-orig

Property changes on: create-16.1-soxr-dependency-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-16.1-soxr-dependency-patch/file.list
===================================================================
--- create-16.1-soxr-dependency-patch/file.list	(nonexistent)
+++ create-16.1-soxr-dependency-patch/file.list	(revision 5)
@@ -0,0 +1 @@
+pulseaudio-16.1/meson.build
Index: create-16.1-soxr-dependency-patch/pulseaudio-16.1-new/meson.build
===================================================================
--- create-16.1-soxr-dependency-patch/pulseaudio-16.1-new/meson.build	(nonexistent)
+++ create-16.1-soxr-dependency-patch/pulseaudio-16.1-new/meson.build	(revision 5)
@@ -0,0 +1,1062 @@
+project('pulseaudio', 'c', 'cpp',
+        version : run_command(find_program('git-version-gen'), join_paths(meson.current_source_dir(), '.tarball-version')).stdout().strip(),
+        meson_version : '>= 0.50.0',
+        default_options : [ 'c_std=gnu11', 'cpp_std=c++11' ]
+        )
+
+meson.add_dist_script('scripts/save-tarball-version.sh', meson.project_version())
+
+pa_version_str = meson.project_version()
+# For tarballs, the first split will do nothing, but for builds in git, we
+# split out suffixes when there are commits since the last tag
+# (e.g.: v11.99.1-3-gad14bdb24 -> v11.99.1)
+version_split = pa_version_str.split('-')[0].split('.')
+pa_version_major = version_split[0].split('v')[0]
+pa_version_minor = version_split[1]
+if version_split.length() > 2
+  pa_version_micro = version_split[2]
+else
+  pa_version_micro = '0'
+endif
+pa_version_major_minor = pa_version_major + '.' + pa_version_minor
+
+pa_api_version = 12
+pa_protocol_version = 35
+
+# The stable ABI for client applications, for the version info x:y:z
+# always will hold x=z
+libpulse_version_info = [24, 2, 24]
+
+# A simplified, synchronous, ABI-stable interface for client
+# applications, for the version info x:y:z always will hold x=z
+libpulse_simple_version_info = [1, 1, 1]
+
+# The ABI-stable GLib adapter for client applications, for the version
+# info x:y:z always will hold x=z
+libpulse_mainloop_glib_version_info = [0, 6, 0]
+
+libpulse_version = '@0@.@1@.@2@'.format(
+  libpulse_version_info[0] - libpulse_version_info[2],
+  libpulse_version_info[0],
+  libpulse_version_info[1],
+)
+
+libpulse_simple_version = '@0@.@1@.@2@'.format(
+  libpulse_simple_version_info[0] - libpulse_simple_version_info[2],
+  libpulse_simple_version_info[0],
+  libpulse_simple_version_info[1],
+)
+
+libpulse_mainloop_glib_version = '@0@.@1@.@2@'.format(
+  libpulse_mainloop_glib_version_info[0] - libpulse_mainloop_glib_version_info[2],
+  libpulse_mainloop_glib_version_info[0],
+  libpulse_mainloop_glib_version_info[1],
+)
+
+i18n = import('i18n')
+
+# Paths
+
+prefix = get_option('prefix')
+assert(prefix.startswith('/'), 'Prefix is not absolute: "@0@"'.format(prefix))
+
+bindir = join_paths(prefix, get_option('bindir'))
+includedir = join_paths(prefix, get_option('includedir'))
+libdir = join_paths(prefix, get_option('libdir'))
+libexecdir = join_paths(prefix, get_option('libexecdir'))
+mandir = join_paths(prefix, get_option('mandir'))
+datadir = join_paths(prefix, get_option('datadir'))
+localedir = join_paths(prefix, get_option('localedir'))
+localstatedir = join_paths(prefix, get_option('localstatedir'))
+sysconfdir = join_paths(prefix, get_option('sysconfdir'))
+privlibdir = join_paths(libdir, 'pulseaudio')
+po_dir = join_paths(meson.current_source_dir(), 'po')
+
+if host_machine.system() == 'windows'
+  # Windows only supports loading libraries from the same dir as the executable
+  privlibdir = bindir
+endif
+
+alsadatadir = get_option('alsadatadir')
+if alsadatadir == ''
+  alsadatadir = join_paths(datadir, 'pulseaudio', 'alsa-mixer')
+endif
+
+pkgconfigdir = join_paths(libdir, 'pkgconfig')
+pulselibexecdir = join_paths(libexecdir, 'pulse')
+pulsesysconfdir = join_paths(sysconfdir, 'pulse')
+
+modlibexecdir = get_option('modlibexecdir')
+if modlibexecdir == ''
+  modlibexecdir = join_paths(libdir, 'pulseaudio', 'modules')
+endif
+
+if host_machine.system() == 'windows'
+  # Windows only supports loading libraries from the same dir as the executable
+  modlibexecdir = bindir
+endif
+
+padsplibdir = get_option('padsplibdir')
+if padsplibdir == ''
+  padsplibdir = privlibdir
+endif
+
+pulsedsp_location = get_option('pulsedsp-location')
+if pulsedsp_location == ''
+  pulsedsp_location = join_paths(prefix, padsplibdir)
+endif
+
+systemduserunitdir = get_option('systemduserunitdir')
+# the default value is set below
+
+udevrulesdir = get_option('udevrulesdir')
+if udevrulesdir == ''
+  # absolute path, otherwise meson prepends the prefix
+  udevrulesdir = '/lib/udev/rules.d'
+endif
+
+vapidir = join_paths(datadir, 'vala', 'vapi')
+
+bashcompletiondir = get_option('bashcompletiondir')
+if bashcompletiondir == ''
+  bash_completion_dep = dependency('bash-completion', required : false)
+  if bash_completion_dep.found()
+    bashcompletiondir = bash_completion_dep.get_pkgconfig_variable('completionsdir')
+  else
+    bashcompletiondir = join_paths(datadir, 'bash-completion', 'completions')
+  endif
+endif
+
+zshcompletiondir = get_option('zshcompletiondir')
+if zshcompletiondir == ''
+  zshcompletiondir = join_paths(datadir, 'zsh', 'site-functions')
+endif
+
+# Configuration data
+
+cc = meson.get_compiler('c')
+
+cdata = configuration_data()
+cdata.set_quoted('PACKAGE', 'pulseaudio')
+cdata.set_quoted('PACKAGE_NAME', 'pulseaudio')
+cdata.set_quoted('PACKAGE_VERSION', pa_version_str)
+cdata.set('PA_MAJOR', pa_version_major)
+cdata.set('PA_MINOR', pa_version_minor)
+cdata.set('PA_API_VERSION', pa_api_version)
+cdata.set('PA_PROTOCOL_VERSION', pa_protocol_version)
+cdata.set_quoted('PA_MACHINE_ID', join_paths(sysconfdir, 'machine-id'))
+cdata.set_quoted('PA_MACHINE_ID_FALLBACK', join_paths(localstatedir, 'lib', 'dbus', 'machine-id'))
+cdata.set_quoted('PA_SRCDIR', join_paths(meson.current_source_dir(), 'src'))
+cdata.set_quoted('PA_BUILDDIR', meson.current_build_dir())
+cdata.set_quoted('PA_SOEXT', '.so')
+cdata.set_quoted('PA_DEFAULT_CONFIG_DIR', pulsesysconfdir)
+cdata.set('PA_DEFAULT_CONFIG_DIR_UNQUOTED', pulsesysconfdir)
+cdata.set_quoted('PA_BINARY', join_paths(bindir, 'pulseaudio'))
+cdata.set_quoted('PA_SYSTEM_RUNTIME_PATH', join_paths(localstatedir, 'run', 'pulse'))
+cdata.set_quoted('PA_SYSTEM_CONFIG_PATH', join_paths(localstatedir, 'lib', 'pulse'))
+cdata.set_quoted('PA_SYSTEM_STATE_PATH', join_paths(localstatedir, 'lib', 'pulse'))
+cdata.set_quoted('PA_DLSEARCHPATH', modlibexecdir)
+cdata.set_quoted('PA_SYSTEM_USER', get_option('system_user'))
+cdata.set_quoted('PA_SYSTEM_GROUP', get_option('system_group'))
+cdata.set_quoted('PA_ACCESS_GROUP', get_option('access_group'))
+cdata.set_quoted('PA_CFLAGS', 'Not yet supported on meson')
+cdata.set_quoted('PA_ALSA_PATHS_DIR', join_paths(alsadatadir, 'paths'))
+cdata.set_quoted('PA_ALSA_PROFILE_SETS_DIR', join_paths(alsadatadir, 'profile-sets'))
+cdata.set_quoted('DESKTOPFILEDIR', join_paths(datadir, 'applications'))
+cdata.set_quoted('PULSE_LOCALEDIR', localedir)
+cdata.set_quoted('GETTEXT_PACKAGE', 'pulseaudio')
+cdata.set('ENABLE_NLS', 1)
+cdata.set('top_srcdir', meson.source_root())
+
+# Platform specifics
+# First some defaults to keep config file generation happy
+cdata.set('HAVE_COREAUDIO', 0)
+cdata.set('HAVE_WAVEOUT', 0)
+cdata.set('OS_IS_FREEBSD', 0)
+
+platform_socket_dep = []
+platform_dep = []
+
+if host_machine.endian() == 'big'
+  cdata.set('WORDS_BIGENDIAN', 1)
+endif
+
+# FIXME: This was not tested. Maybe some flags should better be CFLAGS,
+# rather than ending up in the config.h file?
+if host_machine.system() == 'darwin'
+  cdata.set('OS_IS_DARWIN', 1)
+  cdata.set('_DARWIN_C_SOURCE', '200112L') # Needed to get NSIG on Mac OS
+elif host_machine.system() == 'windows'
+  cdata.set('OS_IS_WIN32', 1)
+  cdata.set('HAVE_WINDOWS_H', 1)
+  cdata.set('HAVE_WAVEOUT', 1)
+  cdata.set('HAVE_WINSOCK2_H', 1)
+  cdata.set('HAVE_WS2TCPIP_H', 1)
+  cdata.set('WIN32_LEAN_AND_MEAN', 1) # Needed to avoid including unnecessary headers on Windows
+  cdata.set('gid_t', 'int')
+  cdata.set('uid_t', 'int')
+  ws2_32_dep = meson.get_compiler('c').find_library('ws2_32')
+  winsock_dep = meson.get_compiler('c').find_library('wsock32')
+  ole32_dep = meson.get_compiler('c').find_library('ole32')
+  ssp_dep = meson.get_compiler('c').find_library('ssp')
+  pcreposix_dep = meson.get_compiler('c').find_library('pcreposix')
+  platform_socket_dep = [ws2_32_dep, winsock_dep]
+  platform_dep = [ole32_dep, ssp_dep, pcreposix_dep]
+elif host_machine.system() == 'freebsd'
+  cdata.set('OS_IS_FREEBSD', 1)
+#elif host_machine.system() == 'solaris'
+#  # Apparently meson has no solaris support?
+#  # Needed to get declarations for msg_control and msg_controllen on Solaris
+#  cdata.set('_XOPEN_SOURCE', 600)
+#  cdata.set('__EXTENSIONS__', 1)
+endif
+
+if cc.has_type('_Bool')
+  cdata.set('HAVE_STD_BOOL', 1)
+endif
+
+if host_machine.cpu_family() == 'x86_64' or cc.sizeof('void *') >= 8
+  cdata.set('HAVE_FAST_64BIT_OPERATIONS', 1)
+endif
+
+# Headers
+
+check_headers = [
+  'arpa/inet.h',
+  'byteswap.h',
+  'dlfcn.h',
+  'execinfo.h',
+  'grp.h',
+  'langinfo.h',
+  'linux/sockios.h',
+  'locale.h',
+  'netdb.h',
+  'netinet/in.h',
+  'netinet/in_systm.h',
+  'netinet/ip.h',
+  'netinet/tcp.h',
+  'pcreposix.h',
+  'poll.h',
+  'pwd.h',
+  'regex.h',
+  'sched.h',
+  'stdint.h',
+  'sys/atomic.h',
+  'sys/capability.h',
+  'sys/conf.h',
+  'sys/dl.h',
+  'sys/eventfd.h',
+  'sys/filio.h',
+  'sys/ioctl.h',
+  'sys/mman.h',
+  'sys/prctl.h',
+  'sys/resource.h',
+  'sys/select.h',
+  'sys/socket.h',
+  'sys/syscall.h',
+  'sys/uio.h',
+  'sys/un.h',
+  'sys/wait.h',
+  'syslog.h',
+  'xlocale.h',
+]
+
+foreach h : check_headers
+  if cc.has_header(h)
+    define = 'HAVE_' + h.underscorify().to_upper()
+    cdata.set(define, 1)
+  endif
+endforeach
+
+if cc.has_header('valgrind/memcheck.h', required: get_option('valgrind'))
+  cdata.set('HAVE_VALGRIND_MEMCHECK_H', 1)
+endif
+
+# FIXME: move this to the above set
+if host_machine.system() != 'windows'
+  if cc.has_header('pthread.h')
+    cdata.set('HAVE_PTHREAD', 1)
+  endif
+endif
+
+if cc.has_header_symbol('pthread.h', 'PTHREAD_PRIO_INHERIT')
+  cdata.set('HAVE_PTHREAD_PRIO_INHERIT', 1)
+endif
+
+# Headers which are usable
+
+check_usable_headers = [
+  'cpuid.h',
+]
+
+foreach h : check_usable_headers
+  if cc.check_header(h)
+    define = 'HAVE_' + h.underscorify().to_upper()
+    cdata.set(define, 1)
+  endif
+endforeach
+
+# Functions
+
+check_functions = [
+  'accept4',
+  'clock_gettime',
+  'ctime_r',
+  'fchmod',
+  'fchown',
+  'fork',
+  'fstat',
+  'getaddrinfo',
+  'getgrgid_r',
+  'getgrnam_r',
+  'getpwnam_r',
+  'getpwuid_r',
+  'gettimeofday',
+  'getuid',
+  'lrintf',
+  'lstat',
+  'memfd_create',
+  'mkfifo',
+  'mlock',
+  'nanosleep',
+  'open64',
+  'paccept',
+  'pipe',
+  'pipe2',
+  'posix_fadvise',
+  'posix_madvise',
+  'posix_memalign',
+  'ppoll',
+  'readlink',
+  'setegid',
+  'seteuid',
+  'setpgid',
+  'setregid',
+  'setresgid',
+  'setresuid',
+  'setreuid',
+  'setsid',
+  'sig2str',
+  'sigaction',
+  'strerror_r',
+  'strtod_l',
+  'strtof',
+  'symlink',
+  'sysconf',
+  'uname',
+]
+
+foreach f : check_functions
+  if cc.has_function(f)
+    define = 'HAVE_' + f.underscorify().to_upper()
+
+    if f == 'posix_memalign' and host_machine.system() == 'windows'
+      message('Win32/mingw32 does not properly define posix_memalign.')
+    elif f == 'fork' and host_machine.system() == 'windows'
+      # __builtin_fork is defined and compiles properly, but calling __builtin_fork() does not.
+      # This causes Meson to think that Windows has a fork() which causes a link error...
+      message('Win32/mingw32 does not properly define fork.')
+    else
+      cdata.set(define, 1)
+    endif
+  endif
+endforeach
+
+if cc.has_header_symbol('sys/syscall.h', 'SYS_memfd_create') \
+  or cc.has_function('memfd_create')
+  cdata.set('HAVE_MEMFD', 1)
+endif
+
+if cc.has_function('dgettext')
+  if host_machine.system() != 'windows'
+    libintl_dep = []
+  else
+    libintl_dep = cc.find_library('intl')
+  endif
+else
+  libintl_dep = cc.find_library('intl')
+endif
+
+# Symbols
+
+if cc.has_header_symbol('signal.h', 'SIGXCPU')
+  cdata.set('HAVE_SIGXCPU', 1)
+endif
+
+if not cc.has_header_symbol('netinet/in.h', 'INADDR_NONE')
+  if not cc.has_header_symbol('winsock2.h', 'INADDR_NONE')
+    # Define INADDR_NONE if not found (Solaris)
+    cdata.set('INADDR_NONE', '0xffffffff')
+  endif
+endif
+
+check_decls = [
+  [ 'environ', 'unistd.h', '#define _GNU_SOURCE' ],
+  [ 'SOUND_PCM_READ_RATE', 'sys/soundcard.h', '' ],
+  [ 'SOUND_PCM_READ_CHANNELS', 'sys/soundcard.h', '' ],
+  [ 'SOUND_PCM_READ_BITS', 'sys/soundcard.h', '' ],
+]
+
+foreach s : check_decls
+  if cc.has_header_symbol(s[1], s[0], prefix : s[2])
+    define = 'HAVE_DECL_' + s[0].to_upper()
+    cdata.set(define, 1)
+  endif
+endforeach
+
+# Types
+
+# FIXME: do we ever care about gid_t not being defined / smaller than an int?
+cdata.set('GETGROUPS_T', 'gid_t')
+
+# Include paths
+
+configinc = include_directories('.')
+topinc = include_directories('src')
+
+# CFLAGS/LDFLAGS
+
+pa_c_args = ['-DHAVE_CONFIG_H', '-D_GNU_SOURCE']
+server_c_args = ['-D__INCLUDED_FROM_PULSE_AUDIO']
+cdata.set('MESON_BUILD', 1)
+
+# On ELF systems we don't want the libraries to be unloaded since we don't clean them up properly,
+# so we request the nodelete flag to be enabled.
+# On other systems, we don't really know how to do that, but it's welcome if somebody can tell.
+# Windows doesn't support this flag.
+if host_machine.system() != 'windows'
+  nodelete_link_args = ['-Wl,-z,nodelete']
+else
+  nodelete_link_args = []
+endif
+
+# Code coverage
+
+if get_option('gcov')
+  add_project_arguments('--coverage', language: ['c', 'cpp'])
+  add_project_link_arguments('--coverage', language: ['c', 'cpp'])
+endif
+
+# Core Dependencies
+
+libm_dep = cc.find_library('m', required : true)
+
+thread_dep = dependency('threads')
+foreach f : [
+  'pthread_getname_np',
+  'pthread_setaffinity_np',
+  'pthread_setname_np',
+]
+  if cc.has_function(f, dependencies : thread_dep)
+    define = 'HAVE_' + f.underscorify().to_upper()
+    cdata.set(define, 1)
+  endif
+endforeach
+
+cap_dep = cc.find_library('cap', required : false)
+
+shm_dep = cc.find_library('rt', required : false)
+if cc.has_function('shm_open', dependencies : shm_dep)
+  cdata.set('HAVE_SHM_OPEN', 1)
+endif
+
+dl_dep = cc.find_library('dl', required : false)
+if cc.has_function('dladdr', dependencies : dl_dep)
+  cdata.set('HAVE_DLADDR', 1)
+endif
+
+have_iconv = false
+if cc.has_function('iconv_open')
+  iconv_dep = dependency('', required : false)
+  have_iconv = true
+  # tell the libiconv header to pretend to be libc iconv
+  cdata.set('LIBICONV_PLUG', 1)
+else
+  iconv_dep = cc.find_library('iconv', required : false)
+  have_iconv = iconv_dep.found()
+endif
+if have_iconv
+  cdata.set('HAVE_ICONV', 1)
+  iconvconsttest = '''#include <iconv.h>
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+'''
+  if cc.compiles(iconvconsttest, dependencies : iconv_dep)
+    cdata.set('ICONV_CONST', '')
+  else
+    cdata.set('ICONV_CONST', 'const')
+  endif
+endif
+
+# Used for backtraces on BSD
+execinfo_dep = cc.find_library('execinfo', required : false)
+
+# Atomic operations
+
+if get_option('atomic-arm-memory-barrier')
+    cdata.set('ATOMIC_ARM_MEMORY_BARRIER_ENABLED', 1)
+endif
+
+need_libatomic_ops = false
+
+atomictest = '''void func() {
+  volatile int atomic = 2;
+  __sync_bool_compare_and_swap (&atomic, 2, 3);
+}
+'''
+
+if cc.compiles(atomictest)
+  cdata.set('HAVE_ATOMIC_BUILTINS', 1)
+
+  newatomictest = '''void func() {
+    int c = 0;
+    __atomic_store_n(&c, 4, __ATOMIC_SEQ_CST);
+  }
+  '''
+
+  if(cc.compiles(newatomictest))
+    cdata.set('HAVE_ATOMIC_BUILTINS_MEMORY_MODEL', 1)
+  endif
+
+elif host_machine.cpu_family() == 'arm'
+  if host_machine.system() == 'linux' and get_option('atomic-arm-linux-helpers')
+    cdata.set('ATOMIC_ARM_LINUX_HELPERS', 1)
+  else
+    armatomictest = '''int func() {
+      volatile int a=0;
+      int o=0, n=1, r;
+      asm volatile (
+	      "ldrex    %0, [%1]\n"
+	      "subs  %0, %0, %2\n"
+	      "strexeq %0, %3, [%1]\n"
+	      : "=&r" (r)
+	      : "r" (&a), "Ir" (o), "r" (n)
+      : "cc");
+      return (a==1 ? 0 : -1);
+    }
+    '''
+
+    if cc.compiles(armatomictest)
+      cdata.set('ATOMIC_ARM_INLINE_ASM', 1)
+    else
+      need_libatomic_ops = true
+    endif
+  endif # arm && !linux
+
+elif not ['freebsd', 'netbsd'].contains(host_machine.system())
+  need_libatomic_ops = true
+endif # !atomic helpers && !arm
+
+if need_libatomic_ops
+  assert(cc.has_header('atomic_ops.h'), 'Need libatomic_ops')
+
+  cdata.set('AO_REQUIRE_CAS', 1)
+
+  if host_machine.system() != 'windows'
+    libatomic_ops_dep = cc.find_library('atomic_ops', required : true)
+  else
+    libatomic_ops_dep = dependency('', required: false)
+  endif
+else
+  libatomic_ops_dep = dependency('', required: false)
+endif
+
+# ARM checks
+# ARMV6 instructions we need
+if host_machine.cpu_family() == 'arm'
+  armv6test = '''int func() {
+    volatile int a = -60000, b = 0xaaaabbbb, c = 0xccccdddd;
+    asm volatile ("ldr r0, %2 \n"
+                  "ldr r2, %3 \n"
+                  "ldr r3, %4 \n"
+                  "ssat r1, #8, r0 \n"
+                  "str r1, %0 \n"
+                  "pkhbt r1, r3, r2, LSL #8 \n"
+                  "str r1, %1 \n"
+                  : "=m" (a), "=m" (b)
+                  : "m" (a), "m" (b), "m" (c)
+                  : "r0", "r1", "r2", "r3", "cc");
+    return (a == -128 && b == 0xaabbdddd) ? 0 : -1;
+  }
+  '''
+
+  if cc.compiles(armv6test)
+    cdata.set('HAVE_ARMV6', 1)
+  endif
+endif
+# NEON checks are automatically done by the unstable-simd module
+
+# Dependencies common to client, daemon and modules
+
+if get_option('ipv6')
+  cdata.set('HAVE_IPV6', 1)
+endif
+
+dbus_dep = dependency('dbus-1', version : '>= 1.4.12', required : get_option('dbus'))
+if dbus_dep.found()
+  cdata.set('HAVE_DBUS', 1)
+endif
+
+glib_dep = dependency('glib-2.0', version : '>= 2.28.0', required: get_option('glib'))
+if glib_dep.found()
+  cdata.set('HAVE_GLIB', 1)
+  cdata.set('HAVE_GLIB20', 1) # to match the AM_CONDITIONAL for CMake file generation
+endif
+
+sndfile_dep = dependency('sndfile', version : '>= 1.0.20')
+
+libsystemd_dep = dependency('libsystemd', required : get_option('systemd'))
+if libsystemd_dep.found()
+  cdata.set('HAVE_SYSTEMD_DAEMON', 1)
+  cdata.set('HAVE_SYSTEMD_LOGIN', 1)
+  cdata.set('HAVE_SYSTEMD_JOURNAL', 1)
+endif
+
+x11_dep = dependency('x11-xcb', required : get_option('x11'))
+
+# OSS support
+if cc.has_header('sys/soundcard.h', required: get_option('oss-output'))
+  # OSS output via daemon module-detect
+  cdata.set('HAVE_OSS_OUTPUT', 1)
+  # OSS wrapper
+  cdata.set('HAVE_OSS_WRAPPER', 1)
+  cdata.set('PULSEDSP_LOCATION', pulsedsp_location)
+endif
+
+fftw_dep = dependency('fftw3f', required : get_option('fftw'))
+if fftw_dep.found()
+  cdata.set('HAVE_FFTW', 1)
+endif
+
+# Client library dependencies
+
+if get_option('client')
+  asyncns_dep = dependency('libasyncns', version : '>= 0.1', required : get_option('asyncns'))
+  if asyncns_dep.found()
+    cdata.set('HAVE_LIBASYNCNS', 1)
+  endif
+
+  gtk_dep = dependency('gtk+-3.0', required : get_option('gtk'))
+  if gtk_dep.found()
+    cdata.set('HAVE_GTK', 1)
+  endif
+endif
+
+# Daemon and module dependencies
+
+if get_option('daemon')
+  # FIXME: make sure it's >= 2.2
+  ltdl_dep = cc.find_library('ltdl', required : true)
+
+  # FIXME: can meson support libtool -dlopen/-dlpreopen things?
+  #        and do we still want to support this at all?
+  cdata.set('DISABLE_LIBTOOL_PRELOAD', 1)
+
+  if get_option('database') == 'tdb'
+    database_dep = dependency('tdb')
+  elif get_option('database') == 'gdbm'
+    database_dep = cc.find_library('gdbm', required : true)
+  else
+    database_dep = dependency('', required: false)
+  endif
+
+  if get_option('legacy-database-entry-format')
+    cdata.set('ENABLE_LEGACY_DATABASE_ENTRY_FORMAT', 1)
+  endif
+
+  if get_option('stream-restore-clear-old-devices')
+    cdata.set('STREAM_RESTORE_CLEAR_OLD_DEVICES', 1)
+  endif
+
+  if get_option('running-from-build-tree')
+    cdata.set('HAVE_RUNNING_FROM_BUILD_TREE', 1)
+  endif
+
+  if get_option('enable-smoother-2')
+    cdata.set('USE_SMOOTHER_2', 1)
+  endif
+
+  alsa_dep = dependency('alsa', version : '>= 1.0.24', required : get_option('alsa'))
+  if alsa_dep.found()
+    cdata.set('HAVE_ALSA', 1)
+    cdata.set('HAVE_ALSA_UCM', 1)
+  endif
+
+  gio_dep = dependency('gio-2.0', version : '>= 2.26.0')
+  if get_option('gsettings').enabled()
+    assert(gio_dep.found(), 'GSettings support needs glib I/O library (GIO)')
+    cdata.set('HAVE_GSETTINGS', 1)
+  else
+    cdata.set('HAVE_GSETTINGS', 0)
+  endif
+
+  have_orcc = false
+  orcc_args = []
+  orc_dep = dependency('orc-0.4', version : '>= 0.4.11', required : get_option('orc'))
+  orcc = find_program('orcc', required : get_option('orc'))
+  if orc_dep.found() and orcc.found()
+    have_orcc = true
+    orcc_args = [orcc]
+    #orcc_args = [orcc, '--include', 'glib.h']
+    cdata.set('HAVE_ORC', 1)
+  else
+    cdata.set('DISABLE_ORC', 1)
+  endif
+
+  samplerate_dep = dependency('samplerate', version : '>= 0.1.0', required : get_option('samplerate'))
+  if samplerate_dep.found()
+    cdata.set('HAVE_LIBSAMPLERATE', 1)
+  endif
+
+  speex_dep = dependency('speexdsp', version : '>= 1.2', required : get_option('speex'))
+  if speex_dep.found()
+    cdata.set('HAVE_SPEEX', 1)
+  endif
+
+  soxr_dep = cc.find_library('soxr')
+  if soxr_dep.found()
+    cdata.set('HAVE_SOXR', 1)
+  endif
+
+  webrtc_dep = dependency('webrtc-audio-processing', version : '>= 0.2', required : get_option('webrtc-aec'))
+  if webrtc_dep.found()
+    cdata.set('HAVE_WEBRTC', 1)
+  endif
+
+  systemd_dep = dependency('systemd', required : get_option('systemd'))
+  if systemd_dep.found() and systemduserunitdir == ''
+    systemduserunitdir = systemd_dep.get_pkgconfig_variable('systemduserunitdir')
+  endif
+
+  libelogind_dep = dependency('libelogind', required : get_option('elogind'))
+  if libelogind_dep.found()
+    cdata.set('HAVE_SYSTEMD_LOGIN', 1)
+  endif
+
+  tcpwrap_dep = cc.find_library('wrap', required: get_option('tcpwrap'))
+  if cc.has_header('tcpd.h') and cc.has_function('hosts_access', dependencies : tcpwrap_dep)
+    cdata.set('HAVE_LIBWRAP', 1)
+  endif
+
+  if x11_dep.found()
+    xcb_dep  = dependency('xcb',  required : true, version : '>= 1.6')
+    ice_dep  = dependency('ice',  required : true)
+    sm_dep   = dependency('sm',   required : true)
+    xtst_dep = dependency('xtst', required : true)
+    cdata.set('HAVE_X11', 1)
+    if cc.has_function('XSetIOErrorExitHandler', dependencies: x11_dep)
+      cdata.set('HAVE_XSETIOERROREXITHANDLER', 1)
+    endif
+  endif
+
+  avahi_dep = dependency('avahi-client', version : '>= 0.6.0', required : get_option('avahi'), disabler : true)
+  if avahi_dep.found()
+    cdata.set('HAVE_AVAHI', 1)
+  else
+    cdata.set('HAVE_AVAHI', 0)
+  endif
+
+  sbc_dep = dependency('sbc', version : '>= 1.0', required : false)
+
+  bluez_dep = dependency('bluez', required : get_option('bluez5'))
+
+  if bluez_dep.found()
+    assert(dbus_dep.found(), 'BlueZ requires D-Bus support')
+    assert(sbc_dep.found(), 'BlueZ requires SBC support')
+    cdata.set('HAVE_SBC', 1)
+    cdata.set('HAVE_BLUEZ', 1)
+    cdata.set('HAVE_BLUEZ_5', 1)
+    if get_option('bluez5-native-headset')
+      cdata.set('HAVE_BLUEZ_5_NATIVE_HEADSET', 1)
+    endif
+    if get_option('bluez5-ofono-headset')
+      cdata.set('HAVE_BLUEZ_5_OFONO_HEADSET', 1)
+    endif
+  endif
+
+  jack_dep = dependency('jack', version : '>= 0.117.0', required : get_option('jack'))
+  if jack_dep.found()
+    cdata.set('HAVE_JACK', 1)
+  endif
+
+  lirc_dep = dependency('lirc', required : get_option('lirc'))
+  if lirc_dep.found()
+    cdata.set('HAVE_LIRC', 1)
+  endif
+
+  openssl_dep = dependency('openssl', version : '>= 0.9', required : get_option('openssl'))
+  if openssl_dep.found()
+    cdata.set('HAVE_OPENSSL', 1)
+  endif
+
+  udev_dep = dependency('libudev', version : '>= 143', required : get_option('udev'))
+  if udev_dep.found()
+    cdata.set('HAVE_UDEV', 1)
+  endif
+
+  if get_option('hal-compat')
+    cdata.set('HAVE_HAL_COMPAT', 1)
+  endif
+
+  gst_dep = dependency('gstreamer-1.0', version : '>= 1.14', required : get_option('gstreamer'))
+  gstapp_dep = dependency('gstreamer-app-1.0', required : get_option('gstreamer'))
+  gstrtp_dep = dependency('gstreamer-rtp-1.0', required : get_option('gstreamer'))
+
+  have_gstreamer = false
+  if gst_dep.found() and gstapp_dep.found() and gstrtp_dep.found()
+    assert(gio_dep.found(), 'GStreamer-based RTP needs glib I/O library (GIO)')
+    have_gstreamer = true
+  endif
+
+  bluez5_gst_dep = dependency('gstreamer-1.0', version : '>= 1.14', required : get_option('bluez5-gstreamer'))
+  bluez5_gstapp_dep = dependency('gstreamer-app-1.0', required : get_option('bluez5-gstreamer'))
+  have_bluez5_gstreamer = false
+  if bluez5_gst_dep.found() and bluez5_gstapp_dep.found()
+    have_bluez5_gstreamer = true
+    cdata.set('HAVE_GSTLDAC', 1)
+    cdata.set('HAVE_GSTAPTX', 1)
+  endif
+endif
+
+# These are required for the CMake file generation
+cdata.set('PA_LIBDIR', libdir)
+cdata.set('PA_INCDIR', includedir)
+
+# Test dependencies
+
+check_dep = dependency('check', version : '>= 0.9.10', required : get_option('tests'))
+
+# Subdirs
+
+if get_option('doxygen')
+  subdir('doxygen')
+endif
+if get_option('client')
+  subdir('po')
+endif
+if get_option('man')
+  subdir('man')
+endif
+subdir('shell-completion/bash')
+subdir('shell-completion/zsh')
+subdir('src')
+if get_option('client')
+ subdir('vala')
+endif
+
+# Now generate config.h from everything above
+configure_file(output : 'config.h', configuration : cdata)
+
+if get_option('client')
+
+  # pkg-config files
+
+  pc_cdata = configuration_data()
+
+  pc_cdata.set('prefix', prefix)
+  pc_cdata.set('exec_prefix', prefix)
+  pc_cdata.set('libdir', libdir)
+  pc_cdata.set('includedir', includedir)
+  pc_cdata.set('modlibexecdir', modlibexecdir)
+  pc_cdata.set('PACKAGE_VERSION', pa_version_str)
+  pc_cdata.set('PA_MAJORMINOR', pa_version_major_minor)
+  # FIXME: the line below is wrong. Currently the meson thread dep lacks documentation,
+  # and doesn't allow introspection, ie. none of get_pkgconfig_variable() or
+  # get_configtool_variable() work with it, so we have no way to get this flag right,
+  # unless we do all the work ourselves. See current work in glib, also meson #553.
+  pc_cdata.set('PTHREAD_LIBS', '-pthread')
+
+  pc_files = [
+    'libpulse.pc',
+    'libpulse-simple.pc',
+  ]
+
+  if glib_dep.found()
+    pc_files += 'libpulse-mainloop-glib.pc'
+  endif
+
+  foreach file : pc_files
+    configure_file(
+      input : file + '.in',
+      output : file,
+      configuration : pc_cdata,
+      install_dir : pkgconfigdir)
+  endforeach
+
+  # CMake files
+
+  m4 = find_program('m4', required: true)
+
+  cmakedir = join_paths(libdir, 'cmake', 'PulseAudio')
+
+  cmake_template_file = configure_file(
+    input : 'PulseAudioConfig.cmake.in',
+    output : 'PulseAudioConfig.cmake.tmp',
+    configuration: cdata,
+  )
+
+  custom_target('PulseAudioConfig.cmake',
+    input : cmake_template_file,
+    output : 'PulseAudioConfig.cmake',
+    capture : true,
+    command : [m4, '@INPUT@'],
+    build_by_default : true,
+    install : true,
+    install_dir : cmakedir,
+  )
+
+  configure_file(
+    input : 'PulseAudioConfigVersion.cmake.in',
+    output : 'PulseAudioConfigVersion.cmake',
+    configuration: cdata,
+    install : true,
+    install_dir : cmakedir,
+  )
+
+endif # client
+
+############################################################
+
+# Final summary
+
+summary = [
+  '',
+  '---{ @0@ @1@ }---'.format(meson.project_name(), meson.project_version()),
+  '',
+  'prefix:                        @0@'.format(prefix),
+  'bindir:                        @0@'.format(bindir),
+  'libdir:                        @0@'.format(libdir),
+  'libexecdir:                    @0@'.format(libexecdir),
+  'mandir:                        @0@'.format(mandir),
+  'datadir:                       @0@'.format(datadir),
+  'sysconfdir:                    @0@'.format(sysconfdir),
+  'localstatedir:                 @0@'.format(localstatedir),
+  'modlibexecdir:                 @0@'.format(modlibexecdir),
+  'alsadatadir:                   @0@'.format(alsadatadir),
+  'System Runtime Path:           @0@'.format(cdata.get_unquoted('PA_SYSTEM_RUNTIME_PATH')),
+  'System State Path:             @0@'.format(cdata.get_unquoted('PA_SYSTEM_STATE_PATH')),
+  'System Config Path:            @0@'.format(cdata.get_unquoted('PA_SYSTEM_CONFIG_PATH')),
+  'Bash completions directory:    @0@'.format(bashcompletiondir),
+  'Zsh completions directory:     @0@'.format(zshcompletiondir),
+  'Compiler:                      @0@ @1@'.format(cc.get_id(), cc.version()),
+#  'CFLAGS:                        @0@'.format(${CFLAGS}),
+#  'CPPFLAGS:                      @0@'.format(${CPPFLAGS}),
+#  'LIBS:                          @0@'.format(${LIBS}),
+  '',
+  'Enable pulseaudio daemon:      @0@'.format(get_option('daemon')),
+  'Enable pulseaudio client:      @0@'.format(get_option('client')),
+  '',
+  'Enable memfd shared memory:    @0@'.format(cdata.has('HAVE_MEMFD')),
+  'Enable X11:                    @0@'.format(x11_dep.found()),
+  'Enable D-Bus:                  @0@'.format(dbus_dep.found()),
+  'Enable GLib 2:                 @0@'.format(glib_dep.found()),
+  'Enable systemd integration:    @0@'.format(libsystemd_dep.found()),
+  'Enable FFTW:                   @0@'.format(fftw_dep.found()),
+  'Enable IPv6:                   @0@'.format(get_option('ipv6')),
+  'Enable Gcov coverage:          @0@'.format(get_option('gcov')),
+  'Enable Valgrind:               @0@'.format(cdata.has('HAVE_VALGRIND_MEMCHECK_H')),
+  'Enable man pages:              @0@'.format(get_option('man')),
+  'Enable unit tests:             @0@'.format(get_option('tests')),
+]
+
+if get_option('client')
+summary += [
+  '',
+  '--- Pulseaudio client features ---',
+  '',
+  'Enable Gtk+ 3:                 @0@'.format(gtk_dep.found()),
+  'Enable Async DNS:              @0@'.format(asyncns_dep.found()),
+  'Enable OSS Wrapper:            @0@'.format(cdata.has('HAVE_OSS_WRAPPER')),
+]
+endif
+
+if get_option('daemon')
+summary += [
+  '',
+  '--- Pulseaudio daemon features ---',
+  '',
+  'Safe X11 I/O errors:           @0@'.format(cdata.has('HAVE_XSETIOERROREXITHANDLER')),
+  'Enable Avahi:                  @0@'.format(avahi_dep.found()),
+  'Enable OSS Output:             @0@'.format(cdata.has('HAVE_OSS_OUTPUT')),
+#  'Enable EsounD:                 @0@'.format(${ENABLE_ESOUND}),
+  'Enable Alsa:                   @0@'.format(alsa_dep.found()),
+  'Enable Jack:                   @0@'.format(jack_dep.found()),
+  'Enable LIRC:                   @0@'.format(lirc_dep.found()),
+#  'Enable CoreAudio:              @0@'.format(${ENABLE_COREAUDIO}),
+#  'Enable Solaris:                @0@'.format(${ENABLE_SOLARIS}),
+#  'Enable WaveOut:                @0@'.format(${ENABLE_WAVEOUT}),
+  'Enable GSettings:              @0@'.format(gio_dep.found()),
+  'Enable BlueZ 5:              @0@'.format(cdata.has('HAVE_BLUEZ_5')),
+  '  Enable native headsets:    @0@'.format(cdata.has('HAVE_BLUEZ_5_NATIVE_HEADSET')),
+  '  Enable  ofono headsets:    @0@'.format(cdata.has('HAVE_BLUEZ_5_OFONO_HEADSET')),
+  '  Enable GStreamer based codecs: @0@'.format(have_bluez5_gstreamer),
+  'Enable GStreamer:              @0@'.format(have_gstreamer),
+  'Enable libsamplerate:          @0@'.format(samplerate_dep.found()),
+  'Enable ORC:                    @0@'.format(have_orcc),
+  'Enable Adrian echo canceller:  @0@'.format(get_option('adrian-aec')),
+  'Enable Speex (resampler, AEC): @0@'.format(speex_dep.found()),
+  'Enable SoXR (resampler):       @0@'.format(soxr_dep.found()),
+  'Enable WebRTC echo canceller:  @0@'.format(webrtc_dep.found()),
+  '',
+  'Enable udev:                   @0@'.format(udev_dep.found()),
+  '  Enable HAL->udev compat:     @0@'.format(get_option('hal-compat')),
+  'Enable systemd units:          @0@'.format(systemd_dep.found()),
+  'Enable elogind:                @0@'.format(libelogind_dep.found()),
+  'Enable TCP Wrappers:           @0@'.format(tcpwrap_dep.found()),
+  'Enable OpenSSL (for Airtunes): @0@'.format(openssl_dep.found()),
+  'Database:                      @0@'.format(get_option('database')),
+  'Legacy Database Entry Support: @0@'.format(get_option('legacy-database-entry-format')),
+  'module-stream-restore:',
+  '  Clear old devices:           @0@'.format(get_option('stream-restore-clear-old-devices')),
+  'Running from build tree:       @0@'.format(get_option('running-from-build-tree')),
+  'System User:                   @0@'.format(cdata.get_unquoted('PA_SYSTEM_USER')),
+  'System Group:                  @0@'.format(cdata.get_unquoted('PA_SYSTEM_GROUP')),
+  'Access Group:                  @0@'.format(cdata.get_unquoted('PA_ACCESS_GROUP')),
+#  'Enable per-user EsounD socket: @0@'.format(${ENABLE_PER_USER_ESOUND_SOCKET}),
+#  'Force preopen:                 @0@'.format(${FORCE_PREOPEN}),
+#  'Preopened modules:             @0@'.format(${PREOPEN_MODS}),
+]
+endif
+
+message('\n    '.join(summary))
+
+# Sanity checks
+
+if get_option('daemon') and not speex_dep.found() and not webrtc_dep.found() and not get_option('adrian-aec')
+  error('At least one echo canceller implementation must be available!')
+endif
+
+if get_option('daemon') and samplerate_dep.found()
+  warning('Support for libsamplerate is DEPRECATED')
+endif
+
+if host_machine.system() != 'windows' and not dbus_dep.found()
+  message = [
+    'You do not have D-Bus support enabled. It is strongly recommended',
+    'that you enable D-Bus support if your platform supports it.',
+    'Many parts of PulseAudio use D-Bus, from ConsoleKit interaction',
+    'to the Device Reservation Protocol to speak to JACK, Bluetooth',
+    'support and even a native control protocol for communicating and',
+    'controlling the PulseAudio daemon itself.',
+  ]
+  warning('\n' + '\n'.join(message))
+endif
+
+if get_option('daemon') and host_machine.system() == 'linux' and not udev_dep.found()
+  message = [
+    'You do not have udev support enabled. It is strongly recommended',
+    'that you enable udev support if your platform supports it as it is',
+    'the primary method used to detect hardware audio devices (on Linux)',
+    'and is thus a critical part of PulseAudio on that platform.',
+  ]
+  warning('\n' + '\n'.join(message))
+endif
+
+if get_option('daemon') and host_machine.system() != 'windows' and not speex_dep.found()
+  message = [
+    'You do not have speex support enabled. It is strongly recommended',
+    'that you enable speex support if your platform supports it as it is',
+    'the primary method used for audio resampling and is thus a critical',
+    'part of PulseAudio on that platform.',
+  ]
+  warning('\n' + '\n'.join(message))
+endif
Index: create-16.1-soxr-dependency-patch/pulseaudio-16.1-new
===================================================================
--- create-16.1-soxr-dependency-patch/pulseaudio-16.1-new	(nonexistent)
+++ create-16.1-soxr-dependency-patch/pulseaudio-16.1-new	(revision 5)

Property changes on: create-16.1-soxr-dependency-patch/pulseaudio-16.1-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-16.1-soxr-dependency-patch
===================================================================
--- create-16.1-soxr-dependency-patch	(nonexistent)
+++ create-16.1-soxr-dependency-patch	(revision 5)

Property changes on: create-16.1-soxr-dependency-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: patches/README
===================================================================
--- patches/README	(nonexistent)
+++ patches/README	(revision 5)
@@ -0,0 +1,6 @@
+
+/* begin *
+
+   TODO: Leave some comment here.
+
+ * end */
Index: patches
===================================================================
--- patches	(nonexistent)
+++ patches	(revision 5)

Property changes on: patches
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: .
===================================================================
--- .	(nonexistent)
+++ .	(revision 5)

Property changes on: .
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~