catch up with trunk HEAD (i.e. 2118:2213)

git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2214 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2008-03-31 23:08:01 +00:00
parent 106ddb9211
commit ecf6439661
24 changed files with 545 additions and 216 deletions

View file

@ -5,7 +5,7 @@
# This file is part of PulseAudio.
#
# Copyright 2004-2006 Lennart Poettering
# Copyright 2004-2008 Lennart Poettering
# Copyright 2006-2007 Pierre Ossman <ossman@cendio.se> for Cendio AB
#
# PulseAudio is free software; you can redistribute it and/or modify it
@ -22,11 +22,11 @@
# along with PulseAudio; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
AC_PREREQ(2.57)
AC_PREREQ(2.60)
m4_define(PA_MAJOR, [0])
m4_define(PA_MINOR, [9])
m4_define(PA_MICRO, [8])
m4_define(PA_MICRO, [10])
AC_INIT([pulseaudio], PA_MAJOR.PA_MINOR.PA_MICRO,[mzchyfrnhqvb (at) 0pointer (dot) net])
AC_CONFIG_SRCDIR([src/daemon/main.c])
@ -41,7 +41,7 @@ AC_SUBST(PA_PROTOCOL_VERSION, 12)
# The stable ABI for client applications, for the version info x:y:z
# always will hold y=z
AC_SUBST(LIBPULSE_VERSION_INFO, [4:0:4])
AC_SUBST(LIBPULSE_VERSION_INFO, [4:1:4])
# A simplified, synchronous, ABI-stable interface for client
# applications, for the version info x:y:z always will hold y=z
@ -58,7 +58,7 @@ AC_SUBST(LIBPULSE_MAINLOOP_GLIB_VERSION_INFO, [0:3:0])
# An internally used, ABI-unstable library that contains the
# PulseAudio core, SONAMEs are bumped on every release, version info
# suffix will always be 0:0
AC_SUBST(LIBPULSECORE_VERSION_INFO, [5:0:0])
AC_SUBST(LIBPULSECORE_VERSION_INFO, [5:1:0])
AC_CANONICAL_HOST
@ -125,6 +125,43 @@ if test "x$GCC" = "xyes" ; then
done
fi
# Native atomic operation support
AC_ARG_ENABLE([atomic-arm-linux-helpers],
AC_HELP_STRING([--disable-atomic-arm-linux-helpers], [use inline asm or libatomic_ops instead]),
[
case "${enableval}" in
yes) atomic_arm_linux_helpers=yes ;;
no) atomic_arm_linux_helpers=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for --disable-atomic-arm-linux-helpers) ;;
esac
],
[atomic_arm_linux_helpers=auto])
AC_ARG_ENABLE([atomic-arm-memory-barrier],
AC_HELP_STRING([--enable-atomic-arm-memory-barrier], [only really needed in SMP arm systems]),
[
case "${enableval}" in
yes) AC_DEFINE_UNQUOTED(ATOMIC_ARM_MEMORY_BARRIER_ENABLED, 1, [Enable memory barriers]) ;;
no) ;;
*) AC_MSG_ERROR(bad value ${enableval} for --disable-atomic-arm-linux-helpers) ;;
esac
],)
AC_MSG_CHECKING([target operating system])
case $host in
*-*-linux*)
AC_MSG_RESULT([linux])
pulse_target_os=linux
;;
*)
AC_MSG_RESULT([unknown])
pulse_target_os=unknown
;;
esac
# If everything else fails use libatomic_ops
need_libatomic_ops=yes
AC_MSG_CHECKING([whether $CC knows __sync_bool_compare_and_swap()])
AC_LANG_CONFTEST([int main() { int a = 4; __sync_bool_compare_and_swap(&a, 4, 5); }])
$CC conftest.c $CFLAGS -o conftest > /dev/null 2> /dev/null
@ -133,8 +170,53 @@ rm -f conftest.o conftest
if test $ret -eq 0 ; then
AC_DEFINE([HAVE_ATOMIC_BUILTINS], 1, [Have __sync_bool_compare_and_swap() and friends.])
AC_MSG_RESULT([yes])
need_libatomic_ops=no
else
AC_MSG_RESULT([no])
# HW specific atomic ops stuff
AC_MSG_CHECKING([architecture for native atomic operations])
case $host_cpu in
arm*)
AC_MSG_RESULT([arm])
AC_MSG_CHECKING([whether we can use Linux kernel helpers])
# The Linux kernel helper functions have been there since 2.6.16. However
# compile time checking for kernel version in cross compile environment
# (which is usually the case for arm cpu) is tricky (or impossible).
if test "x$pulse_target_os" = "xlinux" && test "x$atomic_arm_linux_helpers" != "xno"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(ATOMIC_ARM_LINUX_HELPERS, 1, [special arm linux implementation])
need_libatomic_ops=no
else
AC_MSG_RESULT([no])
AC_MSG_CHECKING([compiler support for arm inline asm atomic operations])
AC_LANG_CONFTEST([[int main()
{
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);
}]])
$CC conftest.c $CFLAGS -o conftest > /dev/null 2>&1
ret=$?
rm -f conftest.o conftest
if test $ret -eq 0 ; then
AC_DEFINE([ATOMIC_ARM_INLINE_ASM], 1, [Have ARMv6 instructions.])
AC_MSG_RESULT([yes])
need_libatomic_ops=no
else
AC_MSG_RESULT([no])
fi
fi
;;
*)
AC_MSG_RESULT([unknown])
;;
esac
fi
AC_MSG_CHECKING([whether $CC knows __thread])
@ -413,13 +495,19 @@ AC_SUBST(LIBSNDFILE_LIBS)
#### atomic-ops ###
AC_CHECK_HEADERS([atomic_ops.h], [], [
AC_MSG_ERROR([*** libatomic-ops headers not found])
])
AC_MSG_CHECKING([whether we need libatomic_ops])
if test "x$need_libatomic_ops" = "xyes"; then
AC_MSG_RESULT([yes])
AC_CHECK_HEADERS([atomic_ops.h], [], [
AC_MSG_ERROR([*** libatomic-ops headers not found])
])
# Win32 does not need the lib and breaks horribly if we try to include it
if test "x$os_is_win32" != "x1" ; then
LIBS="$LIBS -latomic_ops"
# Win32 does not need the lib and breaks horribly if we try to include it
if test "x$os_is_win32" != "x1" ; then
LIBS="$LIBS -latomic_ops"
fi
else
AC_MSG_RESULT([no])
fi
#### Libsamplerate support (optional) ####
@ -889,13 +977,9 @@ AC_ARG_ENABLE([polkit],
if test "x${polkit}" != xno ; then
PKG_CHECK_MODULES(POLKIT, [ polkit-dbus ],
PKG_CHECK_MODULES(POLKIT, [ polkit-dbus >= 0.7 ],
[
HAVE_POLKIT=1
saved_LIBS="$LIBS"
LIBS="$LIBS $POLKIT_LIBS"
AC_CHECK_FUNCS(polkit_context_is_caller_authorized)
LIBS="$saved_LIBS"
AC_DEFINE([HAVE_POLKIT], 1, [Have PolicyKit])
policydir=`pkg-config polkit-dbus --variable prefix`/share/PolicyKit/policy/
AC_SUBST(policydir)
@ -990,10 +1074,20 @@ fi
AC_SUBST(PA_ACCESS_GROUP)
AC_DEFINE_UNQUOTED(PA_ACCESS_GROUP,"$PA_ACCESS_GROUP", [Access group])
AC_ARG_WITH(peruser_esound, AS_HELP_STRING([--with-peruser-esound-socket], [Use per-user esound socket directory, like /tmp/.esd-UID/socket.]))
AC_ARG_ENABLE(
per_user_esound_socket,
AS_HELP_STRING([--disable-per-user-esound-socket], [Use global esound socket directory /tmp/.esd/socket.]),
[
case "${enableval}" in
yes) per_user_esound_socket=1 ;;
no) per_user_esound_socket=0 ;;
*) AC_MSG_ERROR(bad value ${enableval} for --disable-per-user-esound-socket) ;;
esac
],
[per_user_esound_socket=1])
if test "x$with_peruser_esound" = "xyes"; then
AC_DEFINE([USE_PERUSER_ESOUND_SOCKET], [1], [Define this if you want per-user esound socket directories])
if test "x$per_user_esound_socket" = "x1"; then
AC_DEFINE([USE_PER_USER_ESOUND_SOCKET], [1], [Define this if you want per-user esound socket directories])
fi
#### PulseAudio system runtime dir ####
@ -1127,32 +1221,38 @@ if test "x${HAVE_POLKIT}" = "x1" ; then
ENABLE_POLKIT=yes
fi
ENABLE_PER_USER_ESOUND_SOCKET=no
if test "x$per_user_esound_socket" = "x1" ; then
ENABLE_PER_USER_ESOUND_SOCKET=yes
fi
echo "
---{ $PACKAGE_NAME $VERSION }---
prefix: ${prefix}
sysconfdir: ${sysconfdir}
localstatedir: ${localstatedir}
System Runtime Path: ${PA_SYSTEM_RUNTIME_PATH}
Compiler: ${CC}
CFLAGS: ${CFLAGS}
Have X11: ${ENABLE_X11}
Enable OSS: ${ENABLE_OSS}
Enable Alsa: ${ENABLE_ALSA}
Enable Solaris: ${ENABLE_SOLARIS}
Enable GLib 2.0: ${ENABLE_GLIB20}
Enable GConf: ${ENABLE_GCONF}
Enable Avahi: ${ENABLE_AVAHI}
Enable Jack: ${ENABLE_JACK}
Enable Async DNS: ${ENABLE_LIBASYNCNS}
Enable LIRC: ${ENABLE_LIRC}
Enable HAL: ${ENABLE_HAL}
Enable BlueZ: ${ENABLE_BLUEZ}
Enable TCP Wrappers: ${ENABLE_TCPWRAP}
Enable libsamplerate: ${ENABLE_LIBSAMPLERATE}
Enable PolicyKit: ${ENABLE_POLKIT}
System User: ${PA_SYSTEM_USER}
System Group: ${PA_SYSTEM_GROUP}
Realtime Group: ${PA_REALTIME_GROUP}
Access Group: ${PA_ACCESS_GROUP}
prefix: ${prefix}
sysconfdir: ${sysconfdir}
localstatedir: ${localstatedir}
System Runtime Path: ${PA_SYSTEM_RUNTIME_PATH}
Compiler: ${CC}
CFLAGS: ${CFLAGS}
Have X11: ${ENABLE_X11}
Enable OSS: ${ENABLE_OSS}
Enable Alsa: ${ENABLE_ALSA}
Enable Solaris: ${ENABLE_SOLARIS}
Enable GLib 2.0: ${ENABLE_GLIB20}
Enable GConf: ${ENABLE_GCONF}
Enable Avahi: ${ENABLE_AVAHI}
Enable Jack: ${ENABLE_JACK}
Enable Async DNS: ${ENABLE_LIBASYNCNS}
Enable LIRC: ${ENABLE_LIRC}
Enable HAL: ${ENABLE_HAL}
Enable BlueZ: ${ENABLE_BLUEZ}
Enable TCP Wrappers: ${ENABLE_TCPWRAP}
Enable libsamplerate: ${ENABLE_LIBSAMPLERATE}
Enable PolicyKit: ${ENABLE_POLKIT}
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}
"

View file

@ -64,7 +64,7 @@ AM_LIBADD = $(PTHREAD_LIBS)
AM_LDADD = $(PTHREAD_LIBS)
# Only required on some platforms but defined for all to avoid errors
AM_LDFLAGS = -Wl,-no-undefined -ffunction-sections -fdata-sections -Wl,--gc-sections
AM_LDFLAGS = -Wl,-no-undefined -Wl,--gc-sections
if STATIC_BINS
BINLDFLAGS = -static
@ -103,7 +103,7 @@ EXTRA_DIST = \
modules/module-defs.h.m4 \
daemon/pulseaudio-module-xsmp.desktop \
map-file \
daemon/PulseAudio.policy
daemon/org.pulseaudio.policy
pulseconf_DATA = \
default.pa \
@ -154,7 +154,7 @@ endif
if HAVE_POLKIT
policy_DATA = daemon/PulseAudio.policy
policy_DATA = daemon/org.pulseaudio.policy
pulseaudio_SOURCES += daemon/polkit.c daemon/polkit.h
pulseaudio_CFLAGS += $(POLKIT_CFLAGS)
@ -202,7 +202,7 @@ pactl_LDADD = $(AM_LDADD) libpulse.la $(LIBSNDFILE_LIBS)
pactl_CFLAGS = $(AM_CFLAGS) $(LIBSNDFILE_CFLAGS)
pactl_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
pasuspender_SOURCES = utils/pasuspender.c
pasuspender_SOURCES = utils/pasuspender.c pulsecore/core-util.c pulsecore/core-util.h pulsecore/core-error.c pulsecore/core-error.h pulsecore/log.c pulsecore/log.h pulsecore/once.c pulsecore/once.h $(PA_THREAD_OBJS)
pasuspender_LDADD = $(AM_LDADD) libpulse.la $(LIBSNDFILE_LIBS)
pasuspender_CFLAGS = $(AM_CFLAGS) $(LIBSNDFILE_CFLAGS)
pasuspender_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
@ -275,7 +275,7 @@ mainloop_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
thread_mainloop_test_SOURCES = tests/thread-mainloop-test.c
thread_mainloop_test_CFLAGS = $(AM_CFLAGS)
thread_mainloop_test_LDADD = $(AM_LDADD) libpulse.la
thread_mainloop_test_LDADD = $(AM_LDADD) libpulsecore.la libpulse.la
thread_mainloop_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
utf8_test_SOURCES = tests/utf8-test.c
@ -577,7 +577,14 @@ libpulse_la_CFLAGS += $(LIBASYNCNS_CFLAGS)
libpulse_la_LIBADD += $(LIBASYNCNS_LIBS)
endif
libpulse_simple_la_SOURCES = pulse/simple.c pulse/simple.h
libpulse_simple_la_SOURCES = \
pulse/simple.c pulse/simple.h \
pulsecore/log.c pulsecore/log.h \
pulsecore/core-util.c pulsecore/core-util.h \
pulsecore/core-error.c pulsecore/core-error.h \
pulsecore/once.c pulsecore/once.h \
$(PA_THREAD_OBJS)
libpulse_simple_la_CFLAGS = $(AM_CFLAGS)
libpulse_simple_la_LIBADD = $(AM_LIBADD) libpulse.la
libpulse_simple_la_LDFLAGS = -version-info $(LIBPULSE_SIMPLE_VERSION_INFO) -Wl,-version-script=$(srcdir)/map-file
@ -587,7 +594,13 @@ libpulse_browse_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
libpulse_browse_la_LIBADD = $(AM_LIBADD) libpulse.la $(AVAHI_LIBS)
libpulse_browse_la_LDFLAGS = -version-info $(LIBPULSE_BROWSE_VERSION_INFO) -Wl,-version-script=$(srcdir)/map-file
libpulse_mainloop_glib_la_SOURCES = pulse/glib-mainloop.h pulse/glib-mainloop.c
libpulse_mainloop_glib_la_SOURCES = \
pulse/glib-mainloop.h pulse/glib-mainloop.c \
pulsecore/log.c pulsecore/log.h \
pulsecore/core-util.c pulsecore/core-util.h \
pulsecore/core-error.c pulsecore/core-error.h \
pulsecore/once.c pulsecore/once.h \
$(PA_THREAD_OBJS)
libpulse_mainloop_glib_la_CFLAGS = $(AM_CFLAGS) $(GLIB20_CFLAGS)
libpulse_mainloop_glib_la_LIBADD = $(AM_LIBADD) libpulse.la $(GLIB20_LIBS)
libpulse_mainloop_glib_la_LDFLAGS = -version-info $(LIBPULSE_MAINLOOP_GLIB_VERSION_INFO) -Wl,-version-script=$(srcdir)/map-file

View file

@ -90,8 +90,8 @@ int pa_limit_caps(void) {
cap_t caps;
cap_value_t nice_cap = CAP_SYS_NICE;
caps = cap_init();
pa_assert(caps);
pa_assert_se(caps = cap_init());
cap_clear(caps);
cap_set_flag(caps, CAP_EFFECTIVE, 1, &nice_cap, CAP_SET);
cap_set_flag(caps, CAP_PERMITTED, 1, &nice_cap, CAP_SET);
@ -113,28 +113,15 @@ fail:
}
/* Drop all capabilities, effectively becoming a normal user */
int pa_drop_caps(void) {
void pa_drop_caps(void) {
cap_t caps;
int r = -1;
caps = cap_init();
pa_assert(caps);
pa_assert_se(prctl(PR_SET_KEEPCAPS, 0, 0, 0, 0) == 0);
pa_assert_se(caps = cap_init());
cap_clear(caps);
prctl(PR_SET_KEEPCAPS, 0, 0, 0, 0);
if (cap_set_proc(caps) < 0) {
pa_log("Failed to drop capabilities: %s", pa_cstrerror(errno));
goto fail;
}
r = 0;
fail:
pa_assert_se(cap_set_proc(caps) == 0);
cap_free(caps);
return r;
}
#else
@ -144,9 +131,8 @@ int pa_limit_caps(void) {
return 0;
}
int pa_drop_caps(void) {
void pa_drop_caps(void) {
pa_drop_root();
return 0;
}
#endif

View file

@ -25,7 +25,7 @@
***/
void pa_drop_root(void);
void pa_drop_caps(void);
int pa_limit_caps(void);
int pa_drop_caps(void);
#endif

View file

@ -151,7 +151,7 @@ static void signal_handler(int sig) {
} else if (phase == PHASE_SOFT) {
write_err("Hard CPU time limit exhausted, terminating forcibly.\n");
_exit(1); /* Forced exit */
abort(); /* Forced exit */
}
errno = saved_errno;

View file

@ -38,7 +38,7 @@
; module-idle-time = 20
; scache-idle-time = 20
; dl-search-path = @PA_DLSEARCHPATH@
; dl-search-path = (depends on architecture)
; default-script-file = @PA_DEFAULT_CONFIG_FILE@

View file

@ -37,7 +37,7 @@ load-sample-lazy pulse-hotplug /usr/share/sounds/startup3.wav
#load-module module-pipe-sink
### Automatically load driver modules depending on the hardware available
.ifexists @PA_DLSEARCHPATH@/module-hal-detect@PA_SOEXT@
.ifexists module-hal-detect@PA_SOEXT@
load-module module-hal-detect
.else
### Alternatively use the static hardware detection module (for systems that
@ -46,7 +46,9 @@ load-module module-detect
.endif
### Load several protocols
.ifexists module-esound-protocol-unix@PA_SOEXT@
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix
### Network access (may be configured with paprefs, so leave this commented
@ -78,11 +80,6 @@ load-module module-suspend-on-idle
### Load X11 bell module
#load-module module-x11-bell sample=x11-bell
### Publish connection data in the X11 root window
.ifexists @PA_DLSEARCHPATH@/module-x11-publish@PA_SOEXT@
load-module module-x11-publish
.endif
### Register ourselves in the X11 session manager
# Deactivated by default, to avoid deadlock when PA is started as esd from gnome-session
# Instead we load this via /etc/xdg/autostart/ and "pactl load-module" now
@ -91,8 +88,17 @@ load-module module-x11-publish
### Load additional modules from GConf settings. This can be configured with the paprefs tool.
### Please keep in mind that the modules configured by paprefs might conflict with manually
### loaded modules.
.ifexists @PA_DLSEARCHPATH@/module-gconf@PA_SOEXT@
.ifexists module-gconf@PA_SOEXT@
.nofail
load-module module-gconf
.fail
.endif
### Publish connection data in the X11 root window
.ifexists module-x11-publish@PA_SOEXT@
.nofail
load-module module-x11-publish
.fail
.endif
### Make some devices default

View file

@ -242,7 +242,8 @@ static int change_user(void) {
}
set_env("USER", PA_SYSTEM_USER);
set_env("LOGNAME", PA_SYSTEM_GROUP);
set_env("USERNAME", PA_SYSTEM_USER);
set_env("LOGNAME", PA_SYSTEM_USER);
set_env("HOME", PA_SYSTEM_RUNTIME_PATH);
/* Relevant for pa_runtime_path() */
@ -778,7 +779,7 @@ int main(int argc, char *argv[]) {
c->disallow_module_loading = !!conf->disallow_module_loading;
if (r < 0 && conf->fail) {
pa_log("failed to initialize daemon.");
pa_log("Failed to initialize daemon.");
#ifdef HAVE_FORK
if (conf->daemonize)
pa_loop_write(daemon_pipe[1], &retval, sizeof(retval), NULL);
@ -792,16 +793,19 @@ int main(int argc, char *argv[]) {
} else {
retval = 0;
if (c->default_sink_name &&
pa_namereg_get(c, c->default_sink_name, PA_NAMEREG_SINK, 1) == NULL) {
pa_log_error("%s : Default sink name (%s) does not exist in name register.", __FILE__, c->default_sink_name);
retval = !!conf->fail;
}
#ifdef HAVE_FORK
if (conf->daemonize)
pa_loop_write(daemon_pipe[1], &retval, sizeof(retval), NULL);
#endif
if (c->default_sink_name &&
pa_namereg_get(c, c->default_sink_name, PA_NAMEREG_SINK, 1) == NULL) {
pa_log_error("%s : Fatal error. Default sink name (%s) does not exist in name register.", __FILE__, c->default_sink_name);
retval = 1;
} else {
if (!retval) {
pa_log_info("Daemon startup complete.");
if (pa_mainloop_run(mainloop, &retval) < 0)
retval = 1;

View file

@ -25,6 +25,9 @@ USA.
-->
<policyconfig>
<vendor>The PulseAudio Project</vendor>
<vendor_url>http://pulseaudio.org/</vendor_url>
<icon_name>audio-card</icon_name>
<action id="org.pulseaudio.acquire-real-time">
<description>Real-time scheduling for the PulseAudio daemon</description>

View file

@ -38,59 +38,6 @@
#include "polkit.h"
static pa_bool_t show_grant_dialog(const char *action_id) {
DBusError dbus_error;
DBusConnection *bus = NULL;
DBusMessage *m = NULL, *reply = NULL;
pa_bool_t r = FALSE;
uint32_t xid = 0;
int verdict;
dbus_error_init(&dbus_error);
if (!(bus = dbus_bus_get(DBUS_BUS_SESSION, &dbus_error))) {
pa_log_error("Cannot connect to session bus: %s", dbus_error.message);
goto finish;
}
if (!(m = dbus_message_new_method_call("org.gnome.PolicyKit", "/org/gnome/PolicyKit/Manager", "org.gnome.PolicyKit.Manager", "ShowDialog"))) {
pa_log_error("Failed to allocate D-Bus message.");
goto finish;
}
if (!(dbus_message_append_args(m, DBUS_TYPE_STRING, &action_id, DBUS_TYPE_UINT32, &xid, DBUS_TYPE_INVALID))) {
pa_log_error("Failed to append arguments to D-Bus message.");
goto finish;
}
if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &dbus_error))) {
pa_log_warn("Failed to show grant dialog: %s", dbus_error.message);
goto finish;
}
if (!(dbus_message_get_args(reply, &dbus_error, DBUS_TYPE_BOOLEAN, &verdict, DBUS_TYPE_INVALID))) {
pa_log_warn("Malformed response from grant manager: %s", dbus_error.message);
goto finish;
}
r = !!verdict;
finish:
if (bus)
dbus_connection_unref(bus);
dbus_error_free(&dbus_error);
if (m)
dbus_message_unref(m);
if (reply)
dbus_message_unref(reply);
return r;
}
int pa_polkit_check(const char *action_id) {
int ret = -1;
DBusError dbus_error;
@ -161,35 +108,32 @@ int pa_polkit_check(const char *action_id) {
for (;;) {
#ifdef HAVE_POLKIT_CONTEXT_IS_CALLER_AUTHORIZED
polkit_result = polkit_context_is_caller_authorized(context, action, caller, TRUE, &polkit_error);
if (polkit_error_is_set(polkit_error)) {
pa_log_error("Could not determine whether caller is authorized: %s", polkit_error_get_error_message(polkit_error));
goto finish;
}
#else
polkit_result = polkit_context_can_caller_do_action(context, action, caller);
#endif
if (polkit_result == POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH ||
polkit_result == POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION ||
polkit_result == POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS ||
#ifdef POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_ONE_SHOT
polkit_result == POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_ONE_SHOT ||
#endif
polkit_result == POLKIT_RESULT_ONLY_VIA_SELF_AUTH ||
polkit_result == POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION ||
polkit_result == POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS
#ifdef POLKIT_RESULT_ONLY_VIA_SELF_AUTH_ONE_SHOT
|| polkit_result == POLKIT_RESULT_ONLY_VIA_SELF_AUTH_ONE_SHOT
#endif
polkit_result == POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS ||
polkit_result == POLKIT_RESULT_ONLY_VIA_SELF_AUTH_ONE_SHOT
) {
if (show_grant_dialog(action_id))
continue;
if (polkit_auth_obtain(action_id, 0, getpid(), &dbus_error)) {
polkit_result = POLKIT_RESULT_YES;
break;
}
if (dbus_error_is_set(&dbus_error)) {
pa_log_error("Cannot obtain auth: %s", dbus_error.message);
goto finish;
}
}
break;

View file

@ -1,35 +1,29 @@
/* $Id$ */
/***
This file is part of PulseAudio.
Copyright 2007 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 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
***/
/*
* Small SUID helper that allows us to ping a BT device. Borrows
* heavily from bluez-utils' l2ping, which is licensed as GPL2+, too
* heavily from bluez-utils' l2ping, which is licensed as GPL2+
* and comes with a copyright like this:
*
* Copyright (C) 2000-2001 Qualcomm Incorporated
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
* Copyright (C) 2002-2007 Marcel Holtmann <marcel@holtmann.org>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H

View file

@ -484,8 +484,7 @@ int pa__init(pa_module*m) {
if (p > n_control || k) {
pa_log("Too many control values passed, %lu expected.", n_control);
if (k)
pa_xfree(k);
pa_xfree(k);
goto fail;
}

View file

@ -218,7 +218,7 @@ int pa__init(pa_module*m) {
char tmp[PATH_MAX];
#if defined(USE_PROTOCOL_ESOUND)
#if defined(USE_PERUSER_ESOUND_SOCKET)
#if defined(USE_PER_USER_ESOUND_SOCKET)
char esdsocketpath[PATH_MAX];
#else
const char esdsocketpath[] = "/tmp/.esd/socket";
@ -269,9 +269,10 @@ int pa__init(pa_module*m) {
#if defined(USE_PROTOCOL_ESOUND)
#if defined(USE_PERUSER_ESOUND_SOCKET)
#if defined(USE_PER_USER_ESOUND_SOCKET)
snprintf(esdsocketpath, sizeof(esdsocketpath), "/tmp/.esd-%lu/socket", (unsigned long) getuid());
#endif
pa_runtime_path(pa_modargs_get_value(ma, "socket", esdsocketpath), tmp, sizeof(tmp));
u->socket_path = pa_xstrdup(tmp);

View file

@ -723,7 +723,7 @@ static void sink_info_cb(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uint3
goto fail;
}
if (strcmp(name, u->sink_name))
if (!u->sink_name || strcmp(name, u->sink_name))
return;
pa_xfree(u->device_description);
@ -836,7 +836,7 @@ static void source_info_cb(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED uin
goto fail;
}
if (strcmp(name, u->source_name))
if (!u->source_name || strcmp(name, u->source_name))
return;
pa_xfree(u->device_description);

View file

@ -65,7 +65,7 @@
#include "util.h"
char *pa_get_user_name(char *s, size_t l) {
char *p;
const char *p;
char buf[1024];
#ifdef HAVE_PWD_H
@ -75,7 +75,10 @@ char *pa_get_user_name(char *s, size_t l) {
pa_assert(s);
pa_assert(l > 0);
if (!(p = getenv("USER")) && !(p = getenv("LOGNAME")) && !(p = getenv("USERNAME"))) {
if (!(p = (getuid() == 0 ? "root" : NULL)) &&
!(p = getenv("USER")) &&
!(p = getenv("LOGNAME")) &&
!(p = getenv("USERNAME"))) {
#ifdef HAVE_PWD_H
#ifdef HAVE_GETPWUID_R

View file

@ -36,7 +36,7 @@
* On gcc >= 4.1 we use the builtin atomic functions. otherwise we use
* libatomic_ops
*/
#
#ifndef PACKAGE
#error "Please include config.h before including this file!"
#endif
@ -182,6 +182,235 @@ static inline int pa_atomic_ptr_cmpxchg(pa_atomic_ptr_t *a, void *old_p, void* n
return result;
}
#elif defined(ATOMIC_ARM_INLINE_ASM)
/*
These should only be enabled if we have ARMv6 or better.
*/
typedef struct pa_atomic {
volatile int value;
} pa_atomic_t;
#define PA_ATOMIC_INIT(v) { .value = (v) }
static inline void pa_memory_barrier(void) {
#ifdef ATOMIC_ARM_MEMORY_BARRIER_ENABLED
asm volatile ("mcr p15, 0, r0, c7, c10, 5 @ dmb");
#endif
}
static inline int pa_atomic_load(const pa_atomic_t *a) {
pa_memory_barrier();
return a->value;
}
static inline void pa_atomic_store(pa_atomic_t *a, int i) {
a->value = i;
pa_memory_barrier();
}
/* Returns the previously set value */
static inline int pa_atomic_add(pa_atomic_t *a, int i) {
unsigned long not_exclusive;
int new_val, old_val;
pa_memory_barrier();
do {
asm volatile ("ldrex %0, [%3]\n"
"add %2, %0, %4\n"
"strex %1, %2, [%3]\n"
: "=&r" (old_val), "=&r" (not_exclusive), "=&r" (new_val)
: "r" (&a->value), "Ir" (i)
: "cc");
} while(not_exclusive);
pa_memory_barrier();
return old_val;
}
/* Returns the previously set value */
static inline int pa_atomic_sub(pa_atomic_t *a, int i) {
unsigned long not_exclusive;
int new_val, old_val;
pa_memory_barrier();
do {
asm volatile ("ldrex %0, [%3]\n"
"sub %2, %0, %4\n"
"strex %1, %2, [%3]\n"
: "=&r" (old_val), "=&r" (not_exclusive), "=&r" (new_val)
: "r" (&a->value), "Ir" (i)
: "cc");
} while(not_exclusive);
pa_memory_barrier();
return old_val;
}
static inline int pa_atomic_inc(pa_atomic_t *a) {
return pa_atomic_add(a, 1);
}
static inline int pa_atomic_dec(pa_atomic_t *a) {
return pa_atomic_sub(a, 1);
}
static inline int pa_atomic_cmpxchg(pa_atomic_t *a, int old_i, int new_i) {
unsigned long not_equal, not_exclusive;
pa_memory_barrier();
do {
asm volatile ("ldrex %0, [%2]\n"
"subs %0, %0, %3\n"
"mov %1, %0\n"
"strexeq %0, %4, [%2]\n"
: "=&r" (not_exclusive), "=&r" (not_equal)
: "r" (&a->value), "Ir" (old_i), "r" (new_i)
: "cc");
} while(not_exclusive && !not_equal);
pa_memory_barrier();
return !not_equal;
}
typedef struct pa_atomic_ptr {
volatile unsigned long value;
} pa_atomic_ptr_t;
#define PA_ATOMIC_PTR_INIT(v) { .value = (long) (v) }
static inline void* pa_atomic_ptr_load(const pa_atomic_ptr_t *a) {
pa_memory_barrier();
return (void*) a->value;
}
static inline void pa_atomic_ptr_store(pa_atomic_ptr_t *a, void *p) {
a->value = (unsigned long) p;
pa_memory_barrier();
}
static inline int pa_atomic_ptr_cmpxchg(pa_atomic_ptr_t *a, void *old_p, void* new_p) {
unsigned long not_equal, not_exclusive;
pa_memory_barrier();
do {
asm volatile ("ldrex %0, [%2]\n"
"subs %0, %0, %3\n"
"mov %1, %0\n"
"strexeq %0, %4, [%2]\n"
: "=&r" (not_exclusive), "=&r" (not_equal)
: "r" (&a->value), "Ir" (old_p), "r" (new_p)
: "cc");
} while(not_exclusive && !not_equal);
pa_memory_barrier();
return !not_equal;
}
#elif defined(ATOMIC_ARM_LINUX_HELPERS)
/* See file arch/arm/kernel/entry-armv.S in your kernel sources for more
information about these functions. The arm kernel helper functions first
appeared in 2.6.16.
Apply --disable-atomic-arm-linux-helpers flag to confugure if you prefere
inline asm implementation or you have an obsolete Linux kernel.
*/
/* Memory barrier */
typedef void (__kernel_dmb_t)(void);
#define __kernel_dmb (*(__kernel_dmb_t *)0xffff0fa0)
static inline void pa_memory_barrier(void) {
#ifndef ATOMIC_ARM_MEMORY_BARRIER_ENABLED
__kernel_dmb();
#endif
}
/* Atomic exchange (__kernel_cmpxchg_t contains memory barriers if needed) */
typedef int (__kernel_cmpxchg_t)(int oldval, int newval, volatile int *ptr);
#define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0)
/* This is just to get rid of all warnings */
typedef int (__kernel_cmpxchg_u_t)(unsigned long oldval, unsigned long newval, volatile unsigned long *ptr);
#define __kernel_cmpxchg_u (*(__kernel_cmpxchg_u_t *)0xffff0fc0)
typedef struct pa_atomic {
volatile int value;
} pa_atomic_t;
#define PA_ATOMIC_INIT(v) { .value = (v) }
static inline int pa_atomic_load(const pa_atomic_t *a) {
pa_memory_barrier();
return a->value;
}
static inline void pa_atomic_store(pa_atomic_t *a, int i) {
a->value = i;
pa_memory_barrier();
}
/* Returns the previously set value */
static inline int pa_atomic_add(pa_atomic_t *a, int i) {
int old_val;
do {
old_val = a->value;
} while(__kernel_cmpxchg(old_val, old_val + i, &a->value));
return old_val;
}
/* Returns the previously set value */
static inline int pa_atomic_sub(pa_atomic_t *a, int i) {
int old_val;
do {
old_val = a->value;
} while(__kernel_cmpxchg(old_val, old_val - i, &a->value));
return old_val;
}
/* Returns the previously set value */
static inline int pa_atomic_inc(pa_atomic_t *a) {
return pa_atomic_add(a, 1);
}
/* Returns the previously set value */
static inline int pa_atomic_dec(pa_atomic_t *a) {
return pa_atomic_sub(a, 1);
}
/* Returns non-zero when the operation was successful. */
static inline int pa_atomic_cmpxchg(pa_atomic_t *a, int old_i, int new_i) {
int failed = 1;
do {
failed = __kernel_cmpxchg(old_i, new_i, &a->value);
} while(failed && a->value == old_i);
return !failed;
}
typedef struct pa_atomic_ptr {
volatile unsigned long value;
} pa_atomic_ptr_t;
#define PA_ATOMIC_PTR_INIT(v) { .value = (unsigned long) (v) }
static inline void* pa_atomic_ptr_load(const pa_atomic_ptr_t *a) {
pa_memory_barrier();
return (void*) a->value;
}
static inline void pa_atomic_ptr_store(pa_atomic_ptr_t *a, void *p) {
a->value = (unsigned long) p;
pa_memory_barrier();
}
static inline int pa_atomic_ptr_cmpxchg(pa_atomic_ptr_t *a, void *old_p, void* new_p) {
int failed = 1;
do {
failed = __kernel_cmpxchg_u((unsigned long) old_p, (unsigned long) new_p, &a->value);
} while(failed && a->value == old_p);
return !failed;
}
#else
/* libatomic_ops based implementation */

View file

@ -31,6 +31,7 @@
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <ltdl.h>
#include <pulse/xmalloc.h>
@ -1318,8 +1319,35 @@ int pa_cli_command_execute_line_stateful(pa_core *c, const char *s, pa_strbuf *b
} else {
const char *filename = cs+l+strspn(cs+l, whitespace);
*ifstate = access(filename, F_OK) == 0 ? IFSTATE_TRUE : IFSTATE_FALSE;
pa_log_debug("Checking for existance of '%s': %s", filename, *ifstate == IFSTATE_TRUE ? "success" : "failure");
/* Search DL_SEARCH_PATH unless the filename is absolute */
if (filename[0] == PA_PATH_SEP_CHAR) {
*ifstate = access(filename, F_OK) == 0 ? IFSTATE_TRUE : IFSTATE_FALSE;
pa_log_debug("Checking for existance of '%s': %s", filename, *ifstate == IFSTATE_TRUE ? "success" : "failure");
} else {
const char *paths, *state = NULL;
char *p;
if (!(paths = lt_dlgetsearchpath()))
return -1;
while ((p = pa_split(paths, ":", &state))) {
char *pathname;
pathname = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", p, filename);
pa_xfree(p);
*ifstate = access(pathname, F_OK) == 0 ? IFSTATE_TRUE : IFSTATE_FALSE;
pa_log_debug("Checking for existance of '%s': %s", pathname, *ifstate == IFSTATE_TRUE ? "success" : "failure");
pa_xfree(pathname);
if (*ifstate == IFSTATE_TRUE)
break;
}
}
}
} else {
pa_strbuf_printf(buf, "Invalid meta command: %s\n", cs);

View file

@ -71,7 +71,7 @@ pa_hashmap *pa_hashmap_new(pa_hash_func_t hash_func, pa_compare_func_t compare_f
return h;
}
static void remove(pa_hashmap *h, struct hashmap_entry *e) {
static void remove_entry(pa_hashmap *h, struct hashmap_entry *e) {
pa_assert(h);
pa_assert(e);
@ -103,7 +103,7 @@ void pa_hashmap_free(pa_hashmap*h, void (*free_func)(void *p, void *userdata), v
while (h->first_entry) {
if (free_func)
free_func(h->first_entry->value, userdata);
remove(h, h->first_entry);
remove_entry(h, h->first_entry);
}
pa_xfree(h->data);
@ -182,7 +182,7 @@ void* pa_hashmap_remove(pa_hashmap *h, const void *key) {
return NULL;
data = e->value;
remove(h, e);
remove_entry(h, e);
return data;
}
@ -220,7 +220,7 @@ void* pa_hashmap_steal_first(pa_hashmap *h) {
return NULL;
data = h->first_entry->value;
remove(h, h->first_entry);
remove_entry(h, h->first_entry);
return data;
}

View file

@ -29,6 +29,8 @@
#include <assert.h>
#include <limits.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <pulsecore/log.h>
#include <pulsecore/gccmacro.h>
@ -137,35 +139,47 @@ typedef int pa_bool_t;
#define PA_PRETTY_FUNCTION ""
#endif
#define pa_return_if_fail(expr) \
do { \
if (!(expr)) { \
pa_log_debug("%s: Assertion <%s> failed.\n", PA_PRETTY_FUNCTION, #expr ); \
return; \
} \
} while(0)
#define pa_return_if_fail(expr) \
do { \
if (PA_UNLIKELY(!(expr))) { \
pa_log_debug("Assertion '%s' failed at %s:%u, function %s.\n", #expr , __FILE__, __LINE__, PA_PRETTY_FUNCTION); \
return; \
} \
} while(FALSE)
#define pa_return_val_if_fail(expr, val) \
do { \
if (!(expr)) { \
pa_log_debug("%s: Assertion <%s> failed.\n", PA_PRETTY_FUNCTION, #expr ); \
return (val); \
} \
} while(0)
#define pa_return_val_if_fail(expr, val) \
do { \
if (PA_UNLIKELY(!(expr))) { \
pa_log_debug("Assertion '%s' failed at %s:%u, function %s.\n", #expr , __FILE__, __LINE__, PA_PRETTY_FUNCTION); \
return (val); \
} \
} while(FALSE)
#define pa_return_null_if_fail(expr) pa_return_val_if_fail(expr, NULL)
#define pa_assert assert
/* An assert which guarantees side effects of x, i.e. is never
* optimized away */
#define pa_assert_se(expr) \
do { \
if (PA_UNLIKELY(!(expr))) { \
pa_log_error("Assertion '%s' failed at %s:%u, function %s(). Aborting.", #expr , __FILE__, __LINE__, PA_PRETTY_FUNCTION); \
abort(); \
} \
} while (FALSE)
#define pa_assert_not_reached() pa_assert(!"Should not be reached.")
/* An assert which guarantees side effects of x */
/* An assert that may be optimized away by defining NDEBUG */
#ifdef NDEBUG
#define pa_assert_se(x) x
#define pa_assert(expr) do {} while (FALSE)
#else
#define pa_assert_se(x) pa_assert(x)
#define pa_assert(expr) pa_assert_se(expr)
#endif
#define pa_assert_not_reached() \
do { \
pa_log_error("Code should not be reached at %s:%u, function %s(). Aborting.", __FILE__, __LINE__, PA_PRETTY_FUNCTION); \
abort(); \
} while (FALSE)
#define PA_PTR_TO_UINT(p) ((unsigned int) (unsigned long) (p))
#define PA_UINT_TO_PTR(u) ((void*) (unsigned long) (u))

View file

@ -72,7 +72,7 @@
#define RECORD_BUFFER_SECONDS (5)
#define RECORD_BUFFER_FRAGMENTS (100)
#define MAX_CACHE_SAMPLE_SIZE (1024000)
#define MAX_CACHE_SAMPLE_SIZE (2048000)
#define SCACHE_PREFIX "esound."

View file

@ -1193,6 +1193,7 @@ static void source_output_moved_cb(pa_source_output *o) {
pa_tagstruct_putu32(t, s->index);
pa_tagstruct_putu32(t, o->source->index);
pa_tagstruct_puts(t, o->source->name);
pa_tagstruct_put_boolean(t, pa_source_get_state(o->source) == PA_SOURCE_SUSPENDED);
pa_pstream_send_tagstruct(s->connection->pstream, t);
}

View file

@ -71,7 +71,7 @@ int main(int argc, char*argv[]) {
u += 2;
}
printf("%llu\t%llu\n", x/PA_USEC_PER_MSEC, pa_smoother_get(s, x)/PA_USEC_PER_MSEC);
printf("%llu\t%llu\n", (unsigned long long) (x/PA_USEC_PER_MSEC), (unsigned long long) (pa_smoother_get(s, x)/PA_USEC_PER_MSEC));
}
pa_smoother_free(s);

View file

@ -486,7 +486,7 @@ static void get_autoload_info_callback(pa_context *c, const pa_autoload_info *i,
i->name,
i->type == PA_AUTOLOAD_SINK ? "sink" : "source",
i->module,
i->argument);
i->argument ? i->argument : "");
}
static void simple_callback(pa_context *c, int success, void *userdata) {

View file

@ -2307,7 +2307,11 @@ fail:
return ret;
}
#ifdef sun
int ioctl(int fd, int request, ...) {
#else
int ioctl(int fd, unsigned long request, ...) {
#endif
fd_info *i;
va_list args;
void *argp;