mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
Merge remote-tracking branch 'mkbosmans/mingw32-build'
This commit is contained in:
commit
a3dbdb0446
67 changed files with 719 additions and 449 deletions
56
configure.ac
56
configure.ac
|
|
@ -362,10 +362,7 @@ AC_CHECK_HEADERS([netinet/ip.h], [], [],
|
||||||
# include <netinet/in_systm.h>
|
# include <netinet/in_systm.h>
|
||||||
#endif
|
#endif
|
||||||
])
|
])
|
||||||
AC_CHECK_HEADERS([regex.h], [HAVE_REGEX=1], [HAVE_REGEX=0])
|
|
||||||
AC_CHECK_HEADERS([sys/un.h], [HAVE_AF_UNIX=1], [HAVE_AF_UNIX=0])
|
AC_CHECK_HEADERS([sys/un.h], [HAVE_AF_UNIX=1], [HAVE_AF_UNIX=0])
|
||||||
|
|
||||||
AM_CONDITIONAL(HAVE_REGEX, test "x$HAVE_REGEX" = "x1")
|
|
||||||
AM_CONDITIONAL(HAVE_AF_UNIX, test "x$HAVE_AF_UNIX" = "x1")
|
AM_CONDITIONAL(HAVE_AF_UNIX, test "x$HAVE_AF_UNIX" = "x1")
|
||||||
|
|
||||||
# Linux
|
# Linux
|
||||||
|
|
@ -390,6 +387,8 @@ AC_CHECK_HEADERS_ONCE([byteswap.h])
|
||||||
AC_CHECK_HEADERS_ONCE([sys/syscall.h])
|
AC_CHECK_HEADERS_ONCE([sys/syscall.h])
|
||||||
AC_CHECK_HEADERS_ONCE([sys/eventfd.h])
|
AC_CHECK_HEADERS_ONCE([sys/eventfd.h])
|
||||||
AC_CHECK_HEADERS_ONCE([execinfo.h])
|
AC_CHECK_HEADERS_ONCE([execinfo.h])
|
||||||
|
AC_CHECK_HEADERS_ONCE([langinfo.h])
|
||||||
|
AC_CHECK_HEADERS_ONCE([regex.h pcreposix.h])
|
||||||
|
|
||||||
#### Typdefs, structures, etc. ####
|
#### Typdefs, structures, etc. ####
|
||||||
|
|
||||||
|
|
@ -458,6 +457,8 @@ fi
|
||||||
AC_SUBST(HAVE_BONJOUR)
|
AC_SUBST(HAVE_BONJOUR)
|
||||||
AM_CONDITIONAL([HAVE_BONJOUR], [test "x$HAVE_BONJOUR" = x1])
|
AM_CONDITIONAL([HAVE_BONJOUR], [test "x$HAVE_BONJOUR" = x1])
|
||||||
|
|
||||||
|
AC_SEARCH_LIBS([regexec], [pcreposix])
|
||||||
|
|
||||||
#### Check for functions ####
|
#### Check for functions ####
|
||||||
|
|
||||||
# ISO
|
# ISO
|
||||||
|
|
@ -470,7 +471,7 @@ AC_FUNC_SELECT_ARGTYPES
|
||||||
AC_CHECK_FUNCS_ONCE([chmod chown fstat fchown fchmod clock_gettime getaddrinfo getgrgid_r getgrnam_r \
|
AC_CHECK_FUNCS_ONCE([chmod chown fstat fchown fchmod clock_gettime getaddrinfo getgrgid_r getgrnam_r \
|
||||||
getpwnam_r getpwuid_r gettimeofday getuid inet_ntop inet_pton mlock nanosleep \
|
getpwnam_r getpwuid_r gettimeofday getuid inet_ntop inet_pton mlock nanosleep \
|
||||||
pipe posix_fadvise posix_madvise posix_memalign setpgid setsid shm_open \
|
pipe posix_fadvise posix_madvise posix_memalign setpgid setsid shm_open \
|
||||||
sigaction sleep sysconf pthread_setaffinity_np])
|
sigaction sleep symlink sysconf uname pthread_setaffinity_np])
|
||||||
AC_CHECK_FUNCS([mkfifo], [HAVE_MKFIFO=1], [HAVE_MKFIFO=0])
|
AC_CHECK_FUNCS([mkfifo], [HAVE_MKFIFO=1], [HAVE_MKFIFO=0])
|
||||||
|
|
||||||
AM_CONDITIONAL(HAVE_MKFIFO, test "x$HAVE_MKFIFO" = "x1")
|
AM_CONDITIONAL(HAVE_MKFIFO, test "x$HAVE_MKFIFO" = "x1")
|
||||||
|
|
@ -517,6 +518,9 @@ AS_IF([test "$pulseaudio_cv_PTHREAD_PRIO_INHERIT" = "yes"], [
|
||||||
|
|
||||||
AC_DEFINE_UNQUOTED(PA_CFLAGS,"$CFLAGS", [The CFLAGS used during compilation])
|
AC_DEFINE_UNQUOTED(PA_CFLAGS,"$CFLAGS", [The CFLAGS used during compilation])
|
||||||
|
|
||||||
|
AC_CHECK_FUNCS([regexec], [HAVE_REGEX=1], [HAVE_REGEX=0])
|
||||||
|
AM_CONDITIONAL(HAVE_REGEX, [test "x$HAVE_REGEX" = "x1"])
|
||||||
|
|
||||||
#### Large File-Support (LFS) ####
|
#### Large File-Support (LFS) ####
|
||||||
|
|
||||||
AC_SYS_LARGEFILE
|
AC_SYS_LARGEFILE
|
||||||
|
|
@ -874,6 +878,39 @@ fi
|
||||||
AC_SUBST(HAVE_SOLARIS)
|
AC_SUBST(HAVE_SOLARIS)
|
||||||
AM_CONDITIONAL([HAVE_SOLARIS], [test "x$HAVE_SOLARIS" = x1])
|
AM_CONDITIONAL([HAVE_SOLARIS], [test "x$HAVE_SOLARIS" = x1])
|
||||||
|
|
||||||
|
#### WaveOut audio support (optional) ####
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([waveout],
|
||||||
|
AS_HELP_STRING([--disable-waveout],[Disable optional WaveOut audio support]),
|
||||||
|
[
|
||||||
|
case "${enableval}" in
|
||||||
|
yes) waveout=yes ;;
|
||||||
|
no) waveout=no ;;
|
||||||
|
*) AC_MSG_ERROR(bad value ${enableval} for --disable-waveout) ;;
|
||||||
|
esac
|
||||||
|
],
|
||||||
|
[waveout=auto])
|
||||||
|
|
||||||
|
if test "x${waveout}" != xno ; then
|
||||||
|
AC_CHECK_HEADERS([mmsystem.h],
|
||||||
|
[
|
||||||
|
HAVE_WAVEOUT=1
|
||||||
|
AC_DEFINE([HAVE_WAVEOUT], 1, [Have WaveOut audio?])
|
||||||
|
],
|
||||||
|
[
|
||||||
|
HAVE_WAVEOUT=0
|
||||||
|
if test "x$waveout" = xyes ; then
|
||||||
|
AC_MSG_ERROR([*** WaveOut audio support not found])
|
||||||
|
fi
|
||||||
|
],
|
||||||
|
[#include <windows.h>])
|
||||||
|
else
|
||||||
|
HAVE_WAVEOUT=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_SUBST(HAVE_WAVEOUT)
|
||||||
|
AM_CONDITIONAL([HAVE_WAVEOUT], [test "x$HAVE_WAVEOUT" = x1])
|
||||||
|
|
||||||
#### GLib 2 support (optional) ####
|
#### GLib 2 support (optional) ####
|
||||||
|
|
||||||
AC_ARG_ENABLE([glib2],
|
AC_ARG_ENABLE([glib2],
|
||||||
|
|
@ -1525,6 +1562,11 @@ if test "x$HAVE_SOLARIS" = "x1" ; then
|
||||||
ENABLE_SOLARIS=yes
|
ENABLE_SOLARIS=yes
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ENABLE_WAVEOUT=no
|
||||||
|
if test "x$HAVE_WAVEOUT" = "x1" ; then
|
||||||
|
ENABLE_WAVEOUT=yes
|
||||||
|
fi
|
||||||
|
|
||||||
ENABLE_GTK20=no
|
ENABLE_GTK20=no
|
||||||
if test "x$HAVE_GTK20" = "x1" ; then
|
if test "x$HAVE_GTK20" = "x1" ; then
|
||||||
ENABLE_GTK20=yes
|
ENABLE_GTK20=yes
|
||||||
|
|
@ -1646,6 +1688,7 @@ echo "
|
||||||
System Config Path: ${PA_SYSTEM_CONFIG_PATH}
|
System Config Path: ${PA_SYSTEM_CONFIG_PATH}
|
||||||
Compiler: ${CC}
|
Compiler: ${CC}
|
||||||
CFLAGS: ${CFLAGS}
|
CFLAGS: ${CFLAGS}
|
||||||
|
LIBS: ${LIBS}
|
||||||
|
|
||||||
Have X11: ${ENABLE_X11}
|
Have X11: ${ENABLE_X11}
|
||||||
Enable OSS Output: ${ENABLE_OSS_OUTPUT}
|
Enable OSS Output: ${ENABLE_OSS_OUTPUT}
|
||||||
|
|
@ -1653,6 +1696,7 @@ echo "
|
||||||
Enable CoreAudio: ${ENABLE_COREAUDIO}
|
Enable CoreAudio: ${ENABLE_COREAUDIO}
|
||||||
Enable Alsa: ${ENABLE_ALSA}
|
Enable Alsa: ${ENABLE_ALSA}
|
||||||
Enable Solaris: ${ENABLE_SOLARIS}
|
Enable Solaris: ${ENABLE_SOLARIS}
|
||||||
|
Enable WaveOut: ${ENABLE_WAVEOUT}
|
||||||
Enable GLib 2.0: ${ENABLE_GLIB20}
|
Enable GLib 2.0: ${ENABLE_GLIB20}
|
||||||
Enable Gtk+ 2.0: ${ENABLE_GTK20}
|
Enable Gtk+ 2.0: ${ENABLE_GTK20}
|
||||||
Enable GConf: ${ENABLE_GCONF}
|
Enable GConf: ${ENABLE_GCONF}
|
||||||
|
|
@ -1683,7 +1727,7 @@ echo "
|
||||||
Preopened modules: ${PREOPEN_MODS}
|
Preopened modules: ${PREOPEN_MODS}
|
||||||
"
|
"
|
||||||
|
|
||||||
if test "${ENABLE_DBUS}" = "no" ; then
|
if test "${ENABLE_DBUS}" = "no" && test "x$os_is_win32" != "x1" ; then
|
||||||
echo "
|
echo "
|
||||||
===== WARNING WARNING WARNING WARNING WARNING WARNING WARNING =====
|
===== WARNING WARNING WARNING WARNING WARNING WARNING WARNING =====
|
||||||
You do not have D-Bus support enabled. It is strongly recommended
|
You do not have D-Bus support enabled. It is strongly recommended
|
||||||
|
|
@ -1696,7 +1740,7 @@ controling the PulseAudio daemon itself.
|
||||||
"
|
"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "${ENABLE_UDEV}" = "no" ; then
|
if test "${ENABLE_UDEV}" = "no" && test "x$os_is_win32" != "x1" ; then
|
||||||
echo "
|
echo "
|
||||||
===== WARNING WARNING WARNING WARNING WARNING WARNING WARNING =====
|
===== WARNING WARNING WARNING WARNING WARNING WARNING WARNING =====
|
||||||
You do not have udev support enabled. It is strongly recommended
|
You do not have udev support enabled. It is strongly recommended
|
||||||
|
|
|
||||||
|
|
@ -74,12 +74,12 @@ BINLDFLAGS = -static
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if OS_IS_WIN32
|
if OS_IS_WIN32
|
||||||
AM_LDFLAGS+=-Wl,--export-all-symbols
|
AM_LDFLAGS+=-Wl,--export-all-symbols,--enable-auto-import -no-undefined
|
||||||
WINSOCK_LIBS=-lwsock32 -lws2_32 -lwininet
|
WINSOCK_LIBS=-lwsock32 -lws2_32 -lwininet
|
||||||
endif
|
endif
|
||||||
|
|
||||||
FOREIGN_CFLAGS = -w
|
FOREIGN_CFLAGS = -w
|
||||||
MODULE_LDFLAGS = -module -disable-static -avoid-version $(LDFLAGS_NOUNDEFINED)
|
MODULE_LDFLAGS = $(AM_LDFLAGS) -module -disable-static -avoid-version $(LDFLAGS_NOUNDEFINED)
|
||||||
MODULE_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
MODULE_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
|
|
@ -112,8 +112,10 @@ pulseconf_DATA = \
|
||||||
daemon.conf \
|
daemon.conf \
|
||||||
client.conf
|
client.conf
|
||||||
|
|
||||||
|
if HAVE_DBUS
|
||||||
dbuspolicy_DATA = \
|
dbuspolicy_DATA = \
|
||||||
daemon/pulseaudio-system.conf
|
daemon/pulseaudio-system.conf
|
||||||
|
endif
|
||||||
|
|
||||||
if HAVE_X11
|
if HAVE_X11
|
||||||
xdgautostart_in_files = \
|
xdgautostart_in_files = \
|
||||||
|
|
@ -175,10 +177,15 @@ endif
|
||||||
# Utility programs #
|
# Utility programs #
|
||||||
###################################
|
###################################
|
||||||
|
|
||||||
|
bin_SCRIPTS = esdcompat
|
||||||
|
|
||||||
bin_PROGRAMS += \
|
bin_PROGRAMS += \
|
||||||
pacat \
|
pacat \
|
||||||
pactl \
|
pactl
|
||||||
pasuspender
|
|
||||||
|
if !OS_IS_WIN32
|
||||||
|
bin_PROGRAMS += pasuspender
|
||||||
|
endif
|
||||||
|
|
||||||
if HAVE_AF_UNIX
|
if HAVE_AF_UNIX
|
||||||
bin_PROGRAMS += pacmd
|
bin_PROGRAMS += pacmd
|
||||||
|
|
@ -186,14 +193,13 @@ endif
|
||||||
|
|
||||||
if HAVE_X11
|
if HAVE_X11
|
||||||
bin_PROGRAMS += pax11publish
|
bin_PROGRAMS += pax11publish
|
||||||
|
bin_SCRIPTS += start-pulseaudio-x11 start-pulseaudio-kde
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if HAVE_AVAHI
|
if HAVE_AVAHI
|
||||||
bin_PROGRAMS += pabrowse
|
bin_PROGRAMS += pabrowse
|
||||||
endif
|
endif
|
||||||
|
|
||||||
bin_SCRIPTS = esdcompat start-pulseaudio-x11 start-pulseaudio-kde
|
|
||||||
|
|
||||||
pacat_SOURCES = utils/pacat.c
|
pacat_SOURCES = utils/pacat.c
|
||||||
pacat_LDADD = $(AM_LDADD) libpulse.la libpulsecommon-@PA_MAJORMINOR@.la $(LIBSNDFILE_LIBS)
|
pacat_LDADD = $(AM_LDADD) libpulse.la libpulsecommon-@PA_MAJORMINOR@.la $(LIBSNDFILE_LIBS)
|
||||||
pacat_CFLAGS = $(AM_CFLAGS) $(LIBSNDFILE_CFLAGS)
|
pacat_CFLAGS = $(AM_CFLAGS) $(LIBSNDFILE_CFLAGS)
|
||||||
|
|
@ -256,9 +262,7 @@ TESTS = \
|
||||||
envelope-test \
|
envelope-test \
|
||||||
proplist-test \
|
proplist-test \
|
||||||
lock-autospawn-test \
|
lock-autospawn-test \
|
||||||
prioq-test \
|
prioq-test
|
||||||
sigbus-test \
|
|
||||||
usergroup-test
|
|
||||||
|
|
||||||
TESTS_BINARIES = \
|
TESTS_BINARIES = \
|
||||||
mainloop-test \
|
mainloop-test \
|
||||||
|
|
@ -295,9 +299,16 @@ TESTS_BINARIES = \
|
||||||
rtstutter \
|
rtstutter \
|
||||||
stripnul \
|
stripnul \
|
||||||
lock-autospawn-test \
|
lock-autospawn-test \
|
||||||
prioq-test \
|
prioq-test
|
||||||
|
|
||||||
|
if !OS_IS_WIN32
|
||||||
|
TESTS += \
|
||||||
sigbus-test \
|
sigbus-test \
|
||||||
usergroup-test
|
usergroup-test
|
||||||
|
TESTS_BINARIES += \
|
||||||
|
sigbus-test \
|
||||||
|
usergroup-test
|
||||||
|
endif
|
||||||
|
|
||||||
if HAVE_SIGXCPU
|
if HAVE_SIGXCPU
|
||||||
#TESTS += \
|
#TESTS += \
|
||||||
|
|
@ -326,9 +337,11 @@ TESTS_BINARIES += \
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !OS_IS_DARWIN
|
if !OS_IS_DARWIN
|
||||||
|
if !OS_IS_WIN32
|
||||||
TESTS_BINARIES += \
|
TESTS_BINARIES += \
|
||||||
once-test
|
once-test
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
if BUILD_TESTS_DEFAULT
|
if BUILD_TESTS_DEFAULT
|
||||||
noinst_PROGRAMS = $(TESTS_BINARIES)
|
noinst_PROGRAMS = $(TESTS_BINARIES)
|
||||||
|
|
@ -562,6 +575,14 @@ libpulsecommon_@PA_MAJORMINOR@_la_SOURCES = \
|
||||||
pulse/client-conf.c pulse/client-conf.h \
|
pulse/client-conf.c pulse/client-conf.h \
|
||||||
pulse/i18n.c pulse/i18n.h \
|
pulse/i18n.c pulse/i18n.h \
|
||||||
pulse/fork-detect.c pulse/fork-detect.h \
|
pulse/fork-detect.c pulse/fork-detect.h \
|
||||||
|
pulse/xmalloc.c pulse/xmalloc.h \
|
||||||
|
pulse/proplist.c pulse/proplist.h \
|
||||||
|
pulse/utf8.c pulse/utf8.h \
|
||||||
|
pulse/channelmap.c pulse/channelmap.h \
|
||||||
|
pulse/sample.c pulse/sample.h \
|
||||||
|
pulse/util.c pulse/util.h \
|
||||||
|
pulse/timeval.c pulse/timeval.h \
|
||||||
|
pulse/rtclock.c pulse/rtclock.h \
|
||||||
pulsecore/atomic.h \
|
pulsecore/atomic.h \
|
||||||
pulsecore/authkey.c pulsecore/authkey.h \
|
pulsecore/authkey.c pulsecore/authkey.h \
|
||||||
pulsecore/conf-parser.c pulsecore/conf-parser.h \
|
pulsecore/conf-parser.c pulsecore/conf-parser.h \
|
||||||
|
|
@ -617,7 +638,7 @@ libpulsecommon_@PA_MAJORMINOR@_la_SOURCES = \
|
||||||
pulsecore/tokenizer.c pulsecore/tokenizer.h \
|
pulsecore/tokenizer.c pulsecore/tokenizer.h \
|
||||||
pulsecore/usergroup.c pulsecore/usergroup.h \
|
pulsecore/usergroup.c pulsecore/usergroup.h \
|
||||||
pulsecore/sndfile-util.c pulsecore/sndfile-util.h \
|
pulsecore/sndfile-util.c pulsecore/sndfile-util.h \
|
||||||
pulsecore/winsock.h
|
pulsecore/socket.h
|
||||||
|
|
||||||
libpulsecommon_@PA_MAJORMINOR@_la_CFLAGS = $(AM_CFLAGS) $(LIBSAMPLERATE_CFLAGS) $(LIBSNDFILE_CFLAGS)
|
libpulsecommon_@PA_MAJORMINOR@_la_CFLAGS = $(AM_CFLAGS) $(LIBSAMPLERATE_CFLAGS) $(LIBSNDFILE_CFLAGS)
|
||||||
libpulsecommon_@PA_MAJORMINOR@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
|
libpulsecommon_@PA_MAJORMINOR@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
|
||||||
|
|
@ -858,7 +879,7 @@ libpulsecore_@PA_MAJORMINOR@_la_SOURCES = \
|
||||||
pulsecore/database.h
|
pulsecore/database.h
|
||||||
|
|
||||||
libpulsecore_@PA_MAJORMINOR@_la_CFLAGS = $(AM_CFLAGS) $(LIBSAMPLERATE_CFLAGS) $(LIBSPEEX_CFLAGS) $(LIBSNDFILE_CFLAGS) $(WINSOCK_CFLAGS)
|
libpulsecore_@PA_MAJORMINOR@_la_CFLAGS = $(AM_CFLAGS) $(LIBSAMPLERATE_CFLAGS) $(LIBSPEEX_CFLAGS) $(LIBSNDFILE_CFLAGS) $(WINSOCK_CFLAGS)
|
||||||
libpulsecore_@PA_MAJORMINOR@_la_LDFLAGS = -avoid-version
|
libpulsecore_@PA_MAJORMINOR@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
|
||||||
libpulsecore_@PA_MAJORMINOR@_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) $(LIBSAMPLERATE_LIBS) $(LIBSPEEX_LIBS) $(LIBSNDFILE_LIBS) $(WINSOCK_LIBS) $(LTLIBICONV) libpulsecommon-@PA_MAJORMINOR@.la libpulse.la libpulsecore-foreign.la
|
libpulsecore_@PA_MAJORMINOR@_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) $(LIBSAMPLERATE_LIBS) $(LIBSPEEX_LIBS) $(LIBSNDFILE_LIBS) $(WINSOCK_LIBS) $(LTLIBICONV) libpulsecommon-@PA_MAJORMINOR@.la libpulse.la libpulsecore-foreign.la
|
||||||
|
|
||||||
if HAVE_X11
|
if HAVE_X11
|
||||||
|
|
@ -928,27 +949,27 @@ modlibexec_LTLIBRARIES += \
|
||||||
endif
|
endif
|
||||||
|
|
||||||
libprotocol_simple_la_SOURCES = pulsecore/protocol-simple.c pulsecore/protocol-simple.h
|
libprotocol_simple_la_SOURCES = pulsecore/protocol-simple.c pulsecore/protocol-simple.h
|
||||||
libprotocol_simple_la_LDFLAGS = -avoid-version
|
libprotocol_simple_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
|
||||||
libprotocol_simple_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
libprotocol_simple_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
||||||
|
|
||||||
libcli_la_SOURCES = pulsecore/cli.c pulsecore/cli.h
|
libcli_la_SOURCES = pulsecore/cli.c pulsecore/cli.h
|
||||||
libcli_la_LDFLAGS = -avoid-version
|
libcli_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
|
||||||
libcli_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
libcli_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
||||||
|
|
||||||
libprotocol_cli_la_SOURCES = pulsecore/protocol-cli.c pulsecore/protocol-cli.h
|
libprotocol_cli_la_SOURCES = pulsecore/protocol-cli.c pulsecore/protocol-cli.h
|
||||||
libprotocol_cli_la_LDFLAGS = -avoid-version
|
libprotocol_cli_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
|
||||||
libprotocol_cli_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la libcli.la
|
libprotocol_cli_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la libcli.la
|
||||||
|
|
||||||
libprotocol_http_la_SOURCES = pulsecore/protocol-http.c pulsecore/protocol-http.h pulsecore/mime-type.c pulsecore/mime-type.h
|
libprotocol_http_la_SOURCES = pulsecore/protocol-http.c pulsecore/protocol-http.h pulsecore/mime-type.c pulsecore/mime-type.h
|
||||||
libprotocol_http_la_LDFLAGS = -avoid-version
|
libprotocol_http_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
|
||||||
libprotocol_http_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
libprotocol_http_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
||||||
|
|
||||||
libprotocol_native_la_SOURCES = pulsecore/protocol-native.c pulsecore/protocol-native.h pulsecore/native-common.h
|
libprotocol_native_la_SOURCES = pulsecore/protocol-native.c pulsecore/protocol-native.h pulsecore/native-common.h
|
||||||
libprotocol_native_la_LDFLAGS = -avoid-version
|
libprotocol_native_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
|
||||||
libprotocol_native_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
libprotocol_native_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
||||||
|
|
||||||
libprotocol_esound_la_SOURCES = pulsecore/protocol-esound.c pulsecore/protocol-esound.h pulsecore/esound.h
|
libprotocol_esound_la_SOURCES = pulsecore/protocol-esound.c pulsecore/protocol-esound.h pulsecore/esound.h
|
||||||
libprotocol_esound_la_LDFLAGS = -avoid-version
|
libprotocol_esound_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
|
||||||
libprotocol_esound_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
libprotocol_esound_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
||||||
|
|
||||||
librtp_la_SOURCES = \
|
librtp_la_SOURCES = \
|
||||||
|
|
@ -957,19 +978,19 @@ librtp_la_SOURCES = \
|
||||||
modules/rtp/sap.c modules/rtp/sap.h \
|
modules/rtp/sap.c modules/rtp/sap.h \
|
||||||
modules/rtp/rtsp_client.c modules/rtp/rtsp_client.h \
|
modules/rtp/rtsp_client.c modules/rtp/rtsp_client.h \
|
||||||
modules/rtp/headerlist.c modules/rtp/headerlist.h
|
modules/rtp/headerlist.c modules/rtp/headerlist.h
|
||||||
librtp_la_LDFLAGS = -avoid-version
|
librtp_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
|
||||||
librtp_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
librtp_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
||||||
|
|
||||||
libraop_la_SOURCES = \
|
libraop_la_SOURCES = \
|
||||||
modules/raop/raop_client.c modules/raop/raop_client.h \
|
modules/raop/raop_client.c modules/raop/raop_client.h \
|
||||||
modules/raop/base64.c modules/raop/base64.h
|
modules/raop/base64.c modules/raop/base64.h
|
||||||
libraop_la_CFLAGS = $(AM_CFLAGS) $(OPENSSL_CFLAGS) -I$(top_srcdir)/src/modules/rtp
|
libraop_la_CFLAGS = $(AM_CFLAGS) $(OPENSSL_CFLAGS) -I$(top_srcdir)/src/modules/rtp
|
||||||
libraop_la_LDFLAGS = -avoid-version
|
libraop_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
|
||||||
libraop_la_LIBADD = $(AM_LIBADD) $(OPENSSL_LIBS) libpulsecore-@PA_MAJORMINOR@.la librtp.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
libraop_la_LIBADD = $(AM_LIBADD) $(OPENSSL_LIBS) libpulsecore-@PA_MAJORMINOR@.la librtp.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
||||||
|
|
||||||
# Avahi
|
# Avahi
|
||||||
libavahi_wrap_la_SOURCES = pulsecore/avahi-wrap.c pulsecore/avahi-wrap.h
|
libavahi_wrap_la_SOURCES = pulsecore/avahi-wrap.c pulsecore/avahi-wrap.h
|
||||||
libavahi_wrap_la_LDFLAGS = -avoid-version
|
libavahi_wrap_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
|
||||||
libavahi_wrap_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
|
libavahi_wrap_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
|
||||||
libavahi_wrap_la_LIBADD = $(AM_LIBADD) $(AVAHI_CFLAGS) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
libavahi_wrap_la_LIBADD = $(AM_LIBADD) $(AVAHI_CFLAGS) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la
|
||||||
|
|
||||||
|
|
@ -1165,10 +1186,10 @@ pulselibexec_PROGRAMS += \
|
||||||
gconf-helper
|
gconf-helper
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#if OS_IS_WIN32
|
if HAVE_WAVEOUT
|
||||||
#modlibexec_LTLIBRARIES += \
|
modlibexec_LTLIBRARIES += \
|
||||||
# module-waveout.la
|
module-waveout.la
|
||||||
#endif
|
endif
|
||||||
|
|
||||||
if HAVE_HAL
|
if HAVE_HAL
|
||||||
modlibexec_LTLIBRARIES += \
|
modlibexec_LTLIBRARIES += \
|
||||||
|
|
@ -1408,7 +1429,7 @@ module_esound_compat_spawnpid_la_LDFLAGS = $(MODULE_LDFLAGS)
|
||||||
module_esound_compat_spawnpid_la_LIBADD = $(MODULE_LIBADD)
|
module_esound_compat_spawnpid_la_LIBADD = $(MODULE_LIBADD)
|
||||||
|
|
||||||
module_esound_sink_la_SOURCES = modules/module-esound-sink.c
|
module_esound_sink_la_SOURCES = modules/module-esound-sink.c
|
||||||
module_esound_sink_la_LDFLAGS = $(MODULE_LDFLAGS)
|
module_esound_sink_la_LDFLAGS = $(MODULE_LDFLAGS) $(WINSOCK_LIBS)
|
||||||
module_esound_sink_la_LIBADD = $(MODULE_LIBADD)
|
module_esound_sink_la_LIBADD = $(MODULE_LIBADD)
|
||||||
|
|
||||||
# Pipes
|
# Pipes
|
||||||
|
|
@ -1432,7 +1453,7 @@ module_null_sink_la_LDFLAGS = $(MODULE_LDFLAGS)
|
||||||
module_null_sink_la_LIBADD = $(MODULE_LIBADD)
|
module_null_sink_la_LIBADD = $(MODULE_LIBADD)
|
||||||
|
|
||||||
module_sine_source_la_SOURCES = modules/module-sine-source.c
|
module_sine_source_la_SOURCES = modules/module-sine-source.c
|
||||||
module_sine_source_la_LDFLAGS = -module -avoid-version
|
module_sine_source_la_LDFLAGS = $(MODULE_LDFLAGS)
|
||||||
module_sine_source_la_LIBADD = $(MODULE_LIBADD)
|
module_sine_source_la_LIBADD = $(MODULE_LIBADD)
|
||||||
|
|
||||||
# Couplings
|
# Couplings
|
||||||
|
|
@ -1606,11 +1627,10 @@ module_mmkbd_evdev_la_LIBADD = $(MODULE_LIBADD)
|
||||||
module_mmkbd_evdev_la_CFLAGS = $(AM_CFLAGS)
|
module_mmkbd_evdev_la_CFLAGS = $(AM_CFLAGS)
|
||||||
|
|
||||||
# Windows waveout
|
# Windows waveout
|
||||||
|
module_waveout_la_SOURCES = modules/module-waveout.c
|
||||||
#module_waveout_la_SOURCES = modules/module-waveout.c
|
module_waveout_la_LDFLAGS = $(MODULE_LDFLAGS)
|
||||||
#module_waveout_la_LDFLAGS = $(MODULE_LDFLAGS)
|
module_waveout_la_LIBADD = $(MODULE_LIBADD) -lwinmm
|
||||||
#module_waveout_la_LIBADD = $(MODULE_LIBADD) -lwinmm
|
module_waveout_la_CFLAGS = $(AM_CFLAGS)
|
||||||
#module_waveout_la_CFLAGS = $(AM_CFLAGS)
|
|
||||||
|
|
||||||
# Hardware autodetection module
|
# Hardware autodetection module
|
||||||
module_detect_la_SOURCES = modules/module-detect.c
|
module_detect_la_SOURCES = modules/module-detect.c
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ static void signal_handler(int sig) {
|
||||||
write_err("Soft CPU time limit exhausted, terminating.\n");
|
write_err("Soft CPU time limit exhausted, terminating.\n");
|
||||||
|
|
||||||
/* Try a soft cleanup */
|
/* Try a soft cleanup */
|
||||||
(void) write(the_pipe[1], &c, sizeof(c));
|
(void) pa_write(the_pipe[1], &c, sizeof(c), NULL);
|
||||||
phase = PHASE_SOFT;
|
phase = PHASE_SOFT;
|
||||||
reset_cpu_time(CPUTIME_INTERVAL_HARD);
|
reset_cpu_time(CPUTIME_INTERVAL_HARD);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SCHED_H
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
|
|
@ -460,10 +463,12 @@ static int parse_rtprio(const char *filename, unsigned line, const char *section
|
||||||
pa_assert(rvalue);
|
pa_assert(rvalue);
|
||||||
pa_assert(data);
|
pa_assert(data);
|
||||||
|
|
||||||
|
#ifdef HAVE_SCHED_H
|
||||||
if (pa_atoi(rvalue, &rtprio) < 0 || rtprio < sched_get_priority_min(SCHED_FIFO) || rtprio > sched_get_priority_max(SCHED_FIFO)) {
|
if (pa_atoi(rvalue, &rtprio) < 0 || rtprio < sched_get_priority_min(SCHED_FIFO) || rtprio > sched_get_priority_max(SCHED_FIFO)) {
|
||||||
pa_log("[%s:%u] Invalid realtime priority '%s'.", filename, line, rvalue);
|
pa_log("[%s:%u] Invalid realtime priority '%s'.", filename, line, rvalue);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
c->realtime_priority = (int) rtprio;
|
c->realtime_priority = (int) rtprio;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,9 @@ static void show_info(const char *name, const char *path, void (*info)(const cha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef OS_IS_WIN32
|
||||||
extern const lt_dlsymlist lt_preloaded_symbols[];
|
extern const lt_dlsymlist lt_preloaded_symbols[];
|
||||||
|
#endif
|
||||||
|
|
||||||
static int is_preloaded(const char *name) {
|
static int is_preloaded(const char *name) {
|
||||||
const lt_dlsymlist *l;
|
const lt_dlsymlist *l;
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,10 @@
|
||||||
#undef PA_BIND_NOW
|
#undef PA_BIND_NOW
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef OS_IS_WIN32
|
||||||
|
#undef PA_BIND_NOW
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PA_BIND_NOW
|
#ifdef PA_BIND_NOW
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,6 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SYS_IOCTL_H
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_PWD_H
|
#ifdef HAVE_PWD_H
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -74,7 +70,7 @@
|
||||||
#include <pulse/i18n.h>
|
#include <pulse/i18n.h>
|
||||||
|
|
||||||
#include <pulsecore/lock-autospawn.h>
|
#include <pulsecore/lock-autospawn.h>
|
||||||
#include <pulsecore/winsock.h>
|
#include <pulsecore/socket.h>
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
#include <pulsecore/core-rtclock.h>
|
#include <pulsecore/core-rtclock.h>
|
||||||
#include <pulsecore/core.h>
|
#include <pulsecore/core.h>
|
||||||
|
|
@ -137,7 +133,7 @@ static void message_cb(pa_mainloop_api*a, pa_time_event*e, const struct timeval
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_timeval_add(pa_gettimeofday(&tvnext), 100000);
|
pa_timeval_add(pa_gettimeofday(&tvnext), 100000);
|
||||||
a->rtclock_time_restart(e, &tvnext);
|
a->time_restart(e, &tvnext);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -658,6 +654,7 @@ int main(int argc, char *argv[]) {
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_GETUID
|
||||||
if (getuid() == 0 && !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)."));
|
pa_log_warn(_("This program is not intended to be run as root (unless --system is specified)."));
|
||||||
#ifndef HAVE_DBUS /* A similar, only a notice worthy check was done earlier, if D-Bus is enabled. */
|
#ifndef HAVE_DBUS /* A similar, only a notice worthy check was done earlier, if D-Bus is enabled. */
|
||||||
|
|
@ -666,6 +663,7 @@ int main(int argc, char *argv[]) {
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* HAVE_GETUID */
|
||||||
|
|
||||||
if (conf->cmd == PA_CMD_START && conf->system_instance) {
|
if (conf->cmd == PA_CMD_START && conf->system_instance) {
|
||||||
pa_log(_("--start not supported for system instances."));
|
pa_log(_("--start not supported for system instances."));
|
||||||
|
|
@ -984,7 +982,7 @@ int main(int argc, char *argv[]) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OS_IS_WIN32
|
#ifdef OS_IS_WIN32
|
||||||
win32_timer = pa_mainloop_get_api(mainloop)->rtclock_time_new(pa_mainloop_get_api(mainloop), pa_gettimeofday(&win32_tv), message_cb, NULL);
|
win32_timer = pa_mainloop_get_api(mainloop)->time_new(pa_mainloop_get_api(mainloop), pa_gettimeofday(&win32_tv), message_cb, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!conf->no_cpu_limit)
|
if (!conf->no_cpu_limit)
|
||||||
|
|
@ -1080,7 +1078,7 @@ finish:
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OS_IS_WIN32
|
#ifdef OS_IS_WIN32
|
||||||
if (win32_timer)
|
if (mainloop && win32_timer)
|
||||||
pa_mainloop_get_api(mainloop)->time_free(win32_timer);
|
pa_mainloop_get_api(mainloop)->time_free(win32_timer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,6 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <poll.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <linux/sockios.h>
|
#include <linux/sockios.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
|
@ -44,6 +42,7 @@
|
||||||
#include <pulsecore/socket-util.h>
|
#include <pulsecore/socket-util.h>
|
||||||
#include <pulsecore/thread.h>
|
#include <pulsecore/thread.h>
|
||||||
#include <pulsecore/thread-mq.h>
|
#include <pulsecore/thread-mq.h>
|
||||||
|
#include <pulsecore/poll.h>
|
||||||
#include <pulsecore/rtpoll.h>
|
#include <pulsecore/rtpoll.h>
|
||||||
#include <pulsecore/time-smoother.h>
|
#include <pulsecore/time-smoother.h>
|
||||||
#include <pulsecore/namereg.h>
|
#include <pulsecore/namereg.h>
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,7 @@ static void update_rule(struct rule *r) {
|
||||||
DIR *desktopfiles_dir;
|
DIR *desktopfiles_dir;
|
||||||
struct dirent *dir;
|
struct dirent *dir;
|
||||||
|
|
||||||
|
#ifdef DT_DIR
|
||||||
/* Let's try a more aggressive search, but only one level */
|
/* Let's try a more aggressive search, but only one level */
|
||||||
if ((desktopfiles_dir = opendir(DESKTOPFILEDIR))) {
|
if ((desktopfiles_dir = opendir(DESKTOPFILEDIR))) {
|
||||||
while ((dir = readdir(desktopfiles_dir))) {
|
while ((dir = readdir(desktopfiles_dir))) {
|
||||||
|
|
@ -200,6 +201,7 @@ static void update_rule(struct rule *r) {
|
||||||
}
|
}
|
||||||
closedir(desktopfiles_dir);
|
closedir(desktopfiles_dir);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
r->good = FALSE;
|
r->good = FALSE;
|
||||||
|
|
|
||||||
|
|
@ -105,10 +105,14 @@ int pa__init(pa_module*m) {
|
||||||
* of log messages, particularly because if stdout and stderr are
|
* of log messages, particularly because if stdout and stderr are
|
||||||
* dup'ed they share the same O_NDELAY, too. */
|
* dup'ed they share the same O_NDELAY, too. */
|
||||||
|
|
||||||
|
#ifndef OS_IS_WIN32
|
||||||
if ((fd = pa_open_cloexec("/dev/tty", O_RDWR|O_NONBLOCK, 0)) >= 0) {
|
if ((fd = pa_open_cloexec("/dev/tty", O_RDWR|O_NONBLOCK, 0)) >= 0) {
|
||||||
io = pa_iochannel_new(m->core->mainloop, fd, fd);
|
io = pa_iochannel_new(m->core->mainloop, fd, fd);
|
||||||
pa_log_debug("Managed to open /dev/tty.");
|
pa_log_debug("Managed to open /dev/tty.");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
io = pa_iochannel_new(m->core->mainloop, STDIN_FILENO, STDOUT_FILENO);
|
io = pa_iochannel_new(m->core->mainloop, STDIN_FILENO, STDOUT_FILENO);
|
||||||
pa_iochannel_set_noclose(io, TRUE);
|
pa_iochannel_set_noclose(io, TRUE);
|
||||||
pa_log_debug("Failed to open /dev/tty, using stdin/stdout fds instead.");
|
pa_log_debug("Failed to open /dev/tty, using stdin/stdout fds instead.");
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,18 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <poll.h>
|
|
||||||
#include <sys/socket.h>
|
#ifdef HAVE_NETINET_IN_H
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_NETINET_TCP_H
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_IOCTL_H
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_SOCKIOS_H
|
#ifdef HAVE_LINUX_SOCKIOS_H
|
||||||
#include <linux/sockios.h>
|
#include <linux/sockios.h>
|
||||||
|
|
@ -45,6 +52,7 @@
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
|
|
||||||
|
#include <pulsecore/socket.h>
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
#include <pulsecore/iochannel.h>
|
#include <pulsecore/iochannel.h>
|
||||||
#include <pulsecore/sink.h>
|
#include <pulsecore/sink.h>
|
||||||
|
|
@ -60,6 +68,8 @@
|
||||||
#include <pulsecore/thread.h>
|
#include <pulsecore/thread.h>
|
||||||
#include <pulsecore/time-smoother.h>
|
#include <pulsecore/time-smoother.h>
|
||||||
#include <pulsecore/socket-util.h>
|
#include <pulsecore/socket-util.h>
|
||||||
|
#include <pulsecore/rtpoll.h>
|
||||||
|
#include <pulsecore/poll.h>
|
||||||
|
|
||||||
#include "module-esound-sink-symdef.h"
|
#include "module-esound-sink-symdef.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,15 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <regex.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#if defined(HAVE_REGEX_H)
|
||||||
|
#include <regex.h>
|
||||||
|
#elif defined(HAVE_PCREPOSIX_H)
|
||||||
|
#include <pcreposix.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
|
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <poll.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_FILIO_H
|
#ifdef HAVE_SYS_FILIO_H
|
||||||
#include <sys/filio.h>
|
#include <sys/filio.h>
|
||||||
|
|
@ -49,6 +48,7 @@
|
||||||
#include <pulsecore/thread.h>
|
#include <pulsecore/thread.h>
|
||||||
#include <pulsecore/thread-mq.h>
|
#include <pulsecore/thread-mq.h>
|
||||||
#include <pulsecore/rtpoll.h>
|
#include <pulsecore/rtpoll.h>
|
||||||
|
#include <pulsecore/poll.h>
|
||||||
|
|
||||||
#include "module-pipe-sink-symdef.h"
|
#include "module-pipe-sink-symdef.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/poll.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_FILIO_H
|
#ifdef HAVE_SYS_FILIO_H
|
||||||
#include <sys/filio.h>
|
#include <sys/filio.h>
|
||||||
|
|
@ -49,6 +48,7 @@
|
||||||
#include <pulsecore/thread.h>
|
#include <pulsecore/thread.h>
|
||||||
#include <pulsecore/thread-mq.h>
|
#include <pulsecore/thread-mq.h>
|
||||||
#include <pulsecore/rtpoll.h>
|
#include <pulsecore/rtpoll.h>
|
||||||
|
#include <pulsecore/poll.h>
|
||||||
|
|
||||||
#include "module-pipe-source-symdef.h"
|
#include "module-pipe-source-symdef.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ARPA_INET_H
|
#ifdef HAVE_ARPA_INET_H
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -42,9 +39,9 @@
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
|
|
||||||
#include <pulsecore/winsock.h>
|
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
#include <pulsecore/module.h>
|
#include <pulsecore/module.h>
|
||||||
|
#include <pulsecore/socket.h>
|
||||||
#include <pulsecore/socket-server.h>
|
#include <pulsecore/socket-server.h>
|
||||||
#include <pulsecore/socket-util.h>
|
#include <pulsecore/socket-util.h>
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/ioctl.h>
|
|
||||||
|
|
||||||
#include <pulse/rtclock.h>
|
#include <pulse/rtclock.h>
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
|
|
@ -47,7 +46,6 @@
|
||||||
#include <pulsecore/thread.h>
|
#include <pulsecore/thread.h>
|
||||||
#include <pulsecore/thread-mq.h>
|
#include <pulsecore/thread-mq.h>
|
||||||
#include <pulsecore/rtpoll.h>
|
#include <pulsecore/rtpoll.h>
|
||||||
#include <pulsecore/poll.h>
|
|
||||||
|
|
||||||
#include "module-sine-source-symdef.h"
|
#include "module-sine-source-symdef.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
|
#include <pulse/rtclock.h>
|
||||||
|
|
||||||
#include <pulsecore/sink.h>
|
#include <pulsecore/sink.h>
|
||||||
#include <pulsecore/source.h>
|
#include <pulsecore/source.h>
|
||||||
|
|
@ -39,12 +40,14 @@
|
||||||
#include <pulsecore/sample-util.h>
|
#include <pulsecore/sample-util.h>
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
|
#include <pulsecore/thread.h>
|
||||||
|
#include <pulsecore/thread-mq.h>
|
||||||
|
|
||||||
#include "module-waveout-symdef.h"
|
#include "module-waveout-symdef.h"
|
||||||
|
|
||||||
PA_MODULE_AUTHOR("Pierre Ossman")
|
PA_MODULE_AUTHOR("Pierre Ossman");
|
||||||
PA_MODULE_DESCRIPTION("Windows waveOut Sink/Source")
|
PA_MODULE_DESCRIPTION("Windows waveOut Sink/Source");
|
||||||
PA_MODULE_VERSION(PACKAGE_VERSION)
|
PA_MODULE_VERSION(PACKAGE_VERSION);
|
||||||
PA_MODULE_USAGE(
|
PA_MODULE_USAGE(
|
||||||
"sink_name=<name for the sink> "
|
"sink_name=<name for the sink> "
|
||||||
"source_name=<name for the source> "
|
"source_name=<name for the source> "
|
||||||
|
|
@ -56,7 +59,7 @@ PA_MODULE_USAGE(
|
||||||
"rate=<sample rate> "
|
"rate=<sample rate> "
|
||||||
"fragments=<number of fragments> "
|
"fragments=<number of fragments> "
|
||||||
"fragment_size=<fragment size> "
|
"fragment_size=<fragment size> "
|
||||||
"channel_map=<channel map>")
|
"channel_map=<channel map>");
|
||||||
|
|
||||||
#define DEFAULT_SINK_NAME "wave_output"
|
#define DEFAULT_SINK_NAME "wave_output"
|
||||||
#define DEFAULT_SOURCE_NAME "wave_input"
|
#define DEFAULT_SOURCE_NAME "wave_input"
|
||||||
|
|
@ -67,10 +70,12 @@ struct userdata {
|
||||||
pa_sink *sink;
|
pa_sink *sink;
|
||||||
pa_source *source;
|
pa_source *source;
|
||||||
pa_core *core;
|
pa_core *core;
|
||||||
pa_time_event *event;
|
|
||||||
pa_defer_event *defer;
|
|
||||||
pa_usec_t poll_timeout;
|
pa_usec_t poll_timeout;
|
||||||
|
|
||||||
|
pa_thread *thread;
|
||||||
|
pa_thread_mq thread_mq;
|
||||||
|
pa_rtpoll *rtpoll;
|
||||||
|
|
||||||
uint32_t fragments, fragment_size;
|
uint32_t fragments, fragment_size;
|
||||||
|
|
||||||
uint32_t free_ofrags, free_ifrags;
|
uint32_t free_ofrags, free_ifrags;
|
||||||
|
|
@ -103,22 +108,19 @@ static const char* const valid_modargs[] = {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static void update_usage(struct userdata *u) {
|
static void do_write(struct userdata *u) {
|
||||||
pa_module_set_used(u->module,
|
|
||||||
(u->sink ? pa_sink_used_by(u->sink) : 0) +
|
|
||||||
(u->source ? pa_source_used_by(u->source) : 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void do_write(struct userdata *u)
|
|
||||||
{
|
|
||||||
uint32_t free_frags;
|
uint32_t free_frags;
|
||||||
pa_memchunk memchunk;
|
pa_memchunk memchunk;
|
||||||
WAVEHDR *hdr;
|
WAVEHDR *hdr;
|
||||||
MMRESULT res;
|
MMRESULT res;
|
||||||
|
void *p;
|
||||||
|
|
||||||
if (!u->sink)
|
if (!u->sink)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!PA_SINK_IS_LINKED(u->sink->state))
|
||||||
|
return;
|
||||||
|
|
||||||
EnterCriticalSection(&u->crit);
|
EnterCriticalSection(&u->crit);
|
||||||
free_frags = u->free_ofrags;
|
free_frags = u->free_ofrags;
|
||||||
LeaveCriticalSection(&u->crit);
|
LeaveCriticalSection(&u->crit);
|
||||||
|
|
@ -137,18 +139,17 @@ static void do_write(struct userdata *u)
|
||||||
|
|
||||||
len = u->fragment_size - hdr->dwBufferLength;
|
len = u->fragment_size - hdr->dwBufferLength;
|
||||||
|
|
||||||
if (pa_sink_render(u->sink, len, &memchunk) < 0)
|
pa_sink_render(u->sink, len, &memchunk);
|
||||||
break;
|
|
||||||
|
|
||||||
assert(memchunk.memblock);
|
pa_assert(memchunk.memblock);
|
||||||
assert(memchunk.memblock->data);
|
pa_assert(memchunk.length);
|
||||||
assert(memchunk.length);
|
|
||||||
|
|
||||||
if (memchunk.length < len)
|
if (memchunk.length < len)
|
||||||
len = memchunk.length;
|
len = memchunk.length;
|
||||||
|
|
||||||
memcpy(hdr->lpData + hdr->dwBufferLength,
|
p = pa_memblock_acquire(memchunk.memblock);
|
||||||
(char*)memchunk.memblock->data + memchunk.index, len);
|
memcpy(hdr->lpData + hdr->dwBufferLength, (char*) p + memchunk.index, len);
|
||||||
|
pa_memblock_release(memchunk.memblock);
|
||||||
|
|
||||||
hdr->dwBufferLength += len;
|
hdr->dwBufferLength += len;
|
||||||
|
|
||||||
|
|
@ -165,15 +166,12 @@ static void do_write(struct userdata *u)
|
||||||
u->sink_underflow = 0;
|
u->sink_underflow = 0;
|
||||||
|
|
||||||
res = waveOutPrepareHeader(u->hwo, hdr, sizeof(WAVEHDR));
|
res = waveOutPrepareHeader(u->hwo, hdr, sizeof(WAVEHDR));
|
||||||
if (res != MMSYSERR_NOERROR) {
|
if (res != MMSYSERR_NOERROR)
|
||||||
pa_log_error(__FILE__ ": ERROR: Unable to prepare waveOut block: %d",
|
pa_log_error("Unable to prepare waveOut block: %d", res);
|
||||||
res);
|
|
||||||
}
|
|
||||||
res = waveOutWrite(u->hwo, hdr, sizeof(WAVEHDR));
|
res = waveOutWrite(u->hwo, hdr, sizeof(WAVEHDR));
|
||||||
if (res != MMSYSERR_NOERROR) {
|
if (res != MMSYSERR_NOERROR)
|
||||||
pa_log_error(__FILE__ ": ERROR: Unable to write waveOut block: %d",
|
pa_log_error("Unable to write waveOut block: %d", res);
|
||||||
res);
|
|
||||||
}
|
|
||||||
|
|
||||||
u->written_bytes += hdr->dwBufferLength;
|
u->written_bytes += hdr->dwBufferLength;
|
||||||
|
|
||||||
|
|
@ -187,21 +185,22 @@ static void do_write(struct userdata *u)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_read(struct userdata *u)
|
static void do_read(struct userdata *u) {
|
||||||
{
|
|
||||||
uint32_t free_frags;
|
uint32_t free_frags;
|
||||||
pa_memchunk memchunk;
|
pa_memchunk memchunk;
|
||||||
WAVEHDR *hdr;
|
WAVEHDR *hdr;
|
||||||
MMRESULT res;
|
MMRESULT res;
|
||||||
|
void *p;
|
||||||
|
|
||||||
if (!u->source)
|
if (!u->source)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EnterCriticalSection(&u->crit);
|
if (!PA_SOURCE_IS_LINKED(u->source->state))
|
||||||
|
return;
|
||||||
|
|
||||||
|
EnterCriticalSection(&u->crit);
|
||||||
free_frags = u->free_ifrags;
|
free_frags = u->free_ifrags;
|
||||||
u->free_ifrags = 0;
|
u->free_ifrags = 0;
|
||||||
|
|
||||||
LeaveCriticalSection(&u->crit);
|
LeaveCriticalSection(&u->crit);
|
||||||
|
|
||||||
if (free_frags == u->fragments)
|
if (free_frags == u->fragments)
|
||||||
|
|
@ -214,11 +213,13 @@ static void do_read(struct userdata *u)
|
||||||
|
|
||||||
if (hdr->dwBytesRecorded) {
|
if (hdr->dwBytesRecorded) {
|
||||||
memchunk.memblock = pa_memblock_new(u->core->mempool, hdr->dwBytesRecorded);
|
memchunk.memblock = pa_memblock_new(u->core->mempool, hdr->dwBytesRecorded);
|
||||||
assert(memchunk.memblock);
|
pa_assert(memchunk.memblock);
|
||||||
|
|
||||||
memcpy((char*)memchunk.memblock->data, hdr->lpData, hdr->dwBytesRecorded);
|
p = pa_memblock_acquire(memchunk.memblock);
|
||||||
|
memcpy((char*) p, hdr->lpData, hdr->dwBytesRecorded);
|
||||||
|
pa_memblock_release(memchunk.memblock);
|
||||||
|
|
||||||
memchunk.length = memchunk.memblock->length = hdr->dwBytesRecorded;
|
memchunk.length = hdr->dwBytesRecorded;
|
||||||
memchunk.index = 0;
|
memchunk.index = 0;
|
||||||
|
|
||||||
pa_source_post(u->source, &memchunk);
|
pa_source_post(u->source, &memchunk);
|
||||||
|
|
@ -226,15 +227,12 @@ static void do_read(struct userdata *u)
|
||||||
}
|
}
|
||||||
|
|
||||||
res = waveInPrepareHeader(u->hwi, hdr, sizeof(WAVEHDR));
|
res = waveInPrepareHeader(u->hwi, hdr, sizeof(WAVEHDR));
|
||||||
if (res != MMSYSERR_NOERROR) {
|
if (res != MMSYSERR_NOERROR)
|
||||||
pa_log_error(__FILE__ ": ERROR: Unable to prepare waveIn block: %d",
|
pa_log_error("Unable to prepare waveIn block: %d", res);
|
||||||
res);
|
|
||||||
}
|
|
||||||
res = waveInAddBuffer(u->hwi, hdr, sizeof(WAVEHDR));
|
res = waveInAddBuffer(u->hwi, hdr, sizeof(WAVEHDR));
|
||||||
if (res != MMSYSERR_NOERROR) {
|
if (res != MMSYSERR_NOERROR)
|
||||||
pa_log_error(__FILE__ ": ERROR: Unable to add waveIn block: %d",
|
pa_log_error("Unable to add waveIn block: %d", res);
|
||||||
res);
|
|
||||||
}
|
|
||||||
|
|
||||||
free_frags--;
|
free_frags--;
|
||||||
u->cur_ihdr++;
|
u->cur_ihdr++;
|
||||||
|
|
@ -242,32 +240,53 @@ static void do_read(struct userdata *u)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void poll_cb(pa_mainloop_api*a, pa_time_event *e, const struct timeval *tv, void *userdata) {
|
static void thread_func(void *userdata) {
|
||||||
struct userdata *u = userdata;
|
|
||||||
struct timeval ntv;
|
|
||||||
|
|
||||||
assert(u);
|
|
||||||
|
|
||||||
update_usage(u);
|
|
||||||
|
|
||||||
do_write(u);
|
|
||||||
do_read(u);
|
|
||||||
|
|
||||||
pa_gettimeofday(&ntv);
|
|
||||||
pa_timeval_add(&ntv, u->poll_timeout);
|
|
||||||
|
|
||||||
a->rtclock_time_restart(e, &ntv);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void defer_cb(pa_mainloop_api*a, pa_defer_event *e, void *userdata) {
|
|
||||||
struct userdata *u = userdata;
|
struct userdata *u = userdata;
|
||||||
|
|
||||||
assert(u);
|
pa_assert(u);
|
||||||
|
pa_assert(u->sink || u->source);
|
||||||
|
|
||||||
a->defer_enable(e, 0);
|
pa_log_debug("Thread starting up");
|
||||||
|
|
||||||
do_write(u);
|
if (u->core->realtime_scheduling)
|
||||||
do_read(u);
|
pa_make_realtime(u->core->realtime_priority);
|
||||||
|
|
||||||
|
pa_thread_mq_install(&u->thread_mq);
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (PA_SINK_IS_OPENED(u->sink->thread_info.state) ||
|
||||||
|
PA_SOURCE_IS_OPENED(u->source->thread_info.state)) {
|
||||||
|
|
||||||
|
if (u->sink->thread_info.rewind_requested)
|
||||||
|
pa_sink_process_rewind(u->sink, 0);
|
||||||
|
|
||||||
|
if (PA_SINK_IS_OPENED(u->sink->thread_info.state))
|
||||||
|
do_write(u);
|
||||||
|
if (PA_SOURCE_IS_OPENED(u->source->thread_info.state))
|
||||||
|
do_read(u);
|
||||||
|
|
||||||
|
pa_rtpoll_set_timer_relative(u->rtpoll, u->poll_timeout);
|
||||||
|
} else
|
||||||
|
pa_rtpoll_set_timer_disabled(u->rtpoll);
|
||||||
|
|
||||||
|
/* Hmm, nothing to do. Let's sleep */
|
||||||
|
if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
if (ret == 0)
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
|
||||||
|
fail:
|
||||||
|
/* If this was no regular exit from the loop we have to continue
|
||||||
|
* processing messages until we received PA_MESSAGE_SHUTDOWN */
|
||||||
|
pa_asyncmsgq_post(u->thread_mq.outq, PA_MSGOBJECT(u->core), PA_CORE_MESSAGE_UNLOAD_MODULE, u->module, 0, NULL, NULL);
|
||||||
|
pa_asyncmsgq_wait_for(u->thread_mq.inq, PA_MESSAGE_SHUTDOWN);
|
||||||
|
|
||||||
|
finish:
|
||||||
|
pa_log_debug("Thread shutting down");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CALLBACK chunk_done_cb(HWAVEOUT hwo, UINT msg, DWORD_PTR inst, DWORD param1, DWORD param2) {
|
static void CALLBACK chunk_done_cb(HWAVEOUT hwo, UINT msg, DWORD_PTR inst, DWORD param1, DWORD param2) {
|
||||||
|
|
@ -277,10 +296,8 @@ static void CALLBACK chunk_done_cb(HWAVEOUT hwo, UINT msg, DWORD_PTR inst, DWORD
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EnterCriticalSection(&u->crit);
|
EnterCriticalSection(&u->crit);
|
||||||
|
|
||||||
u->free_ofrags++;
|
u->free_ofrags++;
|
||||||
assert(u->free_ofrags <= u->fragments);
|
pa_assert(u->free_ofrags <= u->fragments);
|
||||||
|
|
||||||
LeaveCriticalSection(&u->crit);
|
LeaveCriticalSection(&u->crit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -291,107 +308,124 @@ static void CALLBACK chunk_ready_cb(HWAVEIN hwi, UINT msg, DWORD_PTR inst, DWORD
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EnterCriticalSection(&u->crit);
|
EnterCriticalSection(&u->crit);
|
||||||
|
|
||||||
u->free_ifrags++;
|
u->free_ifrags++;
|
||||||
assert(u->free_ifrags <= u->fragments);
|
pa_assert(u->free_ifrags <= u->fragments);
|
||||||
|
|
||||||
LeaveCriticalSection(&u->crit);
|
LeaveCriticalSection(&u->crit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pa_usec_t sink_get_latency_cb(pa_sink *s) {
|
static pa_usec_t sink_get_latency(struct userdata *u) {
|
||||||
struct userdata *u = s->userdata;
|
|
||||||
uint32_t free_frags;
|
uint32_t free_frags;
|
||||||
MMTIME mmt;
|
MMTIME mmt;
|
||||||
assert(s && u && u->sink);
|
pa_assert(u);
|
||||||
|
pa_assert(u->sink);
|
||||||
|
|
||||||
memset(&mmt, 0, sizeof(mmt));
|
memset(&mmt, 0, sizeof(mmt));
|
||||||
mmt.wType = TIME_BYTES;
|
mmt.wType = TIME_BYTES;
|
||||||
if (waveOutGetPosition(u->hwo, &mmt, sizeof(mmt)) == MMSYSERR_NOERROR)
|
if (waveOutGetPosition(u->hwo, &mmt, sizeof(mmt)) == MMSYSERR_NOERROR)
|
||||||
return pa_bytes_to_usec(u->written_bytes - mmt.u.cb, &s->sample_spec);
|
return pa_bytes_to_usec(u->written_bytes - mmt.u.cb, &u->sink->sample_spec);
|
||||||
else {
|
else {
|
||||||
EnterCriticalSection(&u->crit);
|
EnterCriticalSection(&u->crit);
|
||||||
|
|
||||||
free_frags = u->free_ofrags;
|
free_frags = u->free_ofrags;
|
||||||
|
|
||||||
LeaveCriticalSection(&u->crit);
|
LeaveCriticalSection(&u->crit);
|
||||||
|
|
||||||
return pa_bytes_to_usec((u->fragments - free_frags) * u->fragment_size,
|
return pa_bytes_to_usec((u->fragments - free_frags) * u->fragment_size, &u->sink->sample_spec);
|
||||||
&s->sample_spec);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static pa_usec_t source_get_latency_cb(pa_source *s) {
|
static pa_usec_t source_get_latency(struct userdata *u) {
|
||||||
pa_usec_t r = 0;
|
pa_usec_t r = 0;
|
||||||
struct userdata *u = s->userdata;
|
|
||||||
uint32_t free_frags;
|
uint32_t free_frags;
|
||||||
assert(s && u && u->sink);
|
pa_assert(u);
|
||||||
|
pa_assert(u->source);
|
||||||
|
|
||||||
EnterCriticalSection(&u->crit);
|
EnterCriticalSection(&u->crit);
|
||||||
|
|
||||||
free_frags = u->free_ifrags;
|
free_frags = u->free_ifrags;
|
||||||
|
|
||||||
LeaveCriticalSection(&u->crit);
|
LeaveCriticalSection(&u->crit);
|
||||||
|
|
||||||
r += pa_bytes_to_usec((free_frags + 1) * u->fragment_size, &s->sample_spec);
|
r += pa_bytes_to_usec((free_frags + 1) * u->fragment_size, &u->source->sample_spec);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void notify_sink_cb(pa_sink *s) {
|
static int process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
|
||||||
struct userdata *u = s->userdata;
|
struct userdata *u;
|
||||||
assert(u);
|
|
||||||
|
|
||||||
u->core->mainloop->defer_enable(u->defer, 1);
|
if (pa_sink_isinstance(o)) {
|
||||||
|
u = PA_SINK(o)->userdata;
|
||||||
|
|
||||||
|
switch (code) {
|
||||||
|
|
||||||
|
case PA_SINK_MESSAGE_GET_LATENCY: {
|
||||||
|
pa_usec_t r = 0;
|
||||||
|
if (u->hwo)
|
||||||
|
r = sink_get_latency(u);
|
||||||
|
*((pa_usec_t*) data) = r;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return pa_sink_process_msg(o, code, data, offset, chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pa_source_isinstance(o)) {
|
||||||
|
u = PA_SOURCE(o)->userdata;
|
||||||
|
|
||||||
|
switch (code) {
|
||||||
|
|
||||||
|
case PA_SOURCE_MESSAGE_GET_LATENCY: {
|
||||||
|
pa_usec_t r = 0;
|
||||||
|
if (u->hwi)
|
||||||
|
r = source_get_latency(u);
|
||||||
|
*((pa_usec_t*) data) = r;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return pa_source_process_msg(o, code, data, offset, chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void notify_source_cb(pa_source *s) {
|
static void sink_get_volume_cb(pa_sink *s) {
|
||||||
struct userdata *u = s->userdata;
|
|
||||||
assert(u);
|
|
||||||
|
|
||||||
u->core->mainloop->defer_enable(u->defer, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int sink_get_hw_volume_cb(pa_sink *s) {
|
|
||||||
struct userdata *u = s->userdata;
|
struct userdata *u = s->userdata;
|
||||||
DWORD vol;
|
DWORD vol;
|
||||||
pa_volume_t left, right;
|
pa_volume_t left, right;
|
||||||
|
|
||||||
if (waveOutGetVolume(u->hwo, &vol) != MMSYSERR_NOERROR)
|
if (waveOutGetVolume(u->hwo, &vol) != MMSYSERR_NOERROR)
|
||||||
return -1;
|
return;
|
||||||
|
|
||||||
left = PA_CLAMP_VOLUME((vol & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME);
|
left = PA_CLAMP_VOLUME((vol & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME);
|
||||||
right = PA_CLAMP_VOLUME(((vol >> 16) & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME);
|
right = PA_CLAMP_VOLUME(((vol >> 16) & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME);
|
||||||
|
|
||||||
/* Windows supports > 2 channels, except for volume control */
|
/* Windows supports > 2 channels, except for volume control */
|
||||||
if (s->hw_volume.channels > 2)
|
if (s->real_volume.channels > 2)
|
||||||
pa_cvolume_set(&s->hw_volume, s->hw_volume.channels, (left + right)/2);
|
pa_cvolume_set(&s->real_volume, s->real_volume.channels, (left + right)/2);
|
||||||
|
|
||||||
s->hw_volume.values[0] = left;
|
s->real_volume.values[0] = left;
|
||||||
if (s->hw_volume.channels > 1)
|
if (s->real_volume.channels > 1)
|
||||||
s->hw_volume.values[1] = right;
|
s->real_volume.values[1] = right;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sink_set_hw_volume_cb(pa_sink *s) {
|
static void sink_set_volume_cb(pa_sink *s) {
|
||||||
struct userdata *u = s->userdata;
|
struct userdata *u = s->userdata;
|
||||||
DWORD vol;
|
DWORD vol;
|
||||||
|
|
||||||
vol = s->hw_volume.values[0] * WAVEOUT_MAX_VOLUME / PA_VOLUME_NORM;
|
vol = s->real_volume.values[0] * WAVEOUT_MAX_VOLUME / PA_VOLUME_NORM;
|
||||||
if (s->hw_volume.channels > 1)
|
if (s->real_volume.channels > 1)
|
||||||
vol |= (s->hw_volume.values[0] * WAVEOUT_MAX_VOLUME / PA_VOLUME_NORM) << 16;
|
vol |= (s->real_volume.values[1] * WAVEOUT_MAX_VOLUME / PA_VOLUME_NORM) << 16;
|
||||||
|
|
||||||
if (waveOutSetVolume(u->hwo, vol) != MMSYSERR_NOERROR)
|
if (waveOutSetVolume(u->hwo, vol) != MMSYSERR_NOERROR)
|
||||||
return -1;
|
return;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ss_to_waveformat(pa_sample_spec *ss, LPWAVEFORMATEX wf) {
|
static int ss_to_waveformat(pa_sample_spec *ss, LPWAVEFORMATEX wf) {
|
||||||
wf->wFormatTag = WAVE_FORMAT_PCM;
|
wf->wFormatTag = WAVE_FORMAT_PCM;
|
||||||
|
|
||||||
if (ss->channels > 2) {
|
if (ss->channels > 2) {
|
||||||
pa_log_error("ERROR: More than two channels not supported.");
|
pa_log_error("More than two channels not supported.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -404,7 +438,7 @@ static int ss_to_waveformat(pa_sample_spec *ss, LPWAVEFORMATEX wf) {
|
||||||
case 44100:
|
case 44100:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pa_log_error("ERROR: Unsupported sample rate.");
|
pa_log_error("Unsupported sample rate.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -415,7 +449,7 @@ static int ss_to_waveformat(pa_sample_spec *ss, LPWAVEFORMATEX wf) {
|
||||||
else if (ss->format == PA_SAMPLE_S16NE)
|
else if (ss->format == PA_SAMPLE_S16NE)
|
||||||
wf->wBitsPerSample = 16;
|
wf->wBitsPerSample = 16;
|
||||||
else {
|
else {
|
||||||
pa_log_error("ERROR: Unsupported sample format.");
|
pa_log_error("Unsupported sample format.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -427,21 +461,31 @@ static int ss_to_waveformat(pa_sample_spec *ss, LPWAVEFORMATEX wf) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa__init(pa_core *c, pa_module*m) {
|
int pa__get_n_used(pa_module *m) {
|
||||||
|
struct userdata *u;
|
||||||
|
pa_assert(m);
|
||||||
|
pa_assert(m->userdata);
|
||||||
|
u = (struct userdata *)m->userdata;
|
||||||
|
|
||||||
|
return (u->sink ? pa_sink_used_by(u->sink) : 0) +
|
||||||
|
(u->source ? pa_source_used_by(u->source) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int pa__init(pa_module *m) {
|
||||||
struct userdata *u = NULL;
|
struct userdata *u = NULL;
|
||||||
HWAVEOUT hwo = INVALID_HANDLE_VALUE;
|
HWAVEOUT hwo = INVALID_HANDLE_VALUE;
|
||||||
HWAVEIN hwi = INVALID_HANDLE_VALUE;
|
HWAVEIN hwi = INVALID_HANDLE_VALUE;
|
||||||
WAVEFORMATEX wf;
|
WAVEFORMATEX wf;
|
||||||
int nfrags, frag_size;
|
int nfrags, frag_size;
|
||||||
int record = 1, playback = 1;
|
pa_bool_t record = TRUE, playback = TRUE;
|
||||||
unsigned int device;
|
unsigned int device;
|
||||||
pa_sample_spec ss;
|
pa_sample_spec ss;
|
||||||
pa_channel_map map;
|
pa_channel_map map;
|
||||||
pa_modargs *ma = NULL;
|
pa_modargs *ma = NULL;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct timeval tv;
|
|
||||||
|
|
||||||
assert(c && m);
|
pa_assert(m);
|
||||||
|
pa_assert(m->core);
|
||||||
|
|
||||||
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
|
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
|
||||||
pa_log("failed to parse module arguments.");
|
pa_log("failed to parse module arguments.");
|
||||||
|
|
@ -471,7 +515,7 @@ int pa__init(pa_core *c, pa_module*m) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ss = c->default_sample_spec;
|
ss = m->core->default_sample_spec;
|
||||||
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_WAVEEX) < 0) {
|
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_WAVEEX) < 0) {
|
||||||
pa_log("failed to parse sample specification");
|
pa_log("failed to parse sample specification");
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
@ -505,34 +549,47 @@ int pa__init(pa_core *c, pa_module*m) {
|
||||||
InitializeCriticalSection(&u->crit);
|
InitializeCriticalSection(&u->crit);
|
||||||
|
|
||||||
if (hwi != INVALID_HANDLE_VALUE) {
|
if (hwi != INVALID_HANDLE_VALUE) {
|
||||||
u->source = pa_source_new(c, __FILE__, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME), 0, &ss, &map);
|
pa_source_new_data data;
|
||||||
assert(u->source);
|
pa_source_new_data_init(&data);
|
||||||
|
data.driver = __FILE__;
|
||||||
|
data.module = m;
|
||||||
|
pa_source_new_data_set_sample_spec(&data, &ss);
|
||||||
|
pa_source_new_data_set_channel_map(&data, &map);
|
||||||
|
pa_source_new_data_set_name(&data, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME));
|
||||||
|
u->source = pa_source_new(m->core, &data, PA_SOURCE_HARDWARE|PA_SOURCE_LATENCY);
|
||||||
|
pa_source_new_data_done(&data);
|
||||||
|
|
||||||
|
pa_assert(u->source);
|
||||||
u->source->userdata = u;
|
u->source->userdata = u;
|
||||||
u->source->notify = notify_source_cb;
|
|
||||||
u->source->get_latency = source_get_latency_cb;
|
|
||||||
pa_source_set_owner(u->source, m);
|
|
||||||
pa_source_set_description(u->source, "Windows waveIn PCM");
|
pa_source_set_description(u->source, "Windows waveIn PCM");
|
||||||
u->source->is_hardware = 1;
|
u->source->parent.process_msg = process_msg;
|
||||||
} else
|
} else
|
||||||
u->source = NULL;
|
u->source = NULL;
|
||||||
|
|
||||||
if (hwo != INVALID_HANDLE_VALUE) {
|
if (hwo != INVALID_HANDLE_VALUE) {
|
||||||
u->sink = pa_sink_new(c, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map);
|
pa_sink_new_data data;
|
||||||
assert(u->sink);
|
pa_sink_new_data_init(&data);
|
||||||
u->sink->notify = notify_sink_cb;
|
data.driver = __FILE__;
|
||||||
u->sink->get_latency = sink_get_latency_cb;
|
data.module = m;
|
||||||
u->sink->get_hw_volume = sink_get_hw_volume_cb;
|
pa_sink_new_data_set_sample_spec(&data, &ss);
|
||||||
u->sink->set_hw_volume = sink_set_hw_volume_cb;
|
pa_sink_new_data_set_channel_map(&data, &map);
|
||||||
|
pa_sink_new_data_set_name(&data, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME));
|
||||||
|
u->sink = pa_sink_new(m->core, &data, PA_SINK_HARDWARE|PA_SINK_LATENCY);
|
||||||
|
pa_sink_new_data_done(&data);
|
||||||
|
|
||||||
|
pa_assert(u->sink);
|
||||||
|
u->sink->get_volume = sink_get_volume_cb;
|
||||||
|
u->sink->set_volume = sink_set_volume_cb;
|
||||||
u->sink->userdata = u;
|
u->sink->userdata = u;
|
||||||
pa_sink_set_owner(u->sink, m);
|
|
||||||
pa_sink_set_description(u->sink, "Windows waveOut PCM");
|
pa_sink_set_description(u->sink, "Windows waveOut PCM");
|
||||||
u->sink->is_hardware = 1;
|
u->sink->parent.process_msg = process_msg;
|
||||||
} else
|
} else
|
||||||
u->sink = NULL;
|
u->sink = NULL;
|
||||||
|
|
||||||
assert(u->source || u->sink);
|
pa_assert(u->source || u->sink);
|
||||||
|
pa_modargs_free(ma);
|
||||||
|
|
||||||
u->core = c;
|
u->core = m->core;
|
||||||
u->hwi = hwi;
|
u->hwi = hwi;
|
||||||
u->hwo = hwo;
|
u->hwo = hwo;
|
||||||
|
|
||||||
|
|
@ -546,82 +603,84 @@ int pa__init(pa_core *c, pa_module*m) {
|
||||||
|
|
||||||
u->poll_timeout = pa_bytes_to_usec(u->fragments * u->fragment_size / 10, &ss);
|
u->poll_timeout = pa_bytes_to_usec(u->fragments * u->fragment_size / 10, &ss);
|
||||||
|
|
||||||
pa_gettimeofday(&tv);
|
|
||||||
pa_timeval_add(&tv, u->poll_timeout);
|
|
||||||
|
|
||||||
u->event = c->mainloop->rtclock_time_new(c->mainloop, &tv, poll_cb, u);
|
|
||||||
assert(u->event);
|
|
||||||
|
|
||||||
u->defer = c->mainloop->defer_new(c->mainloop, defer_cb, u);
|
|
||||||
assert(u->defer);
|
|
||||||
c->mainloop->defer_enable(u->defer, 0);
|
|
||||||
|
|
||||||
u->cur_ihdr = 0;
|
u->cur_ihdr = 0;
|
||||||
u->cur_ohdr = 0;
|
u->cur_ohdr = 0;
|
||||||
u->ihdrs = pa_xmalloc0(sizeof(WAVEHDR) * u->fragments);
|
u->ihdrs = pa_xmalloc0(sizeof(WAVEHDR) * u->fragments);
|
||||||
assert(u->ihdrs);
|
pa_assert(u->ihdrs);
|
||||||
u->ohdrs = pa_xmalloc0(sizeof(WAVEHDR) * u->fragments);
|
u->ohdrs = pa_xmalloc0(sizeof(WAVEHDR) * u->fragments);
|
||||||
assert(u->ohdrs);
|
pa_assert(u->ohdrs);
|
||||||
for (i = 0;i < u->fragments;i++) {
|
for (i = 0;i < u->fragments;i++) {
|
||||||
u->ihdrs[i].dwBufferLength = u->fragment_size;
|
u->ihdrs[i].dwBufferLength = u->fragment_size;
|
||||||
u->ohdrs[i].dwBufferLength = u->fragment_size;
|
u->ohdrs[i].dwBufferLength = u->fragment_size;
|
||||||
u->ihdrs[i].lpData = pa_xmalloc(u->fragment_size);
|
u->ihdrs[i].lpData = pa_xmalloc(u->fragment_size);
|
||||||
assert(u->ihdrs);
|
pa_assert(u->ihdrs);
|
||||||
u->ohdrs[i].lpData = pa_xmalloc(u->fragment_size);
|
u->ohdrs[i].lpData = pa_xmalloc(u->fragment_size);
|
||||||
assert(u->ohdrs);
|
pa_assert(u->ohdrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
u->module = m;
|
u->module = m;
|
||||||
m->userdata = u;
|
m->userdata = u;
|
||||||
|
|
||||||
pa_modargs_free(ma);
|
|
||||||
|
|
||||||
/* Read mixer settings */
|
/* Read mixer settings */
|
||||||
if (u->sink)
|
if (u->sink)
|
||||||
sink_get_hw_volume_cb(u->sink);
|
sink_get_volume_cb(u->sink);
|
||||||
|
|
||||||
|
u->rtpoll = pa_rtpoll_new();
|
||||||
|
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
|
||||||
|
if (!(u->thread = pa_thread_new("waveout-source", thread_func, u))) {
|
||||||
|
pa_log("Failed to create thread.");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (u->sink) {
|
||||||
|
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
|
||||||
|
pa_sink_set_rtpoll(u->sink, u->rtpoll);
|
||||||
|
pa_sink_put(u->sink);
|
||||||
|
}
|
||||||
|
if (u->source) {
|
||||||
|
pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);
|
||||||
|
pa_source_set_rtpoll(u->source, u->rtpoll);
|
||||||
|
pa_source_put(u->source);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (hwi != INVALID_HANDLE_VALUE)
|
|
||||||
waveInClose(hwi);
|
|
||||||
|
|
||||||
if (hwo != INVALID_HANDLE_VALUE)
|
|
||||||
waveOutClose(hwo);
|
|
||||||
|
|
||||||
if (u)
|
|
||||||
pa_xfree(u);
|
|
||||||
|
|
||||||
if (ma)
|
if (ma)
|
||||||
pa_modargs_free(ma);
|
pa_modargs_free(ma);
|
||||||
|
|
||||||
|
pa__done(m);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pa__done(pa_core *c, pa_module*m) {
|
void pa__done(pa_module *m) {
|
||||||
struct userdata *u;
|
struct userdata *u;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
assert(c && m);
|
pa_assert(m);
|
||||||
|
pa_assert(m->core);
|
||||||
|
|
||||||
if (!(u = m->userdata))
|
if (!(u = m->userdata))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (u->event)
|
if (u->sink)
|
||||||
c->mainloop->time_free(u->event);
|
pa_sink_unlink(u->sink);
|
||||||
|
if (u->source)
|
||||||
|
pa_source_unlink(u->source);
|
||||||
|
|
||||||
if (u->defer)
|
pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL);
|
||||||
c->mainloop->defer_free(u->defer);
|
if (u->thread)
|
||||||
|
pa_thread_free(u->thread);
|
||||||
|
pa_thread_mq_done(&u->thread_mq);
|
||||||
|
|
||||||
if (u->sink) {
|
if (u->sink)
|
||||||
pa_sink_disconnect(u->sink);
|
|
||||||
pa_sink_unref(u->sink);
|
pa_sink_unref(u->sink);
|
||||||
}
|
if (u->source)
|
||||||
|
|
||||||
if (u->source) {
|
|
||||||
pa_source_disconnect(u->source);
|
|
||||||
pa_source_unref(u->source);
|
pa_source_unref(u->source);
|
||||||
}
|
|
||||||
|
if (u->rtpoll)
|
||||||
|
pa_rtpoll_free(u->rtpoll);
|
||||||
|
|
||||||
if (u->hwi != INVALID_HANDLE_VALUE) {
|
if (u->hwi != INVALID_HANDLE_VALUE) {
|
||||||
waveInReset(u->hwi);
|
waveInReset(u->hwi);
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <poll.h>
|
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
#include <pulse/util.h>
|
#include <pulse/util.h>
|
||||||
|
|
@ -70,6 +69,7 @@
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
#include <pulsecore/thread-mq.h>
|
#include <pulsecore/thread-mq.h>
|
||||||
#include <pulsecore/rtpoll.h>
|
#include <pulsecore/rtpoll.h>
|
||||||
|
#include <pulsecore/poll.h>
|
||||||
|
|
||||||
#if defined(__NetBSD__) && !defined(SNDCTL_DSP_GETODELAY)
|
#if defined(__NetBSD__) && !defined(SNDCTL_DSP_GETODELAY)
|
||||||
#include <sys/audioio.h>
|
#include <sys/audioio.h>
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <poll.h>
|
|
||||||
|
|
||||||
#include <pulse/rtclock.h>
|
#include <pulse/rtclock.h>
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
|
|
@ -54,6 +53,7 @@
|
||||||
#include <pulsecore/atomic.h>
|
#include <pulsecore/atomic.h>
|
||||||
#include <pulsecore/socket-util.h>
|
#include <pulsecore/socket-util.h>
|
||||||
#include <pulsecore/once.h>
|
#include <pulsecore/once.h>
|
||||||
|
#include <pulsecore/poll.h>
|
||||||
|
|
||||||
#include "module-rtp-recv-symdef.h"
|
#include "module-rtp-recv-symdef.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,6 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_UN_H
|
#ifdef HAVE_SYS_UN_H
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -57,9 +54,7 @@
|
||||||
#include <pulse/mainloop.h>
|
#include <pulse/mainloop.h>
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
|
|
||||||
#include <pulsecore/winsock.h>
|
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
|
|
||||||
#include <pulsecore/native-common.h>
|
#include <pulsecore/native-common.h>
|
||||||
#include <pulsecore/pdispatch.h>
|
#include <pulsecore/pdispatch.h>
|
||||||
#include <pulsecore/pstream.h>
|
#include <pulsecore/pstream.h>
|
||||||
|
|
@ -69,6 +64,7 @@
|
||||||
#include <pulsecore/core-rtclock.h>
|
#include <pulsecore/core-rtclock.h>
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
|
#include <pulsecore/socket.h>
|
||||||
#include <pulsecore/socket-util.h>
|
#include <pulsecore/socket-util.h>
|
||||||
#include <pulsecore/creds.h>
|
#include <pulsecore/creds.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
|
|
@ -589,10 +585,12 @@ static char *get_old_legacy_runtime_dir(void) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_GETUID
|
||||||
if (st.st_uid != getuid()) {
|
if (st.st_uid != getuid()) {
|
||||||
pa_xfree(p);
|
pa_xfree(p);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
@ -611,10 +609,12 @@ static char *get_very_old_legacy_runtime_dir(void) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_GETUID
|
||||||
if (st.st_uid != getuid()) {
|
if (st.st_uid != getuid()) {
|
||||||
pa_xfree(p);
|
pa_xfree(p);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
@ -1001,6 +1001,7 @@ int pa_context_connect(
|
||||||
/* Set up autospawning */
|
/* Set up autospawning */
|
||||||
if (!(flags & PA_CONTEXT_NOAUTOSPAWN) && c->conf->autospawn) {
|
if (!(flags & PA_CONTEXT_NOAUTOSPAWN) && c->conf->autospawn) {
|
||||||
|
|
||||||
|
#ifdef HAVE_GETUID
|
||||||
if (getuid() == 0)
|
if (getuid() == 0)
|
||||||
pa_log_debug("Not doing autospawn since we are root.");
|
pa_log_debug("Not doing autospawn since we are root.");
|
||||||
else {
|
else {
|
||||||
|
|
@ -1009,6 +1010,7 @@ int pa_context_connect(
|
||||||
if (api)
|
if (api)
|
||||||
c->spawn_api = *api;
|
c->spawn_api = *api;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_context_set_state(c, PA_CONTEXT_CONNECTING);
|
pa_context_set_state(c, PA_CONTEXT_CONNECTING);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <pulse/cdecl.h>
|
#include <pulse/cdecl.h>
|
||||||
#include <pulse/sample.h>
|
#include <pulse/sample.h>
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <pulse/cdecl.h>
|
#include <pulse/cdecl.h>
|
||||||
#include <pulse/sample.h>
|
#include <pulse/sample.h>
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
#include <pulsecore/llist.h>
|
#include <pulsecore/llist.h>
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
#include <pulsecore/winsock.h>
|
#include <pulsecore/socket.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
|
|
||||||
#include "mainloop.h"
|
#include "mainloop.h"
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <pulse/timeval.h>
|
||||||
#include <pulsecore/core-rtclock.h>
|
#include <pulsecore/core-rtclock.h>
|
||||||
|
|
||||||
#include "rtclock.h"
|
#include "rtclock.h"
|
||||||
#include "timeval.h"
|
|
||||||
|
|
||||||
pa_usec_t pa_rtclock_now(void) {
|
pa_usec_t pa_rtclock_now(void) {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,6 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef HAVE_POLL_H
|
|
||||||
#include <poll.h>
|
|
||||||
#else
|
|
||||||
#include <pulsecore/poll.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
#include <pulse/mainloop.h>
|
#include <pulse/mainloop.h>
|
||||||
#include <pulse/i18n.h>
|
#include <pulse/i18n.h>
|
||||||
|
|
@ -46,6 +40,7 @@
|
||||||
#include <pulsecore/thread.h>
|
#include <pulsecore/thread.h>
|
||||||
#include <pulsecore/mutex.h>
|
#include <pulsecore/mutex.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
|
#include <pulsecore/poll.h>
|
||||||
|
|
||||||
#include "thread-mainloop.h"
|
#include "thread-mainloop.h"
|
||||||
|
|
||||||
|
|
@ -72,7 +67,7 @@ static int poll_func(struct pollfd *ufds, unsigned long nfds, int timeout, void
|
||||||
* avahi_simple_poll_quit() can succeed from another thread. */
|
* avahi_simple_poll_quit() can succeed from another thread. */
|
||||||
|
|
||||||
pa_mutex_unlock(mutex);
|
pa_mutex_unlock(mutex);
|
||||||
r = poll(ufds, nfds, timeout);
|
r = pa_poll(ufds, nfds, timeout);
|
||||||
pa_mutex_lock(mutex);
|
pa_mutex_lock(mutex);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
|
|
||||||
|
|
@ -31,36 +31,28 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <pulsecore/winsock.h>
|
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
|
|
||||||
#include "timeval.h"
|
#include "timeval.h"
|
||||||
|
|
||||||
struct timeval *pa_gettimeofday(struct timeval *tv) {
|
struct timeval *pa_gettimeofday(struct timeval *tv) {
|
||||||
#ifdef HAVE_GETTIMEOFDAY
|
|
||||||
pa_assert(tv);
|
pa_assert(tv);
|
||||||
|
|
||||||
pa_assert_se(gettimeofday(tv, NULL) == 0);
|
#if defined(OS_IS_WIN32)
|
||||||
return tv;
|
|
||||||
#elif defined(OS_IS_WIN32)
|
|
||||||
/*
|
/*
|
||||||
* Copied from implementation by Steven Edwards (LGPL).
|
* Copied from implementation by Steven Edwards (LGPL).
|
||||||
* Found on wine mailing list.
|
* Found on wine mailing list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
#define EPOCHFILETIME (116444736000000000i64)
|
#define EPOCHFILETIME (116444736000000000i64)
|
||||||
#else
|
#else
|
||||||
#define EPOCHFILETIME (116444736000000000LL)
|
#define EPOCHFILETIME (116444736000000000LL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
LARGE_INTEGER li;
|
LARGE_INTEGER li;
|
||||||
int64_t t;
|
int64_t t;
|
||||||
|
|
||||||
pa_assert(tv);
|
|
||||||
|
|
||||||
GetSystemTimeAsFileTime(&ft);
|
GetSystemTimeAsFileTime(&ft);
|
||||||
li.LowPart = ft.dwLowDateTime;
|
li.LowPart = ft.dwLowDateTime;
|
||||||
li.HighPart = ft.dwHighDateTime;
|
li.HighPart = ft.dwHighDateTime;
|
||||||
|
|
@ -69,11 +61,13 @@ struct timeval *pa_gettimeofday(struct timeval *tv) {
|
||||||
t /= 10; /* In microseconds */
|
t /= 10; /* In microseconds */
|
||||||
tv->tv_sec = (time_t) (t / PA_USEC_PER_SEC);
|
tv->tv_sec = (time_t) (t / PA_USEC_PER_SEC);
|
||||||
tv->tv_usec = (suseconds_t) (t % PA_USEC_PER_SEC);
|
tv->tv_usec = (suseconds_t) (t % PA_USEC_PER_SEC);
|
||||||
|
#elif defined(HAVE_GETTIMEOFDAY)
|
||||||
return tv;
|
pa_assert_se(gettimeofday(tv, NULL) == 0);
|
||||||
#else
|
#else
|
||||||
#error "Platform lacks gettimeofday() or equivalent function."
|
#error "Platform lacks gettimeofday() or equivalent function."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return tv;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) {
|
pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) {
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,6 @@
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_NETDB_H
|
#ifdef HAVE_NETDB_H
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -56,7 +52,7 @@
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
|
|
||||||
#include <pulsecore/winsock.h>
|
#include <pulsecore/socket.h>
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
|
|
@ -79,11 +75,15 @@ char *pa_get_user_name(char *s, size_t l) {
|
||||||
pa_assert(s);
|
pa_assert(s);
|
||||||
pa_assert(l > 0);
|
pa_assert(l > 0);
|
||||||
|
|
||||||
if ((p = (getuid() == 0 ? "root" : NULL)) ||
|
p = NULL;
|
||||||
(p = getenv("USER")) ||
|
#ifdef HAVE_GETUID
|
||||||
(p = getenv("LOGNAME")) ||
|
p = getuid() == 0 ? "root" : NULL;
|
||||||
(p = getenv("USERNAME")))
|
#endif
|
||||||
{
|
if (!p) p = getenv("USER");
|
||||||
|
if (!p) p = getenv("LOGNAME");
|
||||||
|
if (!p) p = getenv("USERNAME");
|
||||||
|
|
||||||
|
if (p) {
|
||||||
name = pa_strlcpy(s, p, l);
|
name = pa_strlcpy(s, p, l);
|
||||||
} else {
|
} else {
|
||||||
#ifdef HAVE_PWD_H
|
#ifdef HAVE_PWD_H
|
||||||
|
|
@ -195,11 +195,11 @@ char *pa_get_binary_name(char *s, size_t l) {
|
||||||
{
|
{
|
||||||
char *rp;
|
char *rp;
|
||||||
|
|
||||||
if ((rp = pa_readlink("/proc/curproc/file"))) {
|
if ((rp = pa_readlink("/proc/curproc/file"))) {
|
||||||
pa_strlcpy(s, pa_path_get_filename(rp), l);
|
pa_strlcpy(s, pa_path_get_filename(rp), l);
|
||||||
pa_xfree(rp);
|
pa_xfree(rp);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
|
@ -151,7 +150,7 @@ static char *normalize_path(const char *fn) {
|
||||||
#ifndef OS_IS_WIN32
|
#ifndef OS_IS_WIN32
|
||||||
if (fn[0] != '/') {
|
if (fn[0] != '/') {
|
||||||
#else
|
#else
|
||||||
if (strlen(fn) < 3 || !isalpha(fn[0]) || fn[1] != ':' || fn[2] != '\\') {
|
if (strlen(fn) < 3 || !IsCharAlpha(fn[0]) || fn[1] != ':' || fn[2] != '\\') {
|
||||||
#endif
|
#endif
|
||||||
char *homedir, *s;
|
char *homedir, *s;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,20 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_WINDOWS_H
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
|
|
||||||
#include "core-rtclock.h"
|
#include "core-rtclock.h"
|
||||||
|
|
||||||
|
#ifdef OS_IS_WIN32
|
||||||
|
static int64_t counter_freq = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
pa_usec_t pa_rtclock_age(const struct timeval *tv) {
|
pa_usec_t pa_rtclock_age(const struct timeval *tv) {
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
pa_assert(tv);
|
pa_assert(tv);
|
||||||
|
|
@ -88,6 +96,17 @@ struct timeval *pa_rtclock_get(struct timeval *tv) {
|
||||||
tv->tv_usec = ts.tv_nsec / PA_NSEC_PER_USEC;
|
tv->tv_usec = ts.tv_nsec / PA_NSEC_PER_USEC;
|
||||||
|
|
||||||
return tv;
|
return tv;
|
||||||
|
#elif defined(OS_IS_WIN32)
|
||||||
|
if (counter_freq > 0) {
|
||||||
|
LARGE_INTEGER count;
|
||||||
|
|
||||||
|
pa_assert_se(QueryPerformanceCounter(&count));
|
||||||
|
|
||||||
|
tv->tv_sec = count.QuadPart / counter_freq;
|
||||||
|
tv->tv_usec = (count.QuadPart % counter_freq) * PA_USEC_PER_SEC / counter_freq;
|
||||||
|
|
||||||
|
return tv;
|
||||||
|
}
|
||||||
#endif /* HAVE_CLOCK_GETTIME */
|
#endif /* HAVE_CLOCK_GETTIME */
|
||||||
|
|
||||||
return pa_gettimeofday(tv);
|
return pa_gettimeofday(tv);
|
||||||
|
|
@ -118,6 +137,11 @@ pa_bool_t pa_rtclock_hrtimer(void) {
|
||||||
pa_assert_se(clock_getres(CLOCK_REALTIME, &ts) == 0);
|
pa_assert_se(clock_getres(CLOCK_REALTIME, &ts) == 0);
|
||||||
return ts.tv_sec == 0 && ts.tv_nsec <= (long) (PA_HRTIMER_THRESHOLD_USEC*PA_NSEC_PER_USEC);
|
return ts.tv_sec == 0 && ts.tv_nsec <= (long) (PA_HRTIMER_THRESHOLD_USEC*PA_NSEC_PER_USEC);
|
||||||
|
|
||||||
|
#elif defined(OS_IS_WIN32)
|
||||||
|
|
||||||
|
if (counter_freq > 0)
|
||||||
|
return counter_freq >= (int64_t) (PA_USEC_PER_SEC/PA_HRTIMER_THRESHOLD_USEC);
|
||||||
|
|
||||||
#endif /* HAVE_CLOCK_GETTIME */
|
#endif /* HAVE_CLOCK_GETTIME */
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
@ -148,6 +172,12 @@ void pa_rtclock_hrtimer_enable(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(OS_IS_WIN32)
|
||||||
|
LARGE_INTEGER freq;
|
||||||
|
|
||||||
|
pa_assert_se(QueryPerformanceFrequency(&freq));
|
||||||
|
counter_freq = freq.QuadPart;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,6 +204,7 @@ struct timeval* pa_rtclock_from_wallclock(struct timeval *tv) {
|
||||||
return tv;
|
return tv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CLOCK_GETTIME
|
||||||
pa_usec_t pa_timespec_load(const struct timespec *ts) {
|
pa_usec_t pa_timespec_load(const struct timespec *ts) {
|
||||||
|
|
||||||
if (PA_UNLIKELY(!ts))
|
if (PA_UNLIKELY(!ts))
|
||||||
|
|
@ -198,6 +229,7 @@ struct timespec* pa_timespec_store(struct timespec *ts, pa_usec_t v) {
|
||||||
|
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct timeval* wallclock_from_rtclock(struct timeval *tv) {
|
static struct timeval* wallclock_from_rtclock(struct timeval *tv) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,10 @@ void pa_rtclock_hrtimer_enable(void);
|
||||||
|
|
||||||
struct timeval* pa_rtclock_from_wallclock(struct timeval *tv);
|
struct timeval* pa_rtclock_from_wallclock(struct timeval *tv);
|
||||||
|
|
||||||
|
#ifdef HAVE_CLOCK_GETTIME
|
||||||
pa_usec_t pa_timespec_load(const struct timespec *ts);
|
pa_usec_t pa_timespec_load(const struct timespec *ts);
|
||||||
struct timespec* pa_timespec_store(struct timespec *ts, pa_usec_t v);
|
struct timespec* pa_timespec_store(struct timespec *ts, pa_usec_t v);
|
||||||
|
#endif
|
||||||
|
|
||||||
struct timeval* pa_timeval_rtstore(struct timeval *tv, pa_usec_t v, pa_bool_t rtclock);
|
struct timeval* pa_timeval_rtstore(struct timeval *tv, pa_usec_t v, pa_bool_t rtclock);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,16 +34,24 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <time.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <regex.h>
|
|
||||||
|
#ifdef HAVE_LANGINFO_H
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNAME
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <sys/socket.h>
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_REGEX_H)
|
||||||
|
#include <regex.h>
|
||||||
|
#elif defined(HAVE_PCREPOSIX_H)
|
||||||
|
#include <pcreposix.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_STRTOF_L
|
#ifdef HAVE_STRTOF_L
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
@ -81,6 +89,10 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef ENOTSUP
|
||||||
|
#define ENOTSUP 135
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_PWD_H
|
#ifdef HAVE_PWD_H
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -110,7 +122,7 @@
|
||||||
#include <pulse/utf8.h>
|
#include <pulse/utf8.h>
|
||||||
|
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
#include <pulsecore/winsock.h>
|
#include <pulsecore/socket.h>
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
#include <pulsecore/thread.h>
|
#include <pulsecore/thread.h>
|
||||||
|
|
@ -118,6 +130,7 @@
|
||||||
#include <pulsecore/usergroup.h>
|
#include <pulsecore/usergroup.h>
|
||||||
#include <pulsecore/strlist.h>
|
#include <pulsecore/strlist.h>
|
||||||
#include <pulsecore/cpu-x86.h>
|
#include <pulsecore/cpu-x86.h>
|
||||||
|
#include <pulsecore/pipe.h>
|
||||||
|
|
||||||
#include "core-util.h"
|
#include "core-util.h"
|
||||||
|
|
||||||
|
|
@ -136,20 +149,18 @@ static pa_strlist *recorded_env = NULL;
|
||||||
#define PULSE_ROOTENV "PULSE_ROOT"
|
#define PULSE_ROOTENV "PULSE_ROOT"
|
||||||
|
|
||||||
int pa_set_root(HANDLE handle) {
|
int pa_set_root(HANDLE handle) {
|
||||||
char library_path[MAX_PATH + sizeof(PULSE_ROOTENV) + 1], *sep;
|
char library_path[MAX_PATH], *sep;
|
||||||
|
|
||||||
strcpy(library_path, PULSE_ROOTENV "=");
|
|
||||||
|
|
||||||
/* FIXME: Needs to set errno */
|
/* FIXME: Needs to set errno */
|
||||||
|
|
||||||
if (!GetModuleFileName(handle, library_path + sizeof(PULSE_ROOTENV), MAX_PATH))
|
if (!GetModuleFileName(handle, library_path, MAX_PATH))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
sep = strrchr(library_path, PA_PATH_SEP_CHAR);
|
sep = strrchr(library_path, PA_PATH_SEP_CHAR);
|
||||||
if (sep)
|
if (sep)
|
||||||
*sep = '\0';
|
*sep = '\0';
|
||||||
|
|
||||||
if (_putenv(library_path) < 0)
|
if (!SetEnvironmentVariable(PULSE_ROOTENV, library_path))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -217,7 +228,7 @@ int pa_make_secure_dir(const char* dir, mode_t m, uid_t uid, gid_t gid) {
|
||||||
if (r < 0 && errno != EEXIST)
|
if (r < 0 && errno != EEXIST)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
#ifdef HAVE_FSTAT
|
#if defined(HAVE_FSTAT) && !defined(OS_IS_WIN32)
|
||||||
if ((fd = open(dir,
|
if ((fd = open(dir,
|
||||||
#ifdef O_CLOEXEC
|
#ifdef O_CLOEXEC
|
||||||
O_CLOEXEC|
|
O_CLOEXEC|
|
||||||
|
|
@ -255,7 +266,6 @@ int pa_make_secure_dir(const char* dir, mode_t m, uid_t uid, gid_t gid) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pa_assert_se(pa_close(fd) >= 0);
|
pa_assert_se(pa_close(fd) >= 0);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LSTAT
|
#ifdef HAVE_LSTAT
|
||||||
|
|
@ -611,6 +621,7 @@ char *pa_strlcpy(char *b, const char *s, size_t l) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_scheduler(int rtprio) {
|
static int set_scheduler(int rtprio) {
|
||||||
|
#ifdef HAVE_SCHED_H
|
||||||
struct sched_param sp;
|
struct sched_param sp;
|
||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
int r;
|
int r;
|
||||||
|
|
@ -634,6 +645,7 @@ static int set_scheduler(int rtprio) {
|
||||||
pa_log_debug("SCHED_RR worked.");
|
pa_log_debug("SCHED_RR worked.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif /* HAVE_SCHED_H */
|
||||||
|
|
||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
/* Try to talk to RealtimeKit */
|
/* Try to talk to RealtimeKit */
|
||||||
|
|
@ -684,14 +696,21 @@ int pa_make_realtime(int rtprio) {
|
||||||
pa_log_info("Successfully enabled SCHED_RR scheduling for thread, with priority %i, which is lower than the requested %i.", p, rtprio);
|
pa_log_info("Successfully enabled SCHED_RR scheduling for thread, with priority %i, which is lower than the requested %i.", p, rtprio);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#elif defined(OS_IS_WIN32)
|
||||||
|
/* Windows only allows realtime scheduling to be set on a per process basis.
|
||||||
|
* Therefore, instead of making the thread realtime, just give it the highest non-realtime priority. */
|
||||||
|
if(SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL)) {
|
||||||
|
pa_log_info("Successfully enabled THREAD_PRIORITY_TIME_CRITICAL scheduling for thread.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_log_warn("SetThreadPriority() failed: 0x%08X", GetLastError());
|
||||||
|
errno = EPERM;
|
||||||
|
#else
|
||||||
|
errno = ENOTSUP;
|
||||||
|
#endif
|
||||||
pa_log_info("Failed to acquire real-time scheduling: %s", pa_cstrerror(errno));
|
pa_log_info("Failed to acquire real-time scheduling: %s", pa_cstrerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
#else
|
|
||||||
|
|
||||||
errno = ENOTSUP;
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_nice(int nice_level) {
|
static int set_nice(int nice_level) {
|
||||||
|
|
@ -703,10 +722,12 @@ static int set_nice(int nice_level) {
|
||||||
dbus_error_init(&error);
|
dbus_error_init(&error);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_RESOURCE_H
|
||||||
if (setpriority(PRIO_PROCESS, 0, nice_level) >= 0) {
|
if (setpriority(PRIO_PROCESS, 0, nice_level) >= 0) {
|
||||||
pa_log_debug("setpriority() worked.");
|
pa_log_debug("setpriority() worked.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
/* Try to talk to RealtimeKit */
|
/* Try to talk to RealtimeKit */
|
||||||
|
|
@ -827,6 +848,7 @@ int pa_parse_boolean(const char *v) {
|
||||||
else if (!strcmp(v, "0") || v[0] == 'n' || v[0] == 'N' || v[0] == 'f' || v[0] == 'F' || !strcasecmp(v, "off"))
|
else if (!strcmp(v, "0") || v[0] == 'n' || v[0] == 'N' || v[0] == 'f' || v[0] == 'F' || !strcasecmp(v, "off"))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
#ifdef HAVE_LANGINFO_H
|
||||||
/* And then we check language dependant */
|
/* And then we check language dependant */
|
||||||
if ((expr = nl_langinfo(YESEXPR)))
|
if ((expr = nl_langinfo(YESEXPR)))
|
||||||
if (expr[0])
|
if (expr[0])
|
||||||
|
|
@ -837,6 +859,7 @@ int pa_parse_boolean(const char *v) {
|
||||||
if (expr[0])
|
if (expr[0])
|
||||||
if (pa_match(expr, v) > 0)
|
if (pa_match(expr, v) > 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -1150,23 +1173,23 @@ int pa_check_in_group(gid_t g) {
|
||||||
#else /* HAVE_GRP_H */
|
#else /* HAVE_GRP_H */
|
||||||
|
|
||||||
int pa_own_uid_in_group(const char *name, gid_t *gid) {
|
int pa_own_uid_in_group(const char *name, gid_t *gid) {
|
||||||
errno = ENOSUP;
|
errno = ENOTSUP;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_uid_in_group(uid_t uid, const char *name) {
|
int pa_uid_in_group(uid_t uid, const char *name) {
|
||||||
errno = ENOSUP;
|
errno = ENOTSUP;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gid_t pa_get_gid_of_group(const char *name) {
|
gid_t pa_get_gid_of_group(const char *name) {
|
||||||
errno = ENOSUP;
|
errno = ENOTSUP;
|
||||||
return (gid_t) -1;
|
return (gid_t) -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_check_in_group(gid_t g) {
|
int pa_check_in_group(gid_t g) {
|
||||||
errno = ENOSUP;
|
errno = ENOTSUP;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1339,11 +1362,13 @@ static char *get_pulse_home(void) {
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_GETUID
|
||||||
if (st.st_uid != getuid()) {
|
if (st.st_uid != getuid()) {
|
||||||
pa_log_error("Home directory %s not ours.", h);
|
pa_log_error("Home directory %s not ours.", h);
|
||||||
errno = EACCES;
|
errno = EACCES;
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse", h);
|
ret = pa_sprintf_malloc("%s" PA_PATH_SEP ".pulse", h);
|
||||||
|
|
||||||
|
|
@ -1441,7 +1466,11 @@ static char* make_random_dir(mode_t m) {
|
||||||
fn[i] = table[rand() % (sizeof(table)-1)];
|
fn[i] = table[rand() % (sizeof(table)-1)];
|
||||||
|
|
||||||
u = umask((~m) & 0777);
|
u = umask((~m) & 0777);
|
||||||
|
#ifndef OS_IS_WIN32
|
||||||
r = mkdir(fn, m);
|
r = mkdir(fn, m);
|
||||||
|
#else
|
||||||
|
r = mkdir(fn);
|
||||||
|
#endif
|
||||||
|
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
umask(u);
|
umask(u);
|
||||||
|
|
@ -1464,6 +1493,7 @@ static int make_random_dir_and_link(mode_t m, const char *k) {
|
||||||
if (!(p = make_random_dir(m)))
|
if (!(p = make_random_dir(m)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
#ifdef HAVE_SYMLINK
|
||||||
if (symlink(p, k) < 0) {
|
if (symlink(p, k) < 0) {
|
||||||
int saved_errno = errno;
|
int saved_errno = errno;
|
||||||
|
|
||||||
|
|
@ -1476,6 +1506,10 @@ static int make_random_dir_and_link(mode_t m, const char *k) {
|
||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
pa_xfree(p);
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
pa_xfree(p);
|
pa_xfree(p);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1534,6 +1568,7 @@ char *pa_get_runtime_dir(void) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_SYMLINK
|
||||||
/* Hmm, so the runtime directory didn't exist yet, so let's
|
/* Hmm, so the runtime directory didn't exist yet, so let's
|
||||||
* create one in /tmp and symlink that to it */
|
* create one in /tmp and symlink that to it */
|
||||||
|
|
||||||
|
|
@ -1546,6 +1581,11 @@ char *pa_get_runtime_dir(void) {
|
||||||
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
/* No symlink possible, so let's just create the runtime directly */
|
||||||
|
if (!mkdir(k))
|
||||||
|
goto fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
@ -1560,6 +1600,7 @@ char *pa_get_runtime_dir(void) {
|
||||||
/* Hmm, so this symlink is still around, make sure nobody fools
|
/* Hmm, so this symlink is still around, make sure nobody fools
|
||||||
* us */
|
* us */
|
||||||
|
|
||||||
|
#ifdef HAVE_LSTAT
|
||||||
if (lstat(p, &st) < 0) {
|
if (lstat(p, &st) < 0) {
|
||||||
|
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
|
|
@ -1579,6 +1620,7 @@ char *pa_get_runtime_dir(void) {
|
||||||
|
|
||||||
pa_log_info("Hmm, runtime path exists, but points to an invalid directory. Changing runtime directory.");
|
pa_log_info("Hmm, runtime path exists, but points to an invalid directory. Changing runtime directory.");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
pa_xfree(p);
|
pa_xfree(p);
|
||||||
p = NULL;
|
p = NULL;
|
||||||
|
|
@ -2218,6 +2260,7 @@ void pa_close_pipe(int fds[2]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pa_readlink(const char *p) {
|
char *pa_readlink(const char *p) {
|
||||||
|
#ifdef HAVE_READLINK
|
||||||
size_t l = 100;
|
size_t l = 100;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
@ -2239,6 +2282,9 @@ char *pa_readlink(const char *p) {
|
||||||
pa_xfree(c);
|
pa_xfree(c);
|
||||||
l *= 2;
|
l *= 2;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_close_all(int except_fd, ...) {
|
int pa_close_all(int except_fd, ...) {
|
||||||
|
|
@ -2277,6 +2323,7 @@ int pa_close_all(int except_fd, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_close_allv(const int except_fds[]) {
|
int pa_close_allv(const int except_fds[]) {
|
||||||
|
#ifndef OS_IS_WIN32
|
||||||
struct rlimit rl;
|
struct rlimit rl;
|
||||||
int maxfd, fd;
|
int maxfd, fd;
|
||||||
|
|
||||||
|
|
@ -2366,6 +2413,7 @@ int pa_close_allv(const int except_fds[]) {
|
||||||
if (pa_close(fd) < 0 && errno != EBADF)
|
if (pa_close(fd) < 0 && errno != EBADF)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif /* !OS_IS_WIN32 */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2406,6 +2454,7 @@ int pa_unblock_sigs(int except, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_unblock_sigsv(const int except[]) {
|
int pa_unblock_sigsv(const int except[]) {
|
||||||
|
#ifndef OS_IS_WIN32
|
||||||
int i;
|
int i;
|
||||||
sigset_t ss;
|
sigset_t ss;
|
||||||
|
|
||||||
|
|
@ -2417,6 +2466,9 @@ int pa_unblock_sigsv(const int except[]) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return sigprocmask(SIG_SETMASK, &ss, NULL);
|
return sigprocmask(SIG_SETMASK, &ss, NULL);
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_reset_sigs(int except, ...) {
|
int pa_reset_sigs(int except, ...) {
|
||||||
|
|
@ -2455,6 +2507,7 @@ int pa_reset_sigs(int except, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_reset_sigsv(const int except[]) {
|
int pa_reset_sigsv(const int except[]) {
|
||||||
|
#ifndef OS_IS_WIN32
|
||||||
int sig;
|
int sig;
|
||||||
|
|
||||||
for (sig = 1; sig < NSIG; sig++) {
|
for (sig = 1; sig < NSIG; sig++) {
|
||||||
|
|
@ -2491,6 +2544,7 @@ int pa_reset_sigsv(const int except[]) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2501,7 +2555,11 @@ void pa_set_env(const char *key, const char *value) {
|
||||||
|
|
||||||
/* This is not thread-safe */
|
/* This is not thread-safe */
|
||||||
|
|
||||||
putenv(pa_sprintf_malloc("%s=%s", key, value));
|
#ifdef OS_IS_WIN32
|
||||||
|
SetEnvironmentVariable(key, value);
|
||||||
|
#else
|
||||||
|
setenv(key, value, 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void pa_set_env_and_record(const char *key, const char *value) {
|
void pa_set_env_and_record(const char *key, const char *value) {
|
||||||
|
|
@ -2526,7 +2584,11 @@ void pa_unset_env_recorded(void) {
|
||||||
if (!s)
|
if (!s)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef OS_IS_WIN32
|
||||||
|
SetEnvironmentVariable(s, NULL);
|
||||||
|
#else
|
||||||
unsetenv(s);
|
unsetenv(s);
|
||||||
|
#endif
|
||||||
pa_xfree(s);
|
pa_xfree(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2625,9 +2687,13 @@ char *pa_machine_id(void) {
|
||||||
if ((h = pa_get_host_name_malloc()))
|
if ((h = pa_get_host_name_malloc()))
|
||||||
return h;
|
return h;
|
||||||
|
|
||||||
|
#ifndef OS_IS_WIN32
|
||||||
/* If no hostname was set we use the POSIX hostid. It's usually
|
/* If no hostname was set we use the POSIX hostid. It's usually
|
||||||
* the IPv4 address. Might not be that stable. */
|
* the IPv4 address. Might not be that stable. */
|
||||||
return pa_sprintf_malloc("%08lx", (unsigned long) gethostid);
|
return pa_sprintf_malloc("%08lx", (unsigned long) gethostid);
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pa_session_id(void) {
|
char *pa_session_id(void) {
|
||||||
|
|
@ -2640,11 +2706,22 @@ char *pa_session_id(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pa_uname_string(void) {
|
char *pa_uname_string(void) {
|
||||||
|
#ifdef HAVE_UNAME
|
||||||
struct utsname u;
|
struct utsname u;
|
||||||
|
|
||||||
pa_assert_se(uname(&u) >= 0);
|
pa_assert_se(uname(&u) >= 0);
|
||||||
|
|
||||||
return pa_sprintf_malloc("%s %s %s %s", u.sysname, u.machine, u.release, u.version);
|
return pa_sprintf_malloc("%s %s %s %s", u.sysname, u.machine, u.release, u.version);
|
||||||
|
#endif
|
||||||
|
#ifdef OS_IS_WIN32
|
||||||
|
OSVERSIONINFO i;
|
||||||
|
|
||||||
|
pa_zero(i);
|
||||||
|
i.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
|
pa_assert_se(GetVersionEx(&i));
|
||||||
|
|
||||||
|
return pa_sprintf_malloc("Windows %d.%d (%d) %s", i.dwMajorVersion, i.dwMinorVersion, i.dwBuildNumber, i.szCSDVersion);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_VALGRIND_MEMCHECK_H
|
#ifdef HAVE_VALGRIND_MEMCHECK_H
|
||||||
|
|
@ -2793,10 +2870,17 @@ char *pa_realpath(const char *path) {
|
||||||
char *path_buf;
|
char *path_buf;
|
||||||
path_buf = pa_xmalloc(PATH_MAX);
|
path_buf = pa_xmalloc(PATH_MAX);
|
||||||
|
|
||||||
|
#if defined(OS_IS_WIN32)
|
||||||
|
if (!(t = _fullpath(path_buf, path, _MAX_PATH))) {
|
||||||
|
pa_xfree(path_buf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (!(t = realpath(path, path_buf))) {
|
if (!(t = realpath(path, path_buf))) {
|
||||||
pa_xfree(path_buf);
|
pa_xfree(path_buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#error "It's not clear whether this system supports realpath(..., NULL) like GNU libc does. If it doesn't we need a private version of realpath() here."
|
#error "It's not clear whether this system supports realpath(..., NULL) like GNU libc does. If it doesn't we need a private version of realpath() here."
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_RESOURCE_H
|
#ifdef HAVE_SYS_RESOURCE_H
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
|
@ -36,6 +35,7 @@
|
||||||
|
|
||||||
#include <pulse/gccmacro.h>
|
#include <pulse/gccmacro.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
|
#include <pulsecore/socket.h>
|
||||||
|
|
||||||
#ifndef PACKAGE
|
#ifndef PACKAGE
|
||||||
#error "Please include config.h before including this file!"
|
#error "Please include config.h before including this file!"
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,7 @@
|
||||||
#error "Please include config.h before including this file!"
|
#error "Please include config.h before including this file!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
#include <pulsecore/socket.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_UN_H
|
#ifdef HAVE_SYS_UN_H
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ static void flush(pa_fdsem *f) {
|
||||||
if (f->efd >= 0) {
|
if (f->efd >= 0) {
|
||||||
uint64_t u;
|
uint64_t u;
|
||||||
|
|
||||||
if ((r = read(f->efd, &u, sizeof(u))) != sizeof(u)) {
|
if ((r = pa_read(f->efd, &u, sizeof(u), NULL)) != sizeof(u)) {
|
||||||
|
|
||||||
if (r >= 0 || errno != EINTR) {
|
if (r >= 0 || errno != EINTR) {
|
||||||
pa_log_error("Invalid read from eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
pa_log_error("Invalid read from eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
|
|
@ -167,7 +167,7 @@ static void flush(pa_fdsem *f) {
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((r = read(f->fds[0], &x, sizeof(x))) <= 0) {
|
if ((r = pa_read(f->fds[0], &x, sizeof(x), NULL)) <= 0) {
|
||||||
|
|
||||||
if (r >= 0 || errno != EINTR) {
|
if (r >= 0 || errno != EINTR) {
|
||||||
pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
|
|
@ -197,9 +197,9 @@ void pa_fdsem_post(pa_fdsem *f) {
|
||||||
if (f->efd >= 0) {
|
if (f->efd >= 0) {
|
||||||
uint64_t u = 1;
|
uint64_t u = 1;
|
||||||
|
|
||||||
if ((r = write(f->efd, &u, sizeof(u))) != sizeof(u)) {
|
if ((r = pa_write(f->efd, &u, sizeof(u), NULL)) != sizeof(u)) {
|
||||||
if (r >= 0 || errno != EINTR) {
|
if (r >= 0 || errno != EINTR) {
|
||||||
pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
pa_log_error("Invalid write to eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
pa_assert_not_reached();
|
pa_assert_not_reached();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -208,9 +208,9 @@ void pa_fdsem_post(pa_fdsem *f) {
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((r = write(f->fds[1], &x, 1)) != 1) {
|
if ((r = pa_write(f->fds[1], &x, 1, NULL)) != 1) {
|
||||||
if (r >= 0 || errno != EINTR) {
|
if (r >= 0 || errno != EINTR) {
|
||||||
pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
pa_log_error("Invalid write to pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
pa_assert_not_reached();
|
pa_assert_not_reached();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,10 +241,10 @@ void pa_fdsem_wait(pa_fdsem *f) {
|
||||||
if (f->efd >= 0) {
|
if (f->efd >= 0) {
|
||||||
uint64_t u;
|
uint64_t u;
|
||||||
|
|
||||||
if ((r = read(f->efd, &u, sizeof(u))) != sizeof(u)) {
|
if ((r = pa_read(f->efd, &u, sizeof(u), NULL)) != sizeof(u)) {
|
||||||
|
|
||||||
if (r >= 0 || errno != EINTR) {
|
if (r >= 0 || errno != EINTR) {
|
||||||
pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
pa_log_error("Invalid read from eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
pa_assert_not_reached();
|
pa_assert_not_reached();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -255,7 +255,7 @@ void pa_fdsem_wait(pa_fdsem *f) {
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((r = read(f->fds[0], &x, sizeof(x))) <= 0) {
|
if ((r = pa_read(f->fds[0], &x, sizeof(x), NULL)) <= 0) {
|
||||||
|
|
||||||
if (r >= 0 || errno != EINTR) {
|
if (r >= 0 || errno != EINTR) {
|
||||||
pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,9 @@
|
||||||
|
|
||||||
#ifndef HAVE_INET_NTOP
|
#ifndef HAVE_INET_NTOP
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
#include <pulsecore/core-util.h>
|
||||||
#include <sys/socket.h>
|
#include <pulsecore/macro.h>
|
||||||
#endif
|
#include <pulsecore/socket.h>
|
||||||
|
|
||||||
#include "winsock.h"
|
|
||||||
|
|
||||||
#include "inet_ntop.h"
|
#include "inet_ntop.h"
|
||||||
|
|
||||||
|
|
@ -42,7 +40,8 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) {
|
||||||
struct in6_addr *in6 = (struct in6_addr*)src;
|
struct in6_addr *in6 = (struct in6_addr*)src;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert(src && dst);
|
pa_assert(src);
|
||||||
|
pa_assert(dst);
|
||||||
|
|
||||||
switch (af) {
|
switch (af) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
#ifndef fooinet_ntophfoo
|
#ifndef fooinet_ntophfoo
|
||||||
#define fooinet_ntophfoo
|
#define fooinet_ntophfoo
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
#ifndef HAVE_INET_NTOP
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "winsock.h"
|
#include <pulsecore/socket.h>
|
||||||
|
|
||||||
const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt);
|
const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,8 @@
|
||||||
|
|
||||||
#ifndef HAVE_INET_PTON
|
#ifndef HAVE_INET_PTON
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
#include <pulsecore/macro.h>
|
||||||
#include <sys/socket.h>
|
#include <pulsecore/socket.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "winsock.h"
|
|
||||||
|
|
||||||
#include "inet_pton.h"
|
#include "inet_pton.h"
|
||||||
|
|
||||||
|
|
@ -42,7 +39,8 @@ int inet_pton(int af, const char *src, void *dst) {
|
||||||
struct in6_addr *in6 = (struct in6_addr*)dst;
|
struct in6_addr *in6 = (struct in6_addr*)dst;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert(src && dst);
|
pa_assert(src);
|
||||||
|
pa_assert(dst);
|
||||||
|
|
||||||
switch (af) {
|
switch (af) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
#ifndef fooinet_ptonhfoo
|
#ifndef fooinet_ptonhfoo
|
||||||
#define fooinet_ptonhfoo
|
#define fooinet_ptonhfoo
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
#ifndef HAVE_INET_PTON
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "winsock.h"
|
#include <pulsecore/socket.h>
|
||||||
|
|
||||||
int inet_pton(int af, const char *src, void *dst);
|
int inet_pton(int af, const char *src, void *dst);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -28,19 +28,16 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_UN_H
|
#ifdef HAVE_SYS_UN_H
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "winsock.h"
|
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
|
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
|
#include <pulsecore/socket.h>
|
||||||
#include <pulsecore/socket-util.h>
|
#include <pulsecore/socket-util.h>
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
|
|
||||||
#include <pulsecore/winsock.h>
|
#include <pulsecore/socket.h>
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,6 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
#ifdef HAVE_NETINET_IN_H
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -50,10 +47,10 @@
|
||||||
#include <pulsecore/llist.h>
|
#include <pulsecore/llist.h>
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
#include <pulsecore/winsock.h>
|
#include <pulsecore/socket.h>
|
||||||
|
|
||||||
#ifndef HAVE_INET_PTON
|
#ifndef HAVE_INET_PTON
|
||||||
#include "inet_pton.h"
|
#include <pulsecore/inet_pton.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ipacl.h"
|
#include "ipacl.h"
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,11 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/poll.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_PTHREAD
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <pulse/i18n.h>
|
#include <pulse/i18n.h>
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
|
|
@ -159,7 +161,7 @@ static void ping(void) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char x = 'x';
|
char x = 'x';
|
||||||
|
|
||||||
if ((s = write(pipe_fd[1], &x, 1)) == 1)
|
if ((s = pa_write(pipe_fd[1], &x, 1, NULL)) == 1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pa_assert(s < 0);
|
pa_assert(s < 0);
|
||||||
|
|
@ -186,7 +188,7 @@ static void wait_for_ping(void) {
|
||||||
if ((k = pa_poll(&pfd, 1, -1)) != 1) {
|
if ((k = pa_poll(&pfd, 1, -1)) != 1) {
|
||||||
pa_assert(k < 0);
|
pa_assert(k < 0);
|
||||||
pa_assert(errno == EINTR);
|
pa_assert(errno == EINTR);
|
||||||
} else if ((s = read(pipe_fd[0], &x, 1)) != 1) {
|
} else if ((s = pa_read(pipe_fd[0], &x, 1, NULL)) != 1) {
|
||||||
pa_assert(s < 0);
|
pa_assert(s < 0);
|
||||||
pa_assert(errno == EAGAIN);
|
pa_assert(errno == EAGAIN);
|
||||||
}
|
}
|
||||||
|
|
@ -198,7 +200,7 @@ static void empty_pipe(void) {
|
||||||
|
|
||||||
pa_assert(pipe_fd[0] >= 0);
|
pa_assert(pipe_fd[0] >= 0);
|
||||||
|
|
||||||
if ((s = read(pipe_fd[0], &x, sizeof(x))) < 1) {
|
if ((s = pa_read(pipe_fd[0], &x, sizeof(x), NULL)) < 1) {
|
||||||
pa_assert(s < 0);
|
pa_assert(s < 0);
|
||||||
pa_assert(errno == EAGAIN);
|
pa_assert(errno == EAGAIN);
|
||||||
}
|
}
|
||||||
|
|
@ -207,11 +209,14 @@ static void empty_pipe(void) {
|
||||||
static void thread_func(void *u) {
|
static void thread_func(void *u) {
|
||||||
int fd;
|
int fd;
|
||||||
char *lf;
|
char *lf;
|
||||||
|
|
||||||
|
#ifdef HAVE_PTHREAD
|
||||||
sigset_t fullset;
|
sigset_t fullset;
|
||||||
|
|
||||||
/* No signals in this thread please */
|
/* No signals in this thread please */
|
||||||
sigfillset(&fullset);
|
sigfillset(&fullset);
|
||||||
pthread_sigmask(SIG_BLOCK, &fullset, NULL);
|
pthread_sigmask(SIG_BLOCK, &fullset, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!(lf = pa_runtime_path(AUTOSPAWN_LOCK))) {
|
if (!(lf = pa_runtime_path(AUTOSPAWN_LOCK))) {
|
||||||
pa_log_warn(_("Cannot access autospawn lock."));
|
pa_log_warn(_("Cannot access autospawn lock."));
|
||||||
|
|
|
||||||
|
|
@ -374,6 +374,9 @@ void pa_log_levelv_meta(
|
||||||
fprintf(stderr, "%s%c: %s%s%s%s%s%s\n", timestamp, level_to_char[level], location, prefix, t, grey, pa_strempty(bt), suffix);
|
fprintf(stderr, "%s%c: %s%s%s%s%s%s\n", timestamp, level_to_char[level], location, prefix, t, grey, pa_strempty(bt), suffix);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "%s%s%s%s%s%s%s\n", timestamp, location, prefix, t, grey, pa_strempty(bt), suffix);
|
fprintf(stderr, "%s%s%s%s%s%s%s\n", timestamp, location, prefix, t, grey, pa_strempty(bt), suffix);
|
||||||
|
#ifdef OS_IS_WIN32
|
||||||
|
fflush(stderr);
|
||||||
|
#endif
|
||||||
|
|
||||||
pa_xfree(local_t);
|
pa_xfree(local_t);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,6 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_MMAN_H
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This is deprecated on glibc but is still used by FreeBSD */
|
/* This is deprecated on glibc but is still used by FreeBSD */
|
||||||
#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
|
#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
|
||||||
|
|
@ -68,6 +71,7 @@ static void sigsafe_error(const char *s) {
|
||||||
(void) write(STDERR_FILENO, s, strlen(s));
|
(void) write(STDERR_FILENO, s, strlen(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_SIGACTION
|
||||||
static void signal_handler(int sig, siginfo_t* si, void *data) {
|
static void signal_handler(int sig, siginfo_t* si, void *data) {
|
||||||
unsigned j;
|
unsigned j;
|
||||||
pa_memtrap *m;
|
pa_memtrap *m;
|
||||||
|
|
@ -102,6 +106,7 @@ fail:
|
||||||
sigsafe_error("Failed to handle SIGBUS.\n");
|
sigsafe_error("Failed to handle SIGBUS.\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void memtrap_link(pa_memtrap *m, unsigned j) {
|
static void memtrap_link(pa_memtrap *m, unsigned j) {
|
||||||
pa_assert(m);
|
pa_assert(m);
|
||||||
|
|
@ -221,6 +226,7 @@ unlock:
|
||||||
}
|
}
|
||||||
|
|
||||||
void pa_memtrap_install(void) {
|
void pa_memtrap_install(void) {
|
||||||
|
#ifdef HAVE_SIGACTION
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
||||||
allocate_aupdate();
|
allocate_aupdate();
|
||||||
|
|
@ -230,4 +236,5 @@ void pa_memtrap_install(void) {
|
||||||
sa.sa_flags = SA_RESTART|SA_SIGINFO;
|
sa.sa_flags = SA_RESTART|SA_SIGINFO;
|
||||||
|
|
||||||
pa_assert_se(sigaction(SIGBUS, &sa, NULL) == 0);
|
pa_assert_se(sigaction(SIGBUS, &sa, NULL) == 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ void pa_cond_signal(pa_cond *c, int broadcast) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (broadcast)
|
if (broadcast)
|
||||||
SetEvent(pa_hashmap_get_first(c->wait_events));
|
SetEvent(pa_hashmap_first(c->wait_events));
|
||||||
else {
|
else {
|
||||||
void *iter;
|
void *iter;
|
||||||
const void *key;
|
const void *key;
|
||||||
|
|
@ -131,3 +131,26 @@ int pa_cond_wait(pa_cond *c, pa_mutex *m) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This is a copy of the function in mutex-posix.c */
|
||||||
|
pa_mutex* pa_static_mutex_get(pa_static_mutex *s, pa_bool_t recursive, pa_bool_t inherit_priority) {
|
||||||
|
pa_mutex *m;
|
||||||
|
|
||||||
|
pa_assert(s);
|
||||||
|
|
||||||
|
/* First, check if already initialized and short cut */
|
||||||
|
if ((m = pa_atomic_ptr_load(&s->ptr)))
|
||||||
|
return m;
|
||||||
|
|
||||||
|
/* OK, not initialized, so let's allocate, and fill in */
|
||||||
|
m = pa_mutex_new(recursive, inherit_priority);
|
||||||
|
if ((pa_atomic_ptr_cmpxchg(&s->ptr, NULL, m)))
|
||||||
|
return m;
|
||||||
|
|
||||||
|
pa_mutex_free(m);
|
||||||
|
|
||||||
|
/* Him, filling in failed, so someone else must have filled in
|
||||||
|
* already */
|
||||||
|
pa_assert_se(m = pa_atomic_ptr_load(&s->ptr));
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,14 +25,17 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_ARPA_INET_H
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <sys/socket.h>
|
#endif
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
#include <pulse/util.h>
|
#include <pulse/util.h>
|
||||||
|
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
|
#include <pulsecore/inet_pton.h>
|
||||||
|
|
||||||
#include "parseaddr.h"
|
#include "parseaddr.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,8 @@
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
#include <pulsecore/socket.h>
|
||||||
#include <sys/socket.h>
|
#include <pulsecore/core-util.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "winsock.h"
|
|
||||||
|
|
||||||
#include "pipe.h"
|
#include "pipe.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,7 @@
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "winsock.h"
|
#include <pulsecore/socket.h>
|
||||||
|
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
#include <pulse/util.h>
|
#include <pulse/util.h>
|
||||||
|
|
||||||
|
|
@ -187,11 +186,11 @@ int pa_poll (struct pollfd *fds, unsigned long int nfds, int timeout) {
|
||||||
* connected socket, a server socket, or something else using a
|
* connected socket, a server socket, or something else using a
|
||||||
* 0-byte recv, and use ioctl(2) to detect POLLHUP. */
|
* 0-byte recv, and use ioctl(2) to detect POLLHUP. */
|
||||||
r = recv(f->fd, NULL, 0, MSG_PEEK);
|
r = recv(f->fd, NULL, 0, MSG_PEEK);
|
||||||
if (r == 0 || (r < 0 && errno == ENOTSOCK))
|
if (r == 0 || (r < 0 && errno == ENOTSOCK))
|
||||||
ioctl(f->fd, FIONREAD, &r);
|
ioctl(f->fd, FIONREAD, &r);
|
||||||
|
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
f->revents |= POLLHUP;
|
f->revents |= POLLHUP;
|
||||||
#else /* !OS_IS_DARWIN */
|
#else /* !OS_IS_DARWIN */
|
||||||
if (recv (f->fd, data, 64, MSG_PEEK) == -1) {
|
if (recv (f->fd, data, 64, MSG_PEEK) == -1) {
|
||||||
if (errno == ESHUTDOWN || errno == ECONNRESET ||
|
if (errno == ESHUTDOWN || errno == ECONNRESET ||
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <dlfcn.h>
|
#include <libintl.h>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <crt_externs.h>
|
#include <crt_externs.h>
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_UN_H
|
#ifdef HAVE_SYS_UN_H
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -38,10 +35,9 @@
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
|
|
||||||
#include <pulsecore/winsock.h>
|
#include <pulsecore/socket.h>
|
||||||
#include <pulsecore/queue.h>
|
#include <pulsecore/queue.h>
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
#include <pulsecore/core-scache.h>
|
#include <pulsecore/core-scache.h>
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,11 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_WINDOWS_H
|
||||||
|
#include <windows.h>
|
||||||
|
#include <wincrypt.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
|
|
@ -43,10 +48,20 @@ static const char * const devices[] = { "/dev/urandom", "/dev/random", NULL };
|
||||||
|
|
||||||
static int random_proper(void *ret_data, size_t length) {
|
static int random_proper(void *ret_data, size_t length) {
|
||||||
#ifdef OS_IS_WIN32
|
#ifdef OS_IS_WIN32
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
pa_assert(ret_data);
|
pa_assert(ret_data);
|
||||||
pa_assert(length > 0);
|
pa_assert(length > 0);
|
||||||
|
|
||||||
return -1;
|
HCRYPTPROV hCryptProv = NULL;
|
||||||
|
|
||||||
|
if (CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
|
||||||
|
if(CryptGenRandom(hCryptProv, length, ret_data))
|
||||||
|
ret = 0;
|
||||||
|
CryptReleaseContext(hCryptProv, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
#else /* OS_IS_WIN32 */
|
#else /* OS_IS_WIN32 */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@
|
||||||
#include <pulsecore/llist.h>
|
#include <pulsecore/llist.h>
|
||||||
#include <pulsecore/flist.h>
|
#include <pulsecore/flist.h>
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
#include <pulsecore/winsock.h>
|
|
||||||
#include <pulsecore/ratelimit.h>
|
#include <pulsecore/ratelimit.h>
|
||||||
#include <pulse/rtclock.h>
|
#include <pulse/rtclock.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_UN_H
|
#ifdef HAVE_SYS_UN_H
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -56,9 +53,9 @@
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
|
|
||||||
#include <pulsecore/winsock.h>
|
#include <pulsecore/socket.h>
|
||||||
#include <pulsecore/core-error.h>
|
|
||||||
#include <pulsecore/socket-util.h>
|
#include <pulsecore/socket-util.h>
|
||||||
|
#include <pulsecore/core-error.h>
|
||||||
#include <pulsecore/core-rtclock.h>
|
#include <pulsecore/core-rtclock.h>
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
#include <pulsecore/socket-util.h>
|
#include <pulsecore/socket-util.h>
|
||||||
|
|
@ -525,7 +522,7 @@ pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, pa_bool_t use_
|
||||||
if (!host)
|
if (!host)
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
pa_zero(sa);
|
pa_zero(s);
|
||||||
s.sin_family = AF_INET;
|
s.sin_family = AF_INET;
|
||||||
memcpy(&s.sin_addr, host->h_addr, sizeof(struct in_addr));
|
memcpy(&s.sin_addr, host->h_addr, sizeof(struct in_addr));
|
||||||
s.sin_port = htons(a.port);
|
s.sin_port = htons(a.port);
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_UN_H
|
#ifdef HAVE_SYS_UN_H
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#ifndef SUN_LEN
|
#ifndef SUN_LEN
|
||||||
|
|
@ -54,18 +51,16 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INET_NTOP
|
#ifndef HAVE_INET_NTOP
|
||||||
#include "inet_ntop.h"
|
#include <pulsecore/inet_ntop.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INET_PTON
|
#ifndef HAVE_INET_PTON
|
||||||
#include "inet_pton.h"
|
#include <pulsecore/inet_pton.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "winsock.h"
|
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
#include <pulse/util.h>
|
#include <pulse/util.h>
|
||||||
|
|
||||||
|
#include <pulsecore/socket.h>
|
||||||
#include <pulsecore/socket-util.h>
|
#include <pulsecore/socket-util.h>
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_UN_H
|
#ifdef HAVE_SYS_UN_H
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -62,17 +59,16 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INET_NTOP
|
#ifndef HAVE_INET_NTOP
|
||||||
#include "inet_ntop.h"
|
#include <pulsecore/inet_ntop.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "winsock.h"
|
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
|
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
|
#include <pulsecore/socket.h>
|
||||||
|
|
||||||
#include "socket-util.h"
|
#include "socket-util.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
|
#include <pulsecore/socket.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
|
|
||||||
void pa_socket_peer_to_string(int fd, char *c, size_t l);
|
void pa_socket_peer_to_string(int fd, char *c, size_t l);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
#ifndef foowinsockhfoo
|
#ifndef foopulsecoresockethfoo
|
||||||
#define foowinsockhfoo
|
#define foopulsecoresockethfoo
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_SOCKET_H
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK2_H
|
#ifdef HAVE_WINSOCK2_H
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
|
@ -14,6 +18,7 @@
|
||||||
#define ECONNREFUSED WSAECONNREFUSED
|
#define ECONNREFUSED WSAECONNREFUSED
|
||||||
#define EHOSTUNREACH WSAEHOSTUNREACH
|
#define EHOSTUNREACH WSAEHOSTUNREACH
|
||||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||||
|
#define EADDRINUSE WSAEADDRINUSE
|
||||||
|
|
||||||
typedef long suseconds_t;
|
typedef long suseconds_t;
|
||||||
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
#include <pulsecore/core-error.h>
|
#include <pulsecore/core-error.h>
|
||||||
|
#include <pulsecore/pipe.h>
|
||||||
|
|
||||||
#include "start-child.h"
|
#include "start-child.h"
|
||||||
|
|
||||||
|
|
@ -47,6 +48,7 @@ int pa_start_child_for_read(const char *name, const char *argv1, pid_t *pid) {
|
||||||
pid_t child;
|
pid_t child;
|
||||||
int pipe_fds[2] = { -1, -1 };
|
int pipe_fds[2] = { -1, -1 };
|
||||||
|
|
||||||
|
#ifdef HAVE_FORK
|
||||||
if (pipe(pipe_fds) < 0) {
|
if (pipe(pipe_fds) < 0) {
|
||||||
pa_log("pipe() failed: %s", pa_cstrerror(errno));
|
pa_log("pipe() failed: %s", pa_cstrerror(errno));
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
@ -104,6 +106,7 @@ int pa_start_child_for_read(const char *name, const char *argv1, pid_t *pid) {
|
||||||
execl(name, name, argv1, NULL);
|
execl(name, name, argv1, NULL);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
pa_close_pipe(pipe_fds);
|
pa_close_pipe(pipe_fds);
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
#include <pulse/xmalloc.h>
|
#include <pulse/xmalloc.h>
|
||||||
|
|
||||||
#include <pulsecore/winsock.h>
|
#include <pulsecore/socket.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
|
|
||||||
#include "tagstruct.h"
|
#include "tagstruct.h"
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <pulse/sample.h>
|
#include <pulse/sample.h>
|
||||||
#include <pulse/channelmap.h>
|
#include <pulse/channelmap.h>
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include <pulsecore/rtpoll.h>
|
#include <pulsecore/rtpoll.h>
|
||||||
|
|
||||||
/* Two way communication between a thread and a mainloop. Before the
|
/* Two way communication between a thread and a mainloop. Before the
|
||||||
* thread is started a pa_pthread_mq should be initialized and than
|
* thread is started a pa_thread_mq should be initialized and than
|
||||||
* attached to the thread using pa_thread_mq_install(). */
|
* attached to the thread using pa_thread_mq_install(). */
|
||||||
|
|
||||||
typedef struct pa_thread_mq {
|
typedef struct pa_thread_mq {
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,9 @@ static DWORD WINAPI internal_thread_func(LPVOID param) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_thread* pa_thread_new(pa_thread_func_t thread_func, void *userdata) {
|
pa_thread* pa_thread_new(const char *name, pa_thread_func_t thread_func, void *userdata) {
|
||||||
pa_thread *t;
|
pa_thread *t;
|
||||||
|
DWORD thread_id;
|
||||||
|
|
||||||
assert(thread_func);
|
assert(thread_func);
|
||||||
|
|
||||||
|
|
@ -80,7 +81,7 @@ pa_thread* pa_thread_new(pa_thread_func_t thread_func, void *userdata) {
|
||||||
t->thread_func = thread_func;
|
t->thread_func = thread_func;
|
||||||
t->userdata = userdata;
|
t->userdata = userdata;
|
||||||
|
|
||||||
t->thread = CreateThread(NULL, 0, internal_thread_func, t, 0, NULL);
|
t->thread = CreateThread(NULL, 0, internal_thread_func, t, 0, &thread_id);
|
||||||
|
|
||||||
if (!t->thread) {
|
if (!t->thread) {
|
||||||
pa_xfree(t);
|
pa_xfree(t);
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ void *pa_tls_set(pa_tls *t, void *userdata);
|
||||||
} \
|
} \
|
||||||
struct __stupid_useless_struct_to_allow_trailing_semicolon
|
struct __stupid_useless_struct_to_allow_trailing_semicolon
|
||||||
|
|
||||||
#ifdef SUPPORT_TLS___THREAD
|
#if defined(SUPPORT_TLS___THREAD) && !defined(OS_IS_WIN32)
|
||||||
/* An optimized version of the above that requires no dynamic
|
/* An optimized version of the above that requires no dynamic
|
||||||
* allocation if the compiler supports __thread */
|
* allocation if the compiler supports __thread */
|
||||||
#define PA_STATIC_TLS_DECLARE_NO_FREE(name) \
|
#define PA_STATIC_TLS_DECLARE_NO_FREE(name) \
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ static void consumer(void *_q) {
|
||||||
void *p;
|
void *p;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sleep(1);
|
pa_msleep(1000);
|
||||||
|
|
||||||
for (i = 0;; i++) {
|
for (i = 0;; i++) {
|
||||||
p = pa_asyncq_pop(q, TRUE);
|
p = pa_asyncq_pop(q, TRUE);
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,6 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
#ifdef HAVE_NETINET_IN_H
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -24,10 +21,10 @@
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../pulsecore/winsock.h"
|
#include <pulsecore/socket.h>
|
||||||
#include "../pulsecore/macro.h"
|
#include <pulsecore/macro.h>
|
||||||
|
|
||||||
#include <pulsecore/ipacl.h>
|
#include <pulsecore/ipacl.h>
|
||||||
|
#include <pulsecore/inet_pton.h>
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
struct sockaddr_in sa;
|
struct sockaddr_in sa;
|
||||||
|
|
|
||||||
|
|
@ -26,78 +26,69 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sched.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
|
#ifdef HAVE_PTHREAD
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <pulse/util.h>
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
#include <pulse/gccmacro.h>
|
#include <pulse/gccmacro.h>
|
||||||
|
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
|
#include <pulsecore/thread.h>
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
|
#include <pulsecore/core-rtclock.h>
|
||||||
|
|
||||||
static int msec_lower, msec_upper;
|
static int msec_lower, msec_upper;
|
||||||
|
|
||||||
static void* work(void *p) PA_GCC_NORETURN;
|
static void work(void *p) PA_GCC_NORETURN;
|
||||||
|
|
||||||
static void* work(void *p) {
|
static void work(void *p) {
|
||||||
#ifdef HAVE_PTHREAD_SETAFFINITY_NP
|
|
||||||
cpu_set_t mask;
|
|
||||||
#endif
|
|
||||||
struct sched_param param;
|
|
||||||
|
|
||||||
pa_log_notice("CPU%i: Created thread.", PA_PTR_TO_UINT(p));
|
pa_log_notice("CPU%i: Created thread.", PA_PTR_TO_UINT(p));
|
||||||
|
|
||||||
memset(¶m, 0, sizeof(param));
|
pa_make_realtime(12);
|
||||||
param.sched_priority = 12;
|
|
||||||
pa_assert_se(pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m) == 0);
|
|
||||||
|
|
||||||
#ifdef HAVE_PTHREAD_SETAFFINITY_NP
|
#ifdef HAVE_PTHREAD_SETAFFINITY_NP
|
||||||
|
{
|
||||||
|
cpu_set_t mask;
|
||||||
|
|
||||||
CPU_ZERO(&mask);
|
CPU_ZERO(&mask);
|
||||||
CPU_SET((size_t) PA_PTR_TO_UINT(p), &mask);
|
CPU_SET((size_t) PA_PTR_TO_UINT(p), &mask);
|
||||||
pa_assert_se(pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) == 0);
|
pa_assert_se(pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) == 0);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
struct timespec now, end;
|
struct timeval now, end;
|
||||||
uint64_t nsec;
|
uint64_t usec;
|
||||||
|
|
||||||
pa_log_notice("CPU%i: Sleeping for 1s", PA_PTR_TO_UINT(p));
|
pa_log_notice("CPU%i: Sleeping for 1s", PA_PTR_TO_UINT(p));
|
||||||
sleep(1);
|
pa_msleep(1000);
|
||||||
|
|
||||||
#ifdef CLOCK_REALTIME
|
usec =
|
||||||
pa_assert_se(clock_gettime(CLOCK_REALTIME, &end) == 0);
|
(uint64_t) ((((double) rand())*(double)(msec_upper-msec_lower)*PA_USEC_PER_MSEC)/RAND_MAX) +
|
||||||
#endif
|
(uint64_t) ((uint64_t) msec_lower*PA_USEC_PER_MSEC);
|
||||||
|
|
||||||
nsec =
|
pa_log_notice("CPU%i: Freezing for %ims", PA_PTR_TO_UINT(p), (int) (usec/PA_USEC_PER_MSEC));
|
||||||
(uint64_t) ((((double) rand())*(double)(msec_upper-msec_lower)*PA_NSEC_PER_MSEC)/RAND_MAX) +
|
|
||||||
(uint64_t) ((uint64_t) msec_lower*PA_NSEC_PER_MSEC);
|
|
||||||
|
|
||||||
pa_log_notice("CPU%i: Freezing for %ims", PA_PTR_TO_UINT(p), (int) (nsec/PA_NSEC_PER_MSEC));
|
pa_rtclock_get(&end);
|
||||||
|
pa_timeval_add(&end, usec);
|
||||||
end.tv_sec += (time_t) (nsec / PA_NSEC_PER_SEC);
|
|
||||||
end.tv_nsec += (long int) (nsec % PA_NSEC_PER_SEC);
|
|
||||||
|
|
||||||
while ((pa_usec_t) end.tv_nsec > PA_NSEC_PER_SEC) {
|
|
||||||
end.tv_sec++;
|
|
||||||
end.tv_nsec -= (long int) PA_NSEC_PER_SEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
#ifdef CLOCK_REALTIME
|
pa_rtclock_get(&now);
|
||||||
pa_assert_se(clock_gettime(CLOCK_REALTIME, &now) == 0);
|
} while (pa_timeval_cmp(&now, &end) < 0);
|
||||||
#endif
|
|
||||||
} while (now.tv_sec < end.tv_sec ||
|
|
||||||
(now.tv_sec == end.tv_sec && now.tv_nsec < end.tv_nsec));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char*argv[]) {
|
int main(int argc, char*argv[]) {
|
||||||
unsigned n;
|
unsigned n;
|
||||||
|
|
||||||
pa_log_set_level(PA_LOG_DEBUG);
|
pa_log_set_level(PA_LOG_INFO);
|
||||||
|
|
||||||
srand((unsigned) time(NULL));
|
srand((unsigned) time(NULL));
|
||||||
|
|
||||||
|
|
@ -118,8 +109,7 @@ int main(int argc, char*argv[]) {
|
||||||
pa_log_notice("Creating random latencies in the range of %ims to %ims.", msec_lower, msec_upper);
|
pa_log_notice("Creating random latencies in the range of %ims to %ims.", msec_lower, msec_upper);
|
||||||
|
|
||||||
for (n = 1; n < pa_ncpus(); n++) {
|
for (n = 1; n < pa_ncpus(); n++) {
|
||||||
pthread_t t;
|
pa_assert_se(pa_thread_new("rtstutter", work, PA_UINT_TO_PTR(n)));
|
||||||
pa_assert_se(pthread_create(&t, NULL, work, PA_UINT_TO_PTR(n)) == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
work(PA_INT_TO_PTR(0));
|
work(PA_INT_TO_PTR(0));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue