[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.15-249-g32e2cd6

Lennart Poettering gitmailer-noreply at 0pointer.de
Fri Jun 19 12:00:05 PDT 2009


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  6ad38556395fa1ee2020abb258e5f814fef8ad34 (commit)

- Log -----------------------------------------------------------------
32e2cd6 core: get rid of rt sig/timer handling since modern Linux' ppooll() is finally fixed for granularity
a62db27 daemon: enable real-time by default
06ec5fd mergo
9c438bc daemon: strip all special suid/caps log from our startup code, we'll now rely on RealtimeKit for all high-priority/RT scheduling policy issues
bacc5ca core: use rtkit to acquire high-priority scheduling
8474fd7 core: ask RealtimeKit for RT scheduling
-----------------------------------------------------------------------

Summary of changes:
 configure.ac                                    |   54 ------
 src/Makefile.am                                 |   24 +--
 src/daemon/caps.c                               |   99 ++---------
 src/daemon/caps.h                               |    3 -
 src/daemon/daemon-conf.c                        |    2 +-
 src/daemon/daemon.conf.in                       |    2 +-
 src/daemon/main.c                               |  203 ++---------------------
 src/modules/alsa/alsa-sink.c                    |    1 -
 src/modules/alsa/alsa-source.c                  |    1 -
 src/modules/bluetooth/module-bluetooth-device.c |    1 -
 src/modules/jack/module-jack-sink.c             |    1 -
 src/modules/jack/module-jack-source.c           |    1 -
 src/modules/module-combine.c                    |    1 -
 src/modules/module-esound-sink.c                |    1 -
 src/modules/module-null-sink.c                  |    1 -
 src/modules/module-pipe-sink.c                  |    1 -
 src/modules/module-pipe-source.c                |    1 -
 src/modules/module-sine-source.c                |    1 -
 src/modules/module-tunnel.c                     |    1 -
 src/modules/oss/module-oss.c                    |    1 -
 src/modules/raop/module-raop-sink.c             |    1 -
 src/pulsecore/core-util.c                       |  204 ++++++++++++-----------
 src/pulsecore/core-util.h                       |    3 -
 src/pulsecore/rtkit.c                           |  189 +++++++++++++++++++++
 src/pulsecore/rtkit.h                           |   62 +++++++
 src/pulsecore/rtpoll.c                          |  176 +-------------------
 src/pulsecore/rtpoll.h                          |    3 -
 src/pulsecore/rtsig.c                           |  131 ---------------
 src/pulsecore/rtsig.h                           |   39 -----
 src/tests/rtpoll-test.c                         |    6 -
 30 files changed, 397 insertions(+), 817 deletions(-)
 create mode 100644 src/pulsecore/rtkit.c
 create mode 100644 src/pulsecore/rtkit.h
 delete mode 100644 src/pulsecore/rtsig.c
 delete mode 100644 src/pulsecore/rtsig.h

-----------------------------------------------------------------------

commit 8474fd7c62712470465800ddccd6ea291d04151e
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Jun 19 04:19:08 2009 +0200

    core: ask RealtimeKit for RT scheduling

diff --git a/src/Makefile.am b/src/Makefile.am
index 92453ad..59f5fff 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -573,6 +573,7 @@ libpulsecommon_ at PA_MAJORMINORMICRO@_la_SOURCES = \
 		pulsecore/conf-parser.c pulsecore/conf-parser.h \
 		pulsecore/core-error.c pulsecore/core-error.h \
 		pulsecore/core-util.c pulsecore/core-util.h \
+		pulsecore/rtkit.c pulsecore/rtkit.h \
 		pulsecore/creds.h \
 		pulsecore/dynarray.c pulsecore/dynarray.h \
 		pulsecore/endianmacros.h \
@@ -1735,6 +1736,11 @@ update-reserve:
 		wget -O modules/$$i http://git.0pointer.de/\?p=reserve.git\;a=blob_plain\;f=$$i\;hb=master ; \
 	done
 
+update-rtkit:
+	for i in rtkit.c rtkit.h ; do \
+		wget -O pulsecore/$$i http://git.0pointer.de/\?p=rtkit.git\;a=blob_plain\;f=$$i\;hb=master ; \
+	done
+
 # Automatically generate linker version script. We use the same one for all public .sos
 update-map-file:
 	( echo "PULSE_0 {" ; \
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index a71ba0b..1fdd189 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -50,6 +50,10 @@
 
 #ifdef HAVE_SCHED_H
 #include <sched.h>
+
+#if defined(__linux__) && !defined(SCHED_RESET_ON_FORK)
+#define SCHED_RESET_ON_FORK 0x40000000
+#endif
 #endif
 
 #ifdef HAVE_SYS_RESOURCE_H
@@ -92,6 +96,10 @@
 #include <xlocale.h>
 #endif
 
+#ifdef HAVE_DBUS
+#include "rtkit.h"
+#endif
+
 #include <pulse/xmalloc.h>
 #include <pulse/util.h>
 #include <pulse/utf8.h>
@@ -552,16 +560,68 @@ char *pa_strlcpy(char *b, const char *s, size_t l) {
     return b;
 }
 
+static int set_scheduler(int rtprio) {
+    struct sched_param sp;
+    int r;
+#ifdef HAVE_DBUS
+    DBusError error;
+    DBusConnection *bus;
+
+    dbus_error_init(&error);
+#endif
+
+    pa_zero(sp);
+    sp.sched_priority = rtprio;
+
+#ifdef SCHED_RESET_ON_FORK
+    if ((r = pthread_setschedparam(pthread_self(), SCHED_RR|SCHED_RESET_ON_FORK, &sp)) == 0) {
+        pa_log_debug("SCHED_RR|SCHED_RESET_ON_FORK worked.");
+        return 0;
+    }
+#endif
+
+    if ((r = pthread_setschedparam(pthread_self(), SCHED_RR, &sp)) == 0) {
+        pa_log_debug("SCHED_RR worked.");
+        return 0;
+    }
+
+#ifdef HAVE_DBUS
+    /* Try to talk to RealtimeKit */
+
+    if (!(bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) {
+        pa_log("Failed to connect to system bus: %s\n", error.message);
+        dbus_error_free(&error);
+        errno = -EIO;
+        return -1;
+    }
+
+    r = rtkit_make_realtime(bus, 0, rtprio);
+    dbus_connection_unref(bus);
+
+    if (r >= 0) {
+        pa_log_debug("RealtimeKit worked.");
+        return 0;
+    }
+
+    errno = -r;
+#else
+    errno = r;
+#endif
+
+    return -1;
+}
+
 /* Make the current thread a realtime thread, and acquire the highest
  * rtprio we can get that is less or equal the specified parameter. If
  * the thread is already realtime, don't do anything. */
 int pa_make_realtime(int rtprio) {
 
 #ifdef _POSIX_PRIORITY_SCHEDULING
-    struct sched_param sp;
     int r, policy;
+    struct sched_param sp;
+    int rtprio_try;
 
-    memset(&sp, 0, sizeof(sp));
+    pa_zero(sp);
     policy = 0;
 
     if ((r = pthread_getschedparam(pthread_self(), &policy, &sp)) != 0) {
@@ -569,29 +629,29 @@ int pa_make_realtime(int rtprio) {
         return -1;
     }
 
-    if (policy == SCHED_FIFO && sp.sched_priority >= rtprio) {
-        pa_log_info("Thread already being scheduled with SCHED_FIFO with priority %i.", sp.sched_priority);
+#ifdef SCHED_RESET_ON_FORK
+    policy &= ~SCHED_RESET_ON_FORK;
+#endif
+
+    if ((policy == SCHED_FIFO || policy == SCHED_RR) && sp.sched_priority >= rtprio) {
+        pa_log_info("Thread already being scheduled with SCHED_FIFO/SCHED_RR with priority %i.", sp.sched_priority);
         return 0;
     }
 
-    sp.sched_priority = rtprio;
-    if ((r = pthread_setschedparam(pthread_self(), SCHED_FIFO, &sp)) != 0) {
-
-        while (sp.sched_priority > 1) {
-            sp.sched_priority --;
+    if (set_scheduler(rtprio) >= 0) {
+        pa_log_info("Successfully enabled SCHED_RR scheduling for thread, with priority %i.", rtprio);
+        return 0;
+    }
 
-            if ((r = pthread_setschedparam(pthread_self(), SCHED_FIFO, &sp)) == 0) {
-                pa_log_info("Successfully enabled SCHED_FIFO scheduling for thread, with priority %i, which is lower than the requested %i.", sp.sched_priority, rtprio);
-                return 0;
-            }
+    for (rtprio_try = rtprio-1; rtprio_try >= 1; rtprio_try--) {
+        if (set_scheduler(rtprio_try)) {
+            pa_log_info("Successfully enabled SCHED_RR scheduling for thread, with priority %i, which is lower than the requested %i.", rtprio_try, rtprio);
+            return 0;
         }
-
-        pa_log_warn("pthread_setschedparam(): %s", pa_cstrerror(r));
-        return -1;
     }
 
-    pa_log_info("Successfully enabled SCHED_FIFO scheduling for thread, with priority %i.", sp.sched_priority);
-    return 0;
+    pa_log_warn("Failed to acquire real-time scheduling: %s", pa_cstrerror(r));
+    return -1;
 #else
 
     errno = ENOTSUP;
diff --git a/src/pulsecore/rtkit.c b/src/pulsecore/rtkit.c
new file mode 100644
index 0000000..aecc4e3
--- /dev/null
+++ b/src/pulsecore/rtkit.c
@@ -0,0 +1,189 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+  Copyright 2009 Lennart Poettering
+
+  Permission is hereby granted, free of charge, to any person
+  obtaining a copy of this software and associated documentation files
+  (the "Software"), to deal in the Software without restriction,
+  including without limitation the rights to use, copy, modify, merge,
+  publish, distribute, sublicense, and/or sell copies of the Software,
+  and to permit persons to whom the Software is furnished to do so,
+  subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be
+  included in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+  SOFTWARE.
+***/
+
+#include <errno.h>
+
+#include "rtkit.h"
+
+#ifdef __linux__
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+static pid_t _gettid(void) {
+        return (pid_t) syscall(SYS_gettid);
+}
+
+static int translate_error(const char *name) {
+        if (strcmp(name, DBUS_ERROR_NO_MEMORY) == 0)
+                return -ENOMEM;
+        if (strcmp(name, DBUS_ERROR_SERVICE_UNKNOWN) == 0 ||
+            strcmp(name, DBUS_ERROR_NAME_HAS_NO_OWNER) == 0)
+                return -ENOENT;
+        if (strcmp(name, DBUS_ERROR_ACCESS_DENIED) == 0 ||
+            strcmp(name, DBUS_ERROR_AUTH_FAILED) == 0)
+                return -EACCES;
+
+        return -EIO;
+}
+
+int rtkit_make_realtime(DBusConnection *connection, pid_t thread, int priority) {
+        DBusMessage *m = NULL, *r = NULL;
+        dbus_uint64_t u64;
+        dbus_uint32_t u32;
+        DBusError error;
+        int ret;
+
+        dbus_error_init(&error);
+
+        if (thread == 0)
+                thread = _gettid();
+
+        if (!(m = dbus_message_new_method_call(
+                              RTKIT_SERVICE_NAME,
+                              RTKIT_OBJECT_PATH,
+                              "org.freedesktop.RealtimeKit1",
+                              "MakeThreadRealtime"))) {
+                ret = -ENOMEM;
+                goto finish;
+        }
+
+        u64 = (dbus_uint64_t) thread;
+        u32 = (dbus_uint32_t) priority;
+
+        if (!dbus_message_append_args(
+                            m,
+                            DBUS_TYPE_UINT64, &u64,
+                            DBUS_TYPE_UINT32, &u32,
+                            DBUS_TYPE_INVALID)) {
+                ret = -ENOMEM;
+                goto finish;
+        }
+
+        if (!(r = dbus_connection_send_with_reply_and_block(connection, m, -1, &error))) {
+                ret = translate_error(error.name);
+                goto finish;
+        }
+
+
+        if (dbus_set_error_from_message(&error, r)) {
+                ret = translate_error(error.name);
+                goto finish;
+        }
+
+        ret = 0;
+
+finish:
+
+        if (m)
+                dbus_message_unref(m);
+
+        if (r)
+                dbus_message_unref(r);
+
+        dbus_error_free(&error);
+
+        return ret;
+}
+
+int rtkit_make_high_priority(DBusConnection *connection, pid_t thread, int nice_level) {
+        DBusMessage *m = NULL, *r = NULL;
+        dbus_uint64_t u64;
+        dbus_int32_t s32;
+        DBusError error;
+        int ret;
+
+        dbus_error_init(&error);
+
+        if (thread == 0)
+                thread = _gettid();
+
+        if (!(m = dbus_message_new_method_call(
+                              RTKIT_SERVICE_NAME,
+                              RTKIT_OBJECT_PATH,
+                              "org.freedesktop.RealtimeKit1",
+                              "MakeThreadHighPriority"))) {
+                ret = -ENOMEM;
+                goto finish;
+        }
+
+        u64 = (dbus_uint64_t) thread;
+        s32 = (dbus_int32_t) nice_level;
+
+        if (!dbus_message_append_args(
+                            m,
+                            DBUS_TYPE_UINT64, &u64,
+                            DBUS_TYPE_INT32, &s32,
+                            DBUS_TYPE_INVALID)) {
+                ret = -ENOMEM;
+                goto finish;
+        }
+
+
+
+        if (!(r = dbus_connection_send_with_reply_and_block(connection, m, -1, &error))) {
+                ret = translate_error(error.name);
+                goto finish;
+        }
+
+
+        if (dbus_set_error_from_message(&error, r)) {
+                ret = translate_error(error.name);
+                goto finish;
+        }
+
+        ret = 0;
+
+finish:
+
+        if (m)
+                dbus_message_unref(m);
+
+        if (r)
+                dbus_message_unref(r);
+
+        dbus_error_free(&error);
+
+        return ret;
+}
+
+#else
+
+int rtkit_make_realtime(DBusConnection *connection, pid_t thread, int priority) {
+        return -ENOTSUP;
+}
+
+int rtkit_make_high_priority(DBusConnection *connection, pid_t thread, int nice_level) {
+        return -ENOTSUP;
+}
+
+#endif
diff --git a/src/pulsecore/rtkit.h b/src/pulsecore/rtkit.h
new file mode 100644
index 0000000..2081b4e
--- /dev/null
+++ b/src/pulsecore/rtkit.h
@@ -0,0 +1,62 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foortkithfoo
+#define foortkithfoo
+
+/***
+  Copyright 2009 Lennart Poettering
+
+  Permission is hereby granted, free of charge, to any person
+  obtaining a copy of this software and associated documentation files
+  (the "Software"), to deal in the Software without restriction,
+  including without limitation the rights to use, copy, modify, merge,
+  publish, distribute, sublicense, and/or sell copies of the Software,
+  and to permit persons to whom the Software is furnished to do so,
+  subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be
+  included in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+  SOFTWARE.
+***/
+
+#include <sys/types.h>
+#include <dbus/dbus.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* This is the reference implementation for a client for
+ * RealtimeKit. You don't have to use this, but if do, just copy these
+ * sources into your repository */
+
+#define RTKIT_SERVICE_NAME "org.freedesktop.RealtimeKit1"
+#define RTKIT_OBJECT_PATH "/org/freedesktop/RealtimeKit1"
+
+/* This is mostly equivalent to sched_setparam(thread, SCHED_RR, {
+ * .sched_priority = priority }). 'thread' needs to be a kernel thread
+ * id as returned by gettid(), not a pthread_t! If 'thread' is 0 the
+ * current thread is used. The returned value is a negative errno
+ * style error code, or 0 on success. */
+int rtkit_make_realtime(DBusConnection *system_bus, pid_t thread, int priority);
+
+/* This is mostly equivalent to setpriority(PRIO_PROCESS, thread,
+ * nice_level). 'thread' needs to be a kernel thread id as returned by
+ * gettid(), not a pthread_t! If 'thread' is 0 the current thread is
+ * used. The returned value is a negative errno style error code, or 0
+ * on success.*/
+int rtkit_make_high_priority(DBusConnection *system_bus, pid_t thread, int nice_level);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

commit bacc5ca6f48f280c781af508250a25bb2012327f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Jun 19 04:45:19 2009 +0200

    core: use rtkit to acquire high-priority scheduling

diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 1fdd189..4550344 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -617,40 +617,20 @@ static int set_scheduler(int rtprio) {
 int pa_make_realtime(int rtprio) {
 
 #ifdef _POSIX_PRIORITY_SCHEDULING
-    int r, policy;
-    struct sched_param sp;
-    int rtprio_try;
-
-    pa_zero(sp);
-    policy = 0;
-
-    if ((r = pthread_getschedparam(pthread_self(), &policy, &sp)) != 0) {
-        pa_log("pthread_getschedgetparam(): %s", pa_cstrerror(r));
-        return -1;
-    }
-
-#ifdef SCHED_RESET_ON_FORK
-    policy &= ~SCHED_RESET_ON_FORK;
-#endif
-
-    if ((policy == SCHED_FIFO || policy == SCHED_RR) && sp.sched_priority >= rtprio) {
-        pa_log_info("Thread already being scheduled with SCHED_FIFO/SCHED_RR with priority %i.", sp.sched_priority);
-        return 0;
-    }
+    int p;
 
     if (set_scheduler(rtprio) >= 0) {
         pa_log_info("Successfully enabled SCHED_RR scheduling for thread, with priority %i.", rtprio);
         return 0;
     }
 
-    for (rtprio_try = rtprio-1; rtprio_try >= 1; rtprio_try--) {
-        if (set_scheduler(rtprio_try)) {
-            pa_log_info("Successfully enabled SCHED_RR scheduling for thread, with priority %i, which is lower than the requested %i.", rtprio_try, rtprio);
+    for (p = rtprio-1; p >= 1; p--)
+        if (set_scheduler(p)) {
+            pa_log_info("Successfully enabled SCHED_RR scheduling for thread, with priority %i, which is lower than the requested %i.", p, rtprio);
             return 0;
         }
-    }
 
-    pa_log_warn("Failed to acquire real-time scheduling: %s", pa_cstrerror(r));
+    pa_log_info("Failed to acquire real-time scheduling: %s", pa_cstrerror(errno));
     return -1;
 #else
 
@@ -659,80 +639,42 @@ int pa_make_realtime(int rtprio) {
 #endif
 }
 
-/* This is merely used for giving the user a hint. This is not correct
- * for anything security related */
-pa_bool_t pa_can_realtime(void) {
-
-    if (geteuid() == 0)
-        return TRUE;
-
-#if defined(HAVE_SYS_RESOURCE_H) && defined(RLIMIT_RTPRIO)
-    {
-        struct rlimit rl;
+static int set_nice(int nice_level) {
+#ifdef HAVE_DBUS
+    DBusError error;
+    DBusConnection *bus;
+    int r;
 
-        if (getrlimit(RLIMIT_RTPRIO, &rl) >= 0)
-            if (rl.rlim_cur > 0 || rl.rlim_cur == RLIM_INFINITY)
-                return TRUE;
-    }
+    dbus_error_init(&error);
 #endif
 
-#if defined(HAVE_SYS_CAPABILITY_H) && defined(CAP_SYS_NICE)
-    {
-        cap_t cap;
-
-        if ((cap = cap_get_proc())) {
-            cap_flag_value_t flag = CAP_CLEAR;
-
-            if (cap_get_flag(cap, CAP_SYS_NICE, CAP_EFFECTIVE, &flag) >= 0)
-                if (flag == CAP_SET) {
-                    cap_free(cap);
-                    return TRUE;
-                }
-
-            cap_free(cap);
-        }
+    if (setpriority(PRIO_PROCESS, 0, nice_level) >= 0) {
+        pa_log_debug("setpriority() worked.");
+        return 0;
     }
-#endif
-
-    return FALSE;
-}
-
-/* This is merely used for giving the user a hint. This is not correct
- * for anything security related */
-pa_bool_t pa_can_high_priority(void) {
 
-    if (geteuid() == 0)
-        return TRUE;
-
-#if defined(HAVE_SYS_RESOURCE_H) && defined(RLIMIT_RTPRIO)
-    {
-        struct rlimit rl;
+#ifdef HAVE_DBUS
+    /* Try to talk to RealtimeKit */
 
-        if (getrlimit(RLIMIT_NICE, &rl) >= 0)
-            if (rl.rlim_cur >= 21 || rl.rlim_cur == RLIM_INFINITY)
-                return TRUE;
+    if (!(bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) {
+        pa_log("Failed to connect to system bus: %s\n", error.message);
+        dbus_error_free(&error);
+        errno = -EIO;
+        return -1;
     }
-#endif
 
-#if defined(HAVE_SYS_CAPABILITY_H) && defined(CAP_SYS_NICE)
-    {
-        cap_t cap;
-
-        if ((cap = cap_get_proc())) {
-            cap_flag_value_t flag = CAP_CLEAR;
-
-            if (cap_get_flag(cap, CAP_SYS_NICE, CAP_EFFECTIVE, &flag) >= 0)
-                if (flag == CAP_SET) {
-                    cap_free(cap);
-                    return TRUE;
-                }
+    r = rtkit_make_high_priority(bus, 0, nice_level);
+    dbus_connection_unref(bus);
 
-            cap_free(cap);
-        }
+    if (r >= 0) {
+        pa_log_debug("RealtimeKit worked.");
+        return 0;
     }
+
+    errno = -r;
 #endif
 
-    return FALSE;
+    return -1;
 }
 
 /* Raise the priority of the current process as much as possible that
@@ -740,22 +682,21 @@ pa_bool_t pa_can_high_priority(void) {
 int pa_raise_priority(int nice_level) {
 
 #ifdef HAVE_SYS_RESOURCE_H
-    if (setpriority(PRIO_PROCESS, 0, nice_level) < 0) {
-        int n;
+    int n;
 
-        for (n = nice_level+1; n < 0; n++) {
+    if (set_nice(nice_level) >= 0) {
+        pa_log_info("Successfully gained nice level %i.", nice_level);
+        return 0;
+    }
 
-            if (setpriority(PRIO_PROCESS, 0, n) == 0) {
-                pa_log_info("Successfully acquired nice level %i, which is lower than the requested %i.", n, nice_level);
-                return 0;
-            }
+    for (n = nice_level+1; n < 0; n++)
+        if (set_nice(n) > 0) {
+            pa_log_info("Successfully acquired nice level %i, which is lower than the requested %i.", n, nice_level);
+            return 0;
         }
 
-        pa_log_warn("setpriority(): %s", pa_cstrerror(errno));
-        return -1;
-    }
-
-    pa_log_info("Successfully gained nice level %i.", nice_level);
+    pa_log_info("Failed to acquire high-priority scheduling: %s", pa_cstrerror(errno));
+    return -1;
 #endif
 
 #ifdef OS_IS_WIN32
@@ -763,9 +704,10 @@ int pa_raise_priority(int nice_level) {
         if (!SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS)) {
             pa_log_warn("SetPriorityClass() failed: 0x%08X", GetLastError());
             errno = EPERM;
-            return .-1;
-        } else
-            pa_log_info("Successfully gained high priority class.");
+            return -1;
+        }
+
+        pa_log_info("Successfully gained high priority class.");
     }
 #endif
 
@@ -780,8 +722,8 @@ void pa_reset_priority(void) {
 
     setpriority(PRIO_PROCESS, 0, 0);
 
-    memset(&sp, 0, sizeof(sp));
-    pa_assert_se(pthread_setschedparam(pthread_self(), SCHED_OTHER, &sp) == 0);
+    pa_zero(sp);
+    pthread_setschedparam(pthread_self(), SCHED_OTHER, &sp);
 #endif
 
 #ifdef OS_IS_WIN32
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index b841edb..96a0480 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -80,9 +80,6 @@ int pa_make_realtime(int rtprio);
 int pa_raise_priority(int nice_level);
 void pa_reset_priority(void);
 
-pa_bool_t pa_can_realtime(void);
-pa_bool_t pa_can_high_priority(void);
-
 int pa_parse_boolean(const char *s) PA_GCC_PURE;
 
 static inline const char *pa_yes_no(pa_bool_t b) {

commit 9c438bcac67197b685c57c2f6f1b59cdfbf7c9b2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Jun 19 17:37:18 2009 +0200

    daemon: strip all special suid/caps log from our startup code, we'll now rely on RealtimeKit for all high-priority/RT scheduling policy issues

diff --git a/src/Makefile.am b/src/Makefile.am
index 59f5fff..5efe1ac 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -114,7 +114,6 @@ EXTRA_DIST = \
 		modules/module-defs.h.m4 \
 		daemon/pulseaudio.desktop.in \
 		map-file \
-		daemon/org.pulseaudio.policy.in \
 		modules/alsa/mixer/profile-sets/default.conf \
 		modules/alsa/mixer/profile-sets/native-instruments-audio4dj.conf \
 		modules/alsa/mixer/profile-sets/native-instruments-audio8dj.conf \
@@ -184,16 +183,6 @@ else
 pulseaudio_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) -dlopen force $(foreach f,$(PREOPEN_LIBS),-dlopen $(f))
 endif
 
-if HAVE_POLKIT
-policy_in_files = daemon/org.pulseaudio.policy.in
-policy_DATA = $(policy_in_files:.policy.in=.policy)
- at INTLTOOL_POLICY_RULE@
-
-pulseaudio_SOURCES += daemon/polkit.c daemon/polkit.h
-pulseaudio_CFLAGS += $(POLKIT_CFLAGS)
-pulseaudio_LDADD += $(POLKIT_LIBS)
-endif
-
 ###################################
 #       Utility programs          #
 ###################################
@@ -1655,11 +1644,7 @@ module_rygel_media_server_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 #        Some minor stuff         #
 ###################################
 
-suid: pulseaudio .libs/lt-pulseaudio
-	chown root $^
-	chmod u+s $^
-
-CLEANFILES = esdcompat client.conf default.pa system.pa daemon.conf start-pulseaudio-x11 daemon/pulseaudio.desktop daemon/org.pulseaudio.policy
+CLEANFILES = esdcompat client.conf default.pa system.pa daemon.conf start-pulseaudio-x11 daemon/pulseaudio.desktop
 
 esdcompat: daemon/esdcompat.in Makefile
 	sed -e 's, at PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
diff --git a/src/daemon/caps.c b/src/daemon/caps.c
index d2ae8d0..294be49 100644
--- a/src/daemon/caps.c
+++ b/src/daemon/caps.c
@@ -39,6 +39,7 @@
 #ifdef HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
 #endif
+
 #ifdef HAVE_SYS_PRCTL_H
 #include <sys/prctl.h>
 #endif
@@ -51,12 +52,13 @@ int setresgid(gid_t r, gid_t e, gid_t s);
 int setresuid(uid_t r, uid_t e, uid_t s);
 #endif
 
-#ifdef HAVE_GETUID
-
 /* Drop root rights when called SUID root */
 void pa_drop_root(void) {
-    uid_t uid = getuid();
 
+#ifdef HAVE_GETUID
+    uid_t uid;
+
+    uid = getuid();
     if (uid == 0 || geteuid() != 0)
         return;
 
@@ -73,90 +75,19 @@ void pa_drop_root(void) {
 
     pa_assert_se(getuid() == uid);
     pa_assert_se(geteuid() == uid);
-}
-
-#else
-
-void pa_drop_root(void) {
-}
-
-#endif
-
-#if defined(HAVE_SYS_CAPABILITY_H) && defined(HAVE_SYS_PRCTL_H)
-
-/* Limit permitted capabilities set to CAPSYS_NICE */
-void pa_limit_caps(void) {
-    cap_t caps;
-    cap_value_t nice_cap = CAP_SYS_NICE;
-
-    pa_assert_se(caps = cap_init());
-    pa_assert_se(cap_clear(caps) == 0);
-    pa_assert_se(cap_set_flag(caps, CAP_EFFECTIVE, 1, &nice_cap, CAP_SET) == 0);
-    pa_assert_se(cap_set_flag(caps, CAP_PERMITTED, 1, &nice_cap, CAP_SET) == 0);
-
-    if (cap_set_proc(caps) < 0)
-        /* Hmm, so we couldn't limit our caps, which probably means we
-         * hadn't any in the first place, so let's just make sure of
-         * that */
-        pa_drop_caps();
-    else
-        pa_log_info(_("Limited capabilities successfully to CAP_SYS_NICE."));
-
-    pa_assert_se(cap_free(caps) == 0);
-
-    pa_assert_se(prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) == 0);
-}
-
-/* Drop all capabilities, effectively becoming a normal user */
-void pa_drop_caps(void) {
-    cap_t caps;
-
-#ifndef __OPTIMIZE__
-    /* Valgrind doesn't not know set_caps, so we bypass it here -- but
-     * only in development builds.*/
-
-    if (pa_in_valgrind() && !pa_have_caps())
-        return;
 #endif
 
+#ifdef HAVE_SYS_PRCTL_H
     pa_assert_se(prctl(PR_SET_KEEPCAPS, 0, 0, 0, 0) == 0);
-
-    pa_assert_se(caps = cap_init());
-    pa_assert_se(cap_clear(caps) == 0);
-    pa_assert_se(cap_set_proc(caps) == 0);
-    pa_assert_se(cap_free(caps) == 0);
-
-    pa_assert_se(!pa_have_caps());
-}
-
-pa_bool_t pa_have_caps(void) {
-    cap_t caps;
-    cap_flag_value_t flag = CAP_CLEAR;
-
-#ifdef __OPTIMIZE__
-    pa_assert_se(caps = cap_get_proc());
-#else
-    if (!(caps = cap_get_proc()))
-        return FALSE;
 #endif
-    pa_assert_se(cap_get_flag(caps, CAP_SYS_NICE, CAP_EFFECTIVE, &flag) >= 0);
-    pa_assert_se(cap_free(caps) == 0);
-
-    return flag == CAP_SET;
-}
-
-#else
-
-/* NOOPs in case capabilities are not available. */
-void pa_limit_caps(void) {
-}
-
-void pa_drop_caps(void) {
-    pa_drop_root();
-}
-
-pa_bool_t pa_have_caps(void) {
-    return FALSE;
-}
 
+#ifdef HAVE_SYS_CAPABILITY_H
+    {
+        cap_t caps;
+        pa_assert_se(caps = cap_init());
+        pa_assert_se(cap_clear(caps) == 0);
+        pa_assert_se(cap_set_proc(caps) == 0);
+        pa_assert_se(cap_free(caps) == 0);
+    }
 #endif
+}
diff --git a/src/daemon/caps.h b/src/daemon/caps.h
index 94241a9..5d0ee62 100644
--- a/src/daemon/caps.h
+++ b/src/daemon/caps.h
@@ -25,8 +25,5 @@
 #include <pulsecore/macro.h>
 
 void pa_drop_root(void);
-void pa_drop_caps(void);
-void pa_limit_caps(void);
-pa_bool_t pa_have_caps(void);
 
 #endif
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 8058e12..4b2a1f8 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -102,7 +102,6 @@
 #include "dumpmodules.h"
 #include "caps.h"
 #include "ltdl-bind-now.h"
-#include "polkit.h"
 
 #ifdef HAVE_LIBWRAP
 /* Only one instance of these variables */
@@ -381,9 +380,7 @@ int main(int argc, char *argv[]) {
     pa_mainloop *mainloop = NULL;
     char *s;
     int r = 0, retval = 1, d = 0;
-    pa_bool_t suid_root, real_root;
     pa_bool_t valid_pid_file = FALSE;
-    gid_t gid = (gid_t) -1;
     pa_bool_t ltdl_init = FALSE;
     int passed_fd = -1;
     const char *e;
@@ -426,30 +423,6 @@ int main(int argc, char *argv[]) {
     }
 #endif
 
-#ifdef HAVE_GETUID
-    real_root = getuid() == 0;
-    suid_root = !real_root && geteuid() == 0;
-#else
-    real_root = FALSE;
-    suid_root = FALSE;
-#endif
-
-    if (!real_root) {
-        /* Drop all capabilities except CAP_SYS_NICE  */
-        pa_limit_caps();
-
-        /* Drop privileges, but keep CAP_SYS_NICE */
-        pa_drop_root();
-
-        /* After dropping root, the effective set is reset, hence,
-         * let's raise it again */
-        pa_limit_caps();
-
-        /* When capabilities are not supported we will not be able to
-         * acquire RT sched anymore. But yes, that's the way it is. It
-         * is just too risky tun let PA run as root all the time. */
-    }
-
     if ((e = getenv("PULSE_PASSED_FD"))) {
         passed_fd = atoi(e);
 
@@ -457,15 +430,14 @@ int main(int argc, char *argv[]) {
             passed_fd = -1;
     }
 
+    /* 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_drop_root();
     pa_close_all(passed_fd, -1);
-
     pa_reset_sigs(-1);
     pa_unblock_sigs(-1);
 
-    /* At this point, we are a normal user, possibly with CAP_NICE if
-     * we were started SUID. If we are started as normal root, than we
-     * still are normal root. */
-
     setlocale(LC_ALL, "");
     pa_init_i18n();
 
@@ -490,150 +462,6 @@ int main(int argc, char *argv[]) {
         pa_log_set_flags(PA_LOG_PRINT_TIME, PA_LOG_SET);
     pa_log_set_show_backtrace(conf->log_backtrace);
 
-    pa_log_debug("Started as real root: %s, suid root: %s", pa_yes_no(real_root), pa_yes_no(suid_root));
-
-    if (!real_root && pa_have_caps()) {
-#ifdef HAVE_SYS_RESOURCE_H
-        struct rlimit rl;
-#endif
-        pa_bool_t allow_high_priority = FALSE, allow_realtime = FALSE;
-
-        /* Let's better not enable high prio or RT by default */
-
-        if (conf->high_priority && !allow_high_priority) {
-            if (pa_own_uid_in_group(PA_REALTIME_GROUP, &gid) > 0) {
-                pa_log_info(_("We're in the group '%s', allowing high-priority scheduling."), PA_REALTIME_GROUP);
-                allow_high_priority = TRUE;
-            }
-        }
-
-        if (conf->realtime_scheduling && !allow_realtime) {
-            if (pa_own_uid_in_group(PA_REALTIME_GROUP, &gid) > 0) {
-                pa_log_info(_("We're in the group '%s', allowing real-time scheduling."), PA_REALTIME_GROUP);
-                allow_realtime = TRUE;
-            }
-        }
-
-#ifdef HAVE_POLKIT
-        if (conf->high_priority && !allow_high_priority) {
-            if (pa_polkit_check("org.pulseaudio.acquire-high-priority") > 0) {
-                pa_log_info(_("PolicyKit grants us acquire-high-priority privilege."));
-                allow_high_priority = TRUE;
-            } else
-                pa_log_info(_("PolicyKit refuses acquire-high-priority privilege."));
-        }
-
-        if (conf->realtime_scheduling && !allow_realtime) {
-            if (pa_polkit_check("org.pulseaudio.acquire-real-time") > 0) {
-                pa_log_info(_("PolicyKit grants us acquire-real-time privilege."));
-                allow_realtime = TRUE;
-            } else
-                pa_log_info(_("PolicyKit refuses acquire-real-time privilege."));
-        }
-#endif
-
-        if (!allow_high_priority && !allow_realtime) {
-
-            /* OK, there's no further need to keep CAP_NICE. Hence
-             * let's give it up early */
-
-            pa_drop_caps();
-        }
-
-#ifdef RLIMIT_RTPRIO
-        if (getrlimit(RLIMIT_RTPRIO, &rl) >= 0)
-            if (rl.rlim_cur > 0) {
-                pa_log_info("RLIMIT_RTPRIO is set to %u, allowing real-time scheduling.", (unsigned) rl.rlim_cur);
-                allow_realtime = TRUE;
-            }
-#endif
-#ifdef RLIMIT_NICE
-        if (getrlimit(RLIMIT_NICE, &rl) >= 0)
-            if (rl.rlim_cur > 20 ) {
-                pa_log_info("RLIMIT_NICE is set to %u, allowing high-priority scheduling.", (unsigned) rl.rlim_cur);
-                allow_high_priority = TRUE;
-            }
-#endif
-
-        if ((conf->high_priority && !allow_high_priority) ||
-            (conf->realtime_scheduling && !allow_realtime))
-            pa_log_info(_("Called SUID root and real-time and/or high-priority scheduling was requested in the configuration. However, we lack the necessary privileges:\n"
-                            "We are not in group '%s', PolicyKit refuse to grant us the requested privileges and we have no increase RLIMIT_NICE/RLIMIT_RTPRIO resource limits.\n"
-                            "For enabling real-time/high-priority scheduling please acquire the appropriate PolicyKit privileges, or become a member of '%s', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."),
-                          PA_REALTIME_GROUP, PA_REALTIME_GROUP);
-
-
-        if (!allow_realtime)
-            conf->realtime_scheduling = FALSE;
-
-        if (!allow_high_priority)
-            conf->high_priority = FALSE;
-    }
-
-#ifdef HAVE_SYS_RESOURCE_H
-    /* Reset resource limits. If we are run as root (for system mode)
-     * this might end up increasing the limits, which is intended
-     * behaviour. For all other cases, i.e. started as normal user, or
-     * SUID root at this point we should have no CAP_SYS_RESOURCE and
-     * increasing the limits thus should fail. Which is, too, intended
-     * behaviour */
-
-    set_all_rlimits(conf);
-#endif
-
-    if (conf->high_priority && !pa_can_high_priority()) {
-        pa_log_info(_("High-priority scheduling enabled in configuration but not allowed by policy."));
-        conf->high_priority = FALSE;
-    }
-
-    if (conf->high_priority && (conf->cmd == PA_CMD_DAEMON || conf->cmd == PA_CMD_START))
-        pa_raise_priority(conf->nice_level);
-
-    pa_log_debug("Can realtime: %s, can high-priority: %s", pa_yes_no(pa_can_realtime()), pa_yes_no(pa_can_high_priority()));
-
-    if (!real_root && pa_have_caps()) {
-        pa_bool_t drop;
-
-        drop = (conf->cmd != PA_CMD_DAEMON && conf->cmd != PA_CMD_START) || !conf->realtime_scheduling;
-
-#ifdef RLIMIT_RTPRIO
-        if (!drop) {
-            struct rlimit rl;
-            /* At this point we still have CAP_NICE if we were loaded
-             * SUID root. If possible let's acquire RLIMIT_RTPRIO
-             * instead and give CAP_NICE up. */
-
-            if (getrlimit(RLIMIT_RTPRIO, &rl) >= 0) {
-
-                if (rl.rlim_cur >= 9)
-                    drop = TRUE;
-                else {
-                    rl.rlim_max = rl.rlim_cur = 9;
-
-                    if (setrlimit(RLIMIT_RTPRIO, &rl) >= 0) {
-                        pa_log_info(_("Successfully increased RLIMIT_RTPRIO"));
-                        drop = TRUE;
-                    } else
-                        pa_log_warn(_("RLIMIT_RTPRIO failed: %s"), pa_cstrerror(errno));
-                }
-            }
-        }
-#endif
-
-        if (drop)  {
-            pa_log_info(_("Giving up CAP_NICE"));
-            pa_drop_caps();
-            suid_root = FALSE;
-        }
-    }
-
-    if (conf->realtime_scheduling && !pa_can_realtime()) {
-        pa_log_info(_("Real-time scheduling enabled in configuration but not allowed by policy."));
-        conf->realtime_scheduling = FALSE;
-    }
-
-    pa_log_debug("Can realtime: %s, can high-priority: %s", pa_yes_no(pa_can_realtime()), pa_yes_no(pa_can_high_priority()));
-
     LTDL_SET_PRELOADED_SYMBOLS();
     pa_ltdl_init();
     ltdl_init = TRUE;
@@ -718,9 +546,9 @@ int main(int argc, char *argv[]) {
             pa_assert(conf->cmd == PA_CMD_DAEMON || conf->cmd == PA_CMD_START);
     }
 
-    if (real_root && !conf->system_instance)
+    if (getuid() == 0 && !conf->system_instance)
         pa_log_warn(_("This program is not intended to be run as root (unless --system is specified)."));
-    else if (!real_root && conf->system_instance) {
+    else if (getuid() != 0 && conf->system_instance) {
         pa_log(_("Root privileges required."));
         goto finish;
     }
@@ -866,6 +694,13 @@ int main(int argc, char *argv[]) {
     pa_assert_se(chdir("/") == 0);
     umask(0022);
 
+#ifdef HAVE_SYS_RESOURCE_H
+    set_all_rlimits(conf);
+#endif
+    pa_rtclock_hrtimer_enable();
+
+    pa_raise_priority(conf->nice_level);
+
     if (conf->system_instance)
         if (change_user() < 0)
             goto finish;
@@ -914,8 +749,8 @@ int main(int argc, char *argv[]) {
     pa_xfree(s);
 
     if ((s = pa_session_id())) {
-            pa_log_info(_("Session ID is %s."), s);
-            pa_xfree(s);
+        pa_log_info(_("Session ID is %s."), s);
+        pa_xfree(s);
     }
 
     if (!(s = pa_get_runtime_dir()))
@@ -962,8 +797,6 @@ int main(int argc, char *argv[]) {
     else
         pa_log_info(_("Dude, your kernel stinks! The chef's recommendation today is Linux with high-resolution timers enabled!"));
 
-    pa_rtclock_hrtimer_enable();
-
 #ifdef SIGRTMIN
     /* Valgrind uses SIGRTMAX. To easy debugging we don't use it here */
     pa_rtsig_configure(SIGRTMIN, SIGRTMAX-1);

commit 06ec5fda21a7ad316ed6a0badbb00923a2da9694
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Jun 19 18:18:49 2009 +0200

    mergo

diff --git a/configure.ac b/configure.ac
index bb8afa4..1081e68 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1152,44 +1152,6 @@ AC_SUBST(DBUS_LIBS)
 AC_SUBST(HAVE_DBUS)
 AM_CONDITIONAL([HAVE_DBUS], [test "x$HAVE_DBUS" = x1])
 
-#### PolicyKit support (optional) ####
-
-AC_ARG_ENABLE([polkit],
-    AS_HELP_STRING([--disable-polkit],[Disable optional PolicyKit support]),
-        [
-            case "${enableval}" in
-                yes) polkit=yes ;;
-                no) polkit=no ;;
-                *) AC_MSG_ERROR(bad value ${enableval} for --disable-polkit) ;;
-            esac
-        ],
-        [polkit=auto])
-
-if test "x${polkit}" != xno ; then
-
-    PKG_CHECK_MODULES(POLKIT, [ polkit-dbus >= 0.7 ],
-        [
-            HAVE_POLKIT=1
-            AC_DEFINE([HAVE_POLKIT], 1, [Have PolicyKit])
-            policydir=`pkg-config polkit-dbus --variable prefix`/share/PolicyKit/policy/
-            AC_SUBST(policydir)
-        ],
-        [
-            HAVE_POLKIT=0
-            if test "x$polkit" = xyes ; then
-                AC_MSG_ERROR([*** PolicyKit support not found])
-            fi
-        ])
-else
-    HAVE_POLKIT=0
-fi
-
-AC_SUBST(POLKIT_CFLAGS)
-AC_SUBST(POLKIT_LIBS)
-AC_SUBST(HAVE_POLKIT)
-AM_CONDITIONAL([HAVE_POLKIT], [test "x$HAVE_POLKIT" = x1])
-
-
 ### IPv6 connection support (optional) ###
 
 AC_ARG_ENABLE([ipv6],
@@ -1276,15 +1238,6 @@ fi
 AC_SUBST(PA_SYSTEM_GROUP)
 AC_DEFINE_UNQUOTED(PA_SYSTEM_GROUP,"$PA_SYSTEM_GROUP", [Group for the PulseAudio system daemon])
 
-AC_ARG_WITH(realtime_group,AS_HELP_STRING([--with-realtime-group=<group>],[Group for users that are allowed to start the PulseAudio daemon with realtime scheduling (realtime)]))
-if test -z "$with_realtime_group" ; then
-    PA_REALTIME_GROUP=pulse-rt
-else
-    PA_REALTIME_GROUP=$with_realtime_group
-fi
-AC_SUBST(PA_REALTIME_GROUP)
-AC_DEFINE_UNQUOTED(PA_REALTIME_GROUP,"$PA_REALTIME_GROUP", [Realtime group])
-
 AC_ARG_WITH(access_group,AS_HELP_STRING([--with-access-group=<group>],[Group which is allowed access to a system-wide PulseAudio daemon (pulse-access)]))
 if test -z "$with_access_group" ; then
     PA_ACCESS_GROUP=pulse-access
@@ -1461,11 +1414,6 @@ if test "x${HAVE_BLUEZ}" = "x1" ; then
    ENABLE_BLUEZ=yes
 fi
 
-ENABLE_POLKIT=no
-if test "x${HAVE_POLKIT}" = "x1" ; then
-   ENABLE_POLKIT=yes
-fi
-
 ENABLE_GDBM=no
 if test "x${HAVE_GDBM}" = "x1" ; then
    ENABLE_GDBM=yes
@@ -1519,7 +1467,6 @@ echo "
     Enable BlueZ:                  ${ENABLE_BLUEZ}
     Enable TCP Wrappers:           ${ENABLE_TCPWRAP}
     Enable libsamplerate:          ${ENABLE_LIBSAMPLERATE}
-    Enable PolicyKit:              ${ENABLE_POLKIT}
     Enable IPv6:                   ${ENABLE_IPV6}
     Enable OpenSSL (for Airtunes): ${ENABLE_OPENSSL}
     Enable tdb:                    ${ENABLE_TDB}
@@ -1527,7 +1474,6 @@ echo "
 
     System User:                   ${PA_SYSTEM_USER}
     System Group:                  ${PA_SYSTEM_GROUP}
-    Realtime Group:                ${PA_REALTIME_GROUP}
     Access Group:                  ${PA_ACCESS_GROUP}
     Enable per-user EsounD socket: ${ENABLE_PER_USER_ESOUND_SOCKET}
     Force preopen:                 ${FORCE_PREOPEN}

commit a62db279b71f8a715c1559fbc4bb1c037159fd14
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Jun 19 18:21:35 2009 +0200

    daemon: enable real-time by default

diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c
index 664e4fd..9010f2f 100644
--- a/src/daemon/daemon-conf.c
+++ b/src/daemon/daemon-conf.c
@@ -60,7 +60,7 @@ static const pa_daemon_conf default_conf = {
     .fail = TRUE,
     .high_priority = TRUE,
     .nice_level = -11,
-    .realtime_scheduling = FALSE,
+    .realtime_scheduling = TRUE,
     .realtime_priority = 5,  /* Half of JACK's default rtprio */
     .disallow_module_loading = FALSE,
     .disallow_exit = FALSE,
diff --git a/src/daemon/daemon.conf.in b/src/daemon/daemon.conf.in
index d119716..6931359 100644
--- a/src/daemon/daemon.conf.in
+++ b/src/daemon/daemon.conf.in
@@ -33,7 +33,7 @@
 ; high-priority = yes
 ; nice-level = -11
 
-; realtime-scheduling = no
+; realtime-scheduling = yes
 ; realtime-priority = 5
 
 ; exit-idle-time = 20

commit 32e2cd6d3216f780c4cffed0f8eb3c30f2c8d732
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Jun 19 21:00:06 2009 +0200

    core: get rid of rt sig/timer handling since modern Linux' ppooll() is finally fixed for granularity

diff --git a/src/Makefile.am b/src/Makefile.am
index 5efe1ac..d5fbf27 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -811,7 +811,6 @@ libpulsecore_ at PA_MAJORMINORMICRO@_la_SOURCES = \
 		pulsecore/play-memchunk.c pulsecore/play-memchunk.h \
 		pulsecore/resampler.c pulsecore/resampler.h \
 		pulsecore/rtpoll.c pulsecore/rtpoll.h \
-		pulsecore/rtsig.c pulsecore/rtsig.h \
 		pulsecore/sample-util.c pulsecore/sample-util.h \
 		pulsecore/sconv-s16be.c pulsecore/sconv-s16be.h \
 		pulsecore/sconv-s16le.c pulsecore/sconv-s16le.h \
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 4b2a1f8..2ecd6c2 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -84,7 +84,6 @@
 #include <pulsecore/pid.h>
 #include <pulsecore/namereg.h>
 #include <pulsecore/random.h>
-#include <pulsecore/rtsig.h>
 #include <pulsecore/rtclock.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/mutex.h>
@@ -797,11 +796,6 @@ int main(int argc, char *argv[]) {
     else
         pa_log_info(_("Dude, your kernel stinks! The chef's recommendation today is Linux with high-resolution timers enabled!"));
 
-#ifdef SIGRTMIN
-    /* Valgrind uses SIGRTMAX. To easy debugging we don't use it here */
-    pa_rtsig_configure(SIGRTMIN, SIGRTMAX-1);
-#endif
-
     if (conf->lock_memory) {
 #ifdef HAVE_SYS_MMAN_H
         if (mlockall(MCL_FUTURE) < 0)
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 281371f..c39a898 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1212,7 +1212,6 @@ static void thread_func(void *userdata) {
         pa_make_realtime(u->core->realtime_priority);
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     for (;;) {
         int ret;
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 4be27eb..755ceae 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -1094,7 +1094,6 @@ static void thread_func(void *userdata) {
         pa_make_realtime(u->core->realtime_priority);
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     for (;;) {
         int ret;
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 6bcd0b8..0f1e78f 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -1265,7 +1265,6 @@ static void thread_func(void *userdata) {
         goto fail;
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     for (;;) {
         struct pollfd *pollfd;
diff --git a/src/modules/jack/module-jack-sink.c b/src/modules/jack/module-jack-sink.c
index 290038e..fc976fa 100644
--- a/src/modules/jack/module-jack-sink.c
+++ b/src/modules/jack/module-jack-sink.c
@@ -225,7 +225,6 @@ static void thread_func(void *userdata) {
         pa_make_realtime(u->core->realtime_priority);
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     for (;;) {
         int ret;
diff --git a/src/modules/jack/module-jack-source.c b/src/modules/jack/module-jack-source.c
index ef89a98..a898e0e 100644
--- a/src/modules/jack/module-jack-source.c
+++ b/src/modules/jack/module-jack-source.c
@@ -196,7 +196,6 @@ static void thread_func(void *userdata) {
         pa_make_realtime(u->core->realtime_priority);
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     for (;;) {
         int ret;
diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c
index 725faa0..cd3118d 100644
--- a/src/modules/module-combine.c
+++ b/src/modules/module-combine.c
@@ -280,7 +280,6 @@ static void thread_func(void *userdata) {
         pa_make_realtime(u->core->realtime_priority+1);
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     u->thread_info.timestamp = pa_rtclock_usec();
     u->thread_info.in_null_mode = FALSE;
diff --git a/src/modules/module-esound-sink.c b/src/modules/module-esound-sink.c
index 8cb25c5..48a9c79 100644
--- a/src/modules/module-esound-sink.c
+++ b/src/modules/module-esound-sink.c
@@ -200,7 +200,6 @@ static void thread_func(void *userdata) {
     pa_log_debug("Thread starting up");
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     pa_smoother_set_time_offset(u->smoother, pa_rtclock_usec());
 
diff --git a/src/modules/module-null-sink.c b/src/modules/module-null-sink.c
index 30a99ca..c4753c9 100644
--- a/src/modules/module-null-sink.c
+++ b/src/modules/module-null-sink.c
@@ -208,7 +208,6 @@ static void thread_func(void *userdata) {
     pa_log_debug("Thread starting up");
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     u->timestamp = pa_rtclock_usec();
 
diff --git a/src/modules/module-pipe-sink.c b/src/modules/module-pipe-sink.c
index 5b0f641..8a7dc84 100644
--- a/src/modules/module-pipe-sink.c
+++ b/src/modules/module-pipe-sink.c
@@ -170,7 +170,6 @@ static void thread_func(void *userdata) {
     pa_log_debug("Thread starting up");
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     for (;;) {
         struct pollfd *pollfd;
diff --git a/src/modules/module-pipe-source.c b/src/modules/module-pipe-source.c
index 61c9fc0..e5609fb 100644
--- a/src/modules/module-pipe-source.c
+++ b/src/modules/module-pipe-source.c
@@ -129,7 +129,6 @@ static void thread_func(void *userdata) {
     pa_log_debug("Thread starting up");
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     for (;;) {
         int ret;
diff --git a/src/modules/module-sine-source.c b/src/modules/module-sine-source.c
index 14a04e4..8df4d9b 100644
--- a/src/modules/module-sine-source.c
+++ b/src/modules/module-sine-source.c
@@ -166,7 +166,6 @@ static void thread_func(void *userdata) {
     pa_log_debug("Thread starting up");
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     u->timestamp = pa_rtclock_usec();
 
diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c
index c493d9b..eaed5f9 100644
--- a/src/modules/module-tunnel.c
+++ b/src/modules/module-tunnel.c
@@ -683,7 +683,6 @@ static void thread_func(void *userdata) {
     pa_log_debug("Thread starting up");
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     for (;;) {
         int ret;
diff --git a/src/modules/oss/module-oss.c b/src/modules/oss/module-oss.c
index b1afcfd..c44b882 100644
--- a/src/modules/oss/module-oss.c
+++ b/src/modules/oss/module-oss.c
@@ -889,7 +889,6 @@ static void thread_func(void *userdata) {
         pa_make_realtime(u->core->realtime_priority);
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     for (;;) {
         int ret;
diff --git a/src/modules/raop/module-raop-sink.c b/src/modules/raop/module-raop-sink.c
index 54de42c..cab3a82 100644
--- a/src/modules/raop/module-raop-sink.c
+++ b/src/modules/raop/module-raop-sink.c
@@ -323,7 +323,6 @@ static void thread_func(void *userdata) {
     pa_log_debug("Thread starting up");
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     pa_smoother_set_time_offset(u->smoother, pa_rtclock_usec());
 
diff --git a/src/pulsecore/rtpoll.c b/src/pulsecore/rtpoll.c
index aa8ca32..185b821 100644
--- a/src/pulsecore/rtpoll.c
+++ b/src/pulsecore/rtpoll.c
@@ -30,10 +30,6 @@
 #include <string.h>
 #include <errno.h>
 
-#ifdef __linux__
-#include <sys/utsname.h>
-#endif
-
 #ifdef HAVE_POLL_H
 #include <poll.h>
 #else
@@ -47,7 +43,6 @@
 #include <pulsecore/rtclock.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/llist.h>
-#include <pulsecore/rtsig.h>
 #include <pulsecore/flist.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/winsock.h>
@@ -66,20 +61,9 @@ struct pa_rtpoll {
 
     pa_bool_t scan_for_dead:1;
     pa_bool_t running:1;
-    pa_bool_t installed:1;
     pa_bool_t rebuild_needed:1;
     pa_bool_t quit:1;
 
-#ifdef HAVE_PPOLL
-    pa_bool_t timer_armed:1;
-#ifdef __linux__
-    pa_bool_t dont_use_ppoll:1;
-#endif
-    int rtsig;
-    sigset_t sigset_unblocked;
-    timer_t timer;
-#endif
-
 #ifdef DEBUG_TIMING
     pa_usec_t timestamp;
     pa_usec_t slept, awake;
@@ -107,52 +91,20 @@ struct pa_rtpoll_item {
 
 PA_STATIC_FLIST_DECLARE(items, 0, pa_xfree);
 
-static void signal_handler_noop(int s) { /* write(2, "signal\n", 7); */ }
-
 pa_rtpoll *pa_rtpoll_new(void) {
     pa_rtpoll *p;
 
     p = pa_xnew(pa_rtpoll, 1);
 
-#ifdef HAVE_PPOLL
-
-#ifdef __linux__
-    /* ppoll is broken on Linux < 2.6.16 */
-    p->dont_use_ppoll = FALSE;
-
-    {
-        struct utsname u;
-        unsigned major, minor, micro;
-
-        pa_assert_se(uname(&u) == 0);
-
-        if (sscanf(u.release, "%u.%u.%u", &major, &minor, &micro) != 3 ||
-            (major < 2) ||
-            (major == 2 && minor < 6) ||
-            (major == 2 && minor == 6 && micro < 16))
-
-            p->dont_use_ppoll = TRUE;
-    }
-
-#endif
-
-    p->rtsig = -1;
-    sigemptyset(&p->sigset_unblocked);
-    p->timer = (timer_t) -1;
-    p->timer_armed = FALSE;
-
-#endif
-
     p->n_pollfd_alloc = 32;
     p->pollfd = pa_xnew(struct pollfd, p->n_pollfd_alloc);
     p->pollfd2 = pa_xnew(struct pollfd, p->n_pollfd_alloc);
     p->n_pollfd_used = 0;
 
-    memset(&p->next_elapse, 0, sizeof(p->next_elapse));
+    pa_zero(p->next_elapse);
     p->timer_enabled = FALSE;
 
     p->running = FALSE;
-    p->installed = FALSE;
     p->scan_for_dead = FALSE;
     p->rebuild_needed = FALSE;
     p->quit = FALSE;
@@ -167,46 +119,6 @@ pa_rtpoll *pa_rtpoll_new(void) {
     return p;
 }
 
-void pa_rtpoll_install(pa_rtpoll *p) {
-    pa_assert(p);
-    pa_assert(!p->installed);
-
-    p->installed = TRUE;
-
-#ifdef HAVE_PPOLL
-# ifdef __linux__
-    if (p->dont_use_ppoll)
-        return;
-# endif
-
-    if ((p->rtsig = pa_rtsig_get_for_thread()) < 0) {
-        pa_log_warn("Failed to reserve POSIX realtime signal.");
-        return;
-    }
-
-    pa_log_debug("Acquired POSIX realtime signal %s", pa_sig2str(p->rtsig));
-
-    {
-        sigset_t ss;
-        struct sigaction sa;
-
-        pa_assert_se(sigemptyset(&ss) == 0);
-        pa_assert_se(sigaddset(&ss, p->rtsig) == 0);
-        pa_assert_se(pthread_sigmask(SIG_BLOCK, &ss, &p->sigset_unblocked) == 0);
-        pa_assert_se(sigdelset(&p->sigset_unblocked, p->rtsig) == 0);
-
-        memset(&sa, 0, sizeof(sa));
-        sa.sa_handler = signal_handler_noop;
-        pa_assert_se(sigemptyset(&sa.sa_mask) == 0);
-
-        pa_assert_se(sigaction(p->rtsig, &sa, NULL) == 0);
-
-        /* We never reset the signal handler. Why should we? */
-    }
-
-#endif
-}
-
 static void rtpoll_rebuild(pa_rtpoll *p) {
 
     struct pollfd *e, *t;
@@ -250,7 +162,6 @@ static void rtpoll_rebuild(pa_rtpoll *p) {
 
     if (ra)
         p->pollfd2 = pa_xrealloc(p->pollfd2, p->n_pollfd_alloc * sizeof(struct pollfd));
-
 }
 
 static void rtpoll_item_destroy(pa_rtpoll_item *i) {
@@ -279,11 +190,6 @@ void pa_rtpoll_free(pa_rtpoll *p) {
     pa_xfree(p->pollfd);
     pa_xfree(p->pollfd2);
 
-#ifdef HAVE_PPOLL
-    if (p->timer != (timer_t) -1)
-        timer_delete(p->timer);
-#endif
-
     pa_xfree(p);
 }
 
@@ -321,7 +227,6 @@ int pa_rtpoll_run(pa_rtpoll *p, pa_bool_t wait) {
 
     pa_assert(p);
     pa_assert(!p->running);
-    pa_assert(p->installed);
 
     p->running = TRUE;
 
@@ -402,22 +307,15 @@ int pa_rtpoll_run(pa_rtpoll *p, pa_bool_t wait) {
 
     /* OK, now let's sleep */
 #ifdef HAVE_PPOLL
-
-#ifdef __linux__
-    if (!p->dont_use_ppoll)
-#endif
     {
         struct timespec ts;
         ts.tv_sec = timeout.tv_sec;
         ts.tv_nsec = timeout.tv_usec * 1000;
-        r = ppoll(p->pollfd, p->n_pollfd_used, (!wait || p->quit || p->timer_enabled) ? &ts : NULL, p->rtsig < 0 ? NULL : &p->sigset_unblocked);
+        r = ppoll(p->pollfd, p->n_pollfd_used, (!wait || p->quit || p->timer_enabled) ? &ts : NULL, NULL);
     }
-#ifdef __linux__
-    else
-#endif
-
-#endif
+#else
         r = poll(p->pollfd, p->n_pollfd_used, (!wait || p->quit || p->timer_enabled) ? (int) ((timeout.tv_sec*1000) + (timeout.tv_usec / 1000)) : -1);
+#endif
 
 #ifdef DEBUG_TIMING
     {
@@ -472,73 +370,11 @@ finish:
     return r < 0 ? r : !p->quit;
 }
 
-static void update_timer(pa_rtpoll *p) {
-    pa_assert(p);
-
-#ifdef HAVE_PPOLL
-
-#ifdef __linux__
-    if (p->dont_use_ppoll)
-        return;
-#endif
-
-    if (p->timer == (timer_t) -1) {
-        struct sigevent se;
-
-        memset(&se, 0, sizeof(se));
-        se.sigev_notify = SIGEV_SIGNAL;
-        se.sigev_signo = p->rtsig;
-
-        if (timer_create(CLOCK_MONOTONIC, &se, &p->timer) < 0)
-            if (timer_create(CLOCK_REALTIME, &se, &p->timer) < 0) {
-                pa_log_warn("Failed to allocate POSIX timer: %s", pa_cstrerror(errno));
-                p->timer = (timer_t) -1;
-            }
-    }
-
-    if (p->timer != (timer_t) -1) {
-        struct itimerspec its;
-        struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 };
-        sigset_t ss;
-
-        if (p->timer_armed) {
-            /* First disarm timer */
-            memset(&its, 0, sizeof(its));
-            pa_assert_se(timer_settime(p->timer, TIMER_ABSTIME, &its, NULL) == 0);
-
-            /* Remove a signal that might be waiting in the signal q */
-            pa_assert_se(sigemptyset(&ss) == 0);
-            pa_assert_se(sigaddset(&ss, p->rtsig) == 0);
-            sigtimedwait(&ss, NULL, &ts);
-        }
-
-        /* And install the new timer */
-        if (p->timer_enabled) {
-            memset(&its, 0, sizeof(its));
-
-            its.it_value.tv_sec = p->next_elapse.tv_sec;
-            its.it_value.tv_nsec = p->next_elapse.tv_usec*1000;
-
-            /* Make sure that 0,0 is not understood as
-             * "disarming" */
-            if (its.it_value.tv_sec == 0 && its.it_value.tv_nsec == 0)
-                its.it_value.tv_nsec = 1;
-            pa_assert_se(timer_settime(p->timer, TIMER_ABSTIME, &its, NULL) == 0);
-        }
-
-        p->timer_armed = p->timer_enabled;
-    }
-
-#endif
-}
-
 void pa_rtpoll_set_timer_absolute(pa_rtpoll *p, pa_usec_t usec) {
     pa_assert(p);
 
     pa_timeval_store(&p->next_elapse, usec);
     p->timer_enabled = TRUE;
-
-    update_timer(p);
 }
 
 void pa_rtpoll_set_timer_relative(pa_rtpoll *p, pa_usec_t usec) {
@@ -550,8 +386,6 @@ void pa_rtpoll_set_timer_relative(pa_rtpoll *p, pa_usec_t usec) {
     pa_rtclock_get(&p->next_elapse);
     pa_timeval_add(&p->next_elapse, usec);
     p->timer_enabled = TRUE;
-
-    update_timer(p);
 }
 
 void pa_rtpoll_set_timer_disabled(pa_rtpoll *p) {
@@ -559,8 +393,6 @@ void pa_rtpoll_set_timer_disabled(pa_rtpoll *p) {
 
     memset(&p->next_elapse, 0, sizeof(p->next_elapse));
     p->timer_enabled = FALSE;
-
-    update_timer(p);
 }
 
 pa_rtpoll_item *pa_rtpoll_item_new(pa_rtpoll *p, pa_rtpoll_priority_t prio, unsigned n_fds) {
diff --git a/src/pulsecore/rtpoll.h b/src/pulsecore/rtpoll.h
index 08776ef..d2d69ca 100644
--- a/src/pulsecore/rtpoll.h
+++ b/src/pulsecore/rtpoll.h
@@ -62,9 +62,6 @@ typedef enum pa_rtpoll_priority {
 pa_rtpoll *pa_rtpoll_new(void);
 void pa_rtpoll_free(pa_rtpoll *p);
 
-/* Install the rtpoll in the current thread */
-void pa_rtpoll_install(pa_rtpoll *p);
-
 /* Sleep on the rtpoll until the time event, or any of the fd events
  * is triggered. If "wait" is 0 we don't sleep but only update the
  * struct pollfd. Returns negative on error, positive if the loop
diff --git a/src/pulsecore/rtsig.c b/src/pulsecore/rtsig.c
deleted file mode 100644
index 4cd6aa8..0000000
--- a/src/pulsecore/rtsig.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/***
-  This file is part of PulseAudio.
-
-  Copyright 2004-2006 Lennart Poettering
-  Copyright 2006 Pierre Ossman <ossman at 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
-  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, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-  USA.
-***/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <signal.h>
-
-#include <pulsecore/macro.h>
-#include <pulsecore/flist.h>
-#include <pulsecore/once.h>
-#include <pulsecore/thread.h>
-#include <pulsecore/core-util.h>
-
-#include "rtsig.h"
-
-#ifdef SIGRTMIN
-
-static void _free_rtsig(void *p) {
-    pa_rtsig_put(PA_PTR_TO_INT(p));
-}
-
-PA_STATIC_FLIST_DECLARE(rtsig_flist, pa_make_power_of_two((unsigned) (SIGRTMAX-SIGRTMIN+1)), NULL);
-PA_STATIC_TLS_DECLARE(rtsig_tls, _free_rtsig);
-
-static pa_atomic_t rtsig_current = PA_ATOMIC_INIT(-1);
-
-static int rtsig_start = -1, rtsig_end = -1;
-
-int pa_rtsig_get(void) {
-    void *p;
-    int sig;
-
-    if ((p = pa_flist_pop(PA_STATIC_FLIST_GET(rtsig_flist))))
-        return PA_PTR_TO_INT(p);
-
-    sig = pa_atomic_dec(&rtsig_current);
-
-    pa_assert(sig <= SIGRTMAX);
-    pa_assert(sig <= rtsig_end);
-
-    if (sig < rtsig_start) {
-        pa_atomic_inc(&rtsig_current);
-        return -1;
-    }
-
-    return sig;
-}
-
-int pa_rtsig_get_for_thread(void) {
-    int sig;
-    void *p;
-
-    if ((p = PA_STATIC_TLS_GET(rtsig_tls)))
-        return PA_PTR_TO_INT(p);
-
-    if ((sig = pa_rtsig_get()) < 0)
-        return -1;
-
-    PA_STATIC_TLS_SET(rtsig_tls, PA_INT_TO_PTR(sig));
-    return sig;
-}
-
-void pa_rtsig_put(int sig) {
-    pa_assert(sig >= rtsig_start);
-    pa_assert(sig <= rtsig_end);
-
-    pa_assert_se(pa_flist_push(PA_STATIC_FLIST_GET(rtsig_flist), PA_INT_TO_PTR(sig)) >= 0);
-}
-
-void pa_rtsig_configure(int start, int end) {
-    int s;
-    sigset_t ss;
-
-    pa_assert(pa_atomic_load(&rtsig_current) == -1);
-
-    pa_assert(SIGRTMIN <= start);
-    pa_assert(start <= end);
-    pa_assert(end <= SIGRTMAX);
-
-    rtsig_start = start;
-    rtsig_end = end;
-
-    sigemptyset(&ss);
-
-    for (s = rtsig_start; s <= rtsig_end; s++)
-        pa_assert_se(sigaddset(&ss, s) == 0);
-
-    pa_assert(pthread_sigmask(SIG_BLOCK, &ss, NULL) == 0);
-
-    /* We allocate starting from the end */
-    pa_atomic_store(&rtsig_current, rtsig_end);
-}
-
-#else /* SIGRTMIN */
-
-int pa_rtsig_get(void) {
-    return -1;
-}
-
-int pa_rtsig_get_for_thread(void) {
-    return -1;
-}
-
-void pa_rtsig_put(int sig) {
-}
-
-void pa_rtsig_configure(int start, int end) {
-}
-
-#endif /* SIGRTMIN */
diff --git a/src/pulsecore/rtsig.h b/src/pulsecore/rtsig.h
deleted file mode 100644
index e414122..0000000
--- a/src/pulsecore/rtsig.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef foopulsertsighfoo
-#define foopulsertsighfoo
-
-/***
-  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
-  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, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-  USA.
-***/
-
-/* Return the next unused POSIX Realtime signals */
-int pa_rtsig_get(void);
-
-/* If not called before in the current thread, return the next unused
- * rtsig, and install it in a TLS region and give it up automatically
- * when the thread shuts down */
-int pa_rtsig_get_for_thread(void);
-
-/* Give an rtsig back. */
-void pa_rtsig_put(int sig);
-
-/* Block all RT signals */
-void pa_rtsig_configure(int start, int end);
-
-#endif
diff --git a/src/tests/rtpoll-test.c b/src/tests/rtpoll-test.c
index 4ac9644..1706cdf 100644
--- a/src/tests/rtpoll-test.c
+++ b/src/tests/rtpoll-test.c
@@ -26,7 +26,6 @@
 
 #include <pulsecore/log.h>
 #include <pulsecore/rtpoll.h>
-#include <pulsecore/rtsig.h>
 
 static int before(pa_rtpoll_item *i) {
     pa_log("before");
@@ -47,10 +46,6 @@ int main(int argc, char *argv[]) {
     pa_rtpoll_item *i, *w;
     struct pollfd *pollfd;
 
-#ifdef SIGRTMIN
-    pa_rtsig_configure(SIGRTMIN+10, SIGRTMAX);
-#endif
-
     p = pa_rtpoll_new();
 
     i = pa_rtpoll_item_new(p, PA_RTPOLL_EARLY, 1);
@@ -64,7 +59,6 @@ int main(int argc, char *argv[]) {
     w = pa_rtpoll_item_new(p, PA_RTPOLL_NORMAL, 0);
     pa_rtpoll_item_set_before_callback(w, worker);
 
-    pa_rtpoll_install(p);
     pa_rtpoll_set_timer_relative(p, 10000000); /* 10 s */
 
     pa_rtpoll_run(p, 1);

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list