Skip to content

Commit

Permalink
Enable Unix Domain Socket on Windows 10
Browse files Browse the repository at this point in the history
Changes:
* No more assume Win32 does not have AF_UNIX;
* Use native inet_ntop, inet_pton and pollfd on Win32;
* Fix WSAEWOULDBLOCK handling on Win32;
* Fix stale pid detection on Win32;
* Automatically create parent directories for AF_UNIX;
* Minor changes to bypass some static assertion on Win32;
* Add an icon and file info for the daemon.
  • Loading branch information
Martin1994 committed Apr 29, 2019
1 parent ee910cf commit 0b475be
Show file tree
Hide file tree
Showing 16 changed files with 255 additions and 128 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -36,3 +36,4 @@ stamp-*
.dirstamp
*.orig
*.rej
.vscode
Binary file added pulseaudio-text.ico
Binary file not shown.
2 changes: 2 additions & 0 deletions src/.gitignore
Expand Up @@ -28,6 +28,8 @@ pulseaudio
pulseaudio.service
start-pulseaudio-x11
*-orc-gen.[ch]
*.exe
*.res
# tests
alsa-mixer-path-test
alsa-time-test
Expand Down
14 changes: 10 additions & 4 deletions src/Makefile.am
Expand Up @@ -160,6 +160,11 @@ pulseaudio_LDADD = $(AM_LDADD) libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@P
# This is needed because automake doesn't properly expand the foreach below
pulseaudio_DEPENDENCIES = libpulsecore-@PA_MAJORMINOR@.la libpulsecommon-@PA_MAJORMINOR@.la libpulse.la $(PREOPEN_LIBS)

if OS_IS_WIN32
pulseaudio_LDADD += daemon/pulseaudio.res
pulseaudio_DEPENDENCIES += daemon/pulseaudio.res
endif

if HAVE_DBUS
pulseaudio_CFLAGS += $(DBUS_CFLAGS)
pulseaudio_SOURCES += daemon/server-lookup.c daemon/server-lookup.h
Expand Down Expand Up @@ -202,7 +207,7 @@ bin_PROGRAMS += pasuspender
endif

if HAVE_AF_UNIX
bin_PROGRAMS += pacmd
# bin_PROGRAMS += pacmd
endif

if HAVE_X11
Expand Down Expand Up @@ -693,7 +698,6 @@ libpulsecommon_@PA_MAJORMINOR@_la_SOURCES = \
pulsecore/hashmap.c pulsecore/hashmap.h \
pulsecore/i18n.c pulsecore/i18n.h \
pulsecore/idxset.c pulsecore/idxset.h \
pulsecore/arpa-inet.c pulsecore/arpa-inet.h \
pulsecore/iochannel.c pulsecore/iochannel.h \
pulsecore/ioline.c pulsecore/ioline.h \
pulsecore/ipacl.c pulsecore/ipacl.h \
Expand Down Expand Up @@ -742,7 +746,7 @@ libpulsecommon_@PA_MAJORMINOR@_la_SOURCES = \

if OS_IS_WIN32
libpulsecommon_@PA_MAJORMINOR@_la_SOURCES += \
pulsecore/poll-win32.c pulsecore/poll.h \
pulsecore/poll.h \
pulsecore/winerrno.h
else
libpulsecommon_@PA_MAJORMINOR@_la_SOURCES += pulsecore/poll-posix.c pulsecore/poll.h
Expand Down Expand Up @@ -1214,7 +1218,6 @@ modlibexec_LTLIBRARIES += \
module-combine-sink.la \
module-remap-sink.la \
module-remap-source.la \
module-ladspa-sink.la \
module-tunnel-sink-new.la \
module-tunnel-source-new.la \
module-tunnel-sink.la \
Expand Down Expand Up @@ -2240,6 +2243,9 @@ update-map-file:

update-all: update-ffmpeg update-map-file

daemon/pulseaudio.res: daemon/pulseaudio.rc ../pulseaudio-text.ico
windres daemon/pulseaudio.rc -O coff -o daemon/pulseaudio.res

# Force installation order of libraries. libtool relinks on install time, in
# which case libpulsecommon has to be installed before others, but the padsp
# preload library has to be done after the normal libraries (e.g. libpulse)
Expand Down
23 changes: 23 additions & 0 deletions src/daemon/pulseaudio.rc
@@ -0,0 +1,23 @@
1 VERSIONINFO
FILEVERSION 12,2,0,0
PRODUCTVERSION 12,2,0,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", "PulseAudio Server"
VALUE "FileVersion", "12.2"
VALUE "InternalName", "pulseaudio"
VALUE "OriginalFilename", "pulseaudio.exe"
VALUE "ProductName", "The PulseAudio Sound System"
VALUE "ProductVersion", "12.2"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END

2 ICON "../pulseaudio-text.ico"
193 changes: 193 additions & 0 deletions src/meson.build
@@ -0,0 +1,193 @@
libpulsecommon_sources = [
'pulse/client-conf.c',
'pulse/fork-detect.c',
'pulse/format.c',
'pulse/json.c',
'pulse/xmalloc.c',
'pulse/proplist.c',
'pulse/utf8.c',
'pulse/channelmap.c',
'pulse/sample.c',
'pulse/util.c',
'pulse/timeval.c',
'pulse/rtclock.c',
'pulse/volume.c',
'pulsecore/authkey.c',
'pulsecore/conf-parser.c',
'pulsecore/core-error.c',
'pulsecore/core-format.c',
'pulsecore/core-rtclock.c',
'pulsecore/core-util.c',
'pulsecore/dynarray.c',
'pulsecore/fdsem.c',
'pulsecore/flist.c',
'pulsecore/g711.c',
'pulsecore/hashmap.c',
'pulsecore/i18n.c',
'pulsecore/idxset.c',
'pulsecore/iochannel.c',
'pulsecore/ioline.c',
'pulsecore/ipacl.c',
'pulsecore/lock-autospawn.c',
'pulsecore/log.c',
'pulsecore/ratelimit.c',
'pulsecore/mcalign.c',
'pulsecore/memblock.c',
'pulsecore/memblockq.c',
'pulsecore/memchunk.c',
'pulsecore/mutex-posix.c',
'pulsecore/native-common.c',
'pulsecore/once.c',
'pulsecore/packet.c',
'pulsecore/parseaddr.c',
'pulsecore/pdispatch.c',
'pulsecore/pid.c',
'pulsecore/pipe.c',
'pulsecore/memtrap.c',
'pulsecore/aupdate.c',
'pulsecore/proplist-util.c',
'pulsecore/pstream-util.c',
'pulsecore/pstream.c',
'pulsecore/queue.c',
'pulsecore/random.c',
'pulsecore/srbchannel.c',
'pulsecore/sample-util.c',
'pulsecore/semaphore-posix.c',
'pulsecore/shm.c',
'pulsecore/bitset.c',
'pulsecore/socket-client.c',
'pulsecore/socket-server.c',
'pulsecore/socket-util.c',
'pulsecore/strbuf.c',
'pulsecore/strlist.c',
'pulsecore/svolume_c.c',
'pulsecore/svolume_mmx.c',
'pulsecore/tagstruct.c',
'pulsecore/thread-posix.c',
'pulsecore/time-smoother.c',
'pulsecore/tokenizer.c',
'pulsecore/usergroup.c',
'pulsecore/sndfile-util.c',
'pulsecore/svolume_arm.c',
]

libpulsecommon_headers = [
'pulse/client-conf.h',
'pulse/fork-detect.h',
'pulse/format.h',
'pulse/json.h',
'pulse/xmalloc.h',
'pulse/proplist.h',
'pulse/utf8.h',
'pulse/channelmap.h',
'pulse/sample.h',
'pulse/util.h',
'pulse/timeval.h',
'pulse/rtclock.h',
'pulse/volume.h',
'pulsecore/atomic.h',
'pulsecore/authkey.h',
'pulsecore/conf-parser.h',
'pulsecore/core-error.h',
'pulsecore/core-format.h',
'pulsecore/core-rtclock.h',
'pulsecore/core-util.h',
'pulsecore/creds.h',
'pulsecore/dynarray.h',
'pulsecore/endianmacros.h',
'pulsecore/fdsem.h',
'pulsecore/flist.h',
'pulsecore/g711.h',
'pulsecore/hashmap.h',
'pulsecore/i18n.h',
'pulsecore/idxset.h',
'pulsecore/arpa-inet.h',
'pulsecore/iochannel.h',
'pulsecore/ioline.h',
'pulsecore/ipacl.h',
'pulsecore/llist.h',
'pulsecore/lock-autospawn.h',
'pulsecore/log.h',
'pulsecore/ratelimit.h',
'pulsecore/macro.h',
'pulsecore/mcalign.h',
'pulsecore/mem.h',
'pulsecore/memblock.h',
'pulsecore/memblockq.h',
'pulsecore/memchunk.h',
'pulsecore/mutex.h',
'pulsecore/native-common.h',
'pulsecore/once.h',
'pulsecore/packet.h',
'pulsecore/parseaddr.h',
'pulsecore/pdispatch.h',
'pulsecore/pid.h',
'pulsecore/pipe.h',
'pulsecore/memtrap.h',
'pulsecore/aupdate.h',
'pulsecore/proplist-util.h',
'pulsecore/pstream-util.h',
'pulsecore/pstream.h',
'pulsecore/queue.h',
'pulsecore/random.h',
'pulsecore/refcnt.h',
'pulsecore/srbchannel.h',
'pulsecore/sample-util.h',
'pulsecore/semaphore.h',
'pulsecore/shm.h',
'pulsecore/bitset.h',
'pulsecore/socket-client.h',
'pulsecore/socket-server.h',
'pulsecore/socket-util.h',
'pulsecore/strbuf.h',
'pulsecore/strlist.h',
'pulsecore/tagstruct.h',
'pulsecore/thread.h',
'pulsecore/time-smoother.h',
'pulsecore/tokenizer.h',
'pulsecore/usergroup.h',
'pulsecore/sndfile-util.h',
'pulsecore/socket.h',
]

if dbus_dep.found()
libpulsecommon_sources += [
'pulsecore/dbus-util.c',
'pulsecore/rtkit.c',
]
libpulsecommon_headers += [
'pulsecore/dbus-util.h',
'pulsecore/rtkit.h',
]
endif

if x11_dep.found()
libpulsecommon_sources += [
'pulse/client-conf-x11.c',
'pulsecore/x11prop.c',
]
libpulsecommon_headers += [
'pulse/client-conf-x11.h',
'pulsecore/x11prop.h',
]
endif

# FIXME: Do non-POSIX thread things
# FIXME: Do SIMD things

libpulsecommon = shared_library('pulsecommon-' + pa_version_major_minor,
libpulsecommon_sources,
libpulsecommon_headers,
include_directories : [configinc, topinc],
c_args : [pa_c_args],
install : true,
dependencies : [libm_dep, thread_dep, shm_dep, sndfile_dep, dbus_dep, x11_dep, systemd_dep, glib_dep, gtk_dep, asyncns_dep],
implicit_include_directories : false)

libpulsecommon_dep = declare_dependency(link_with: libpulsecommon)

subdir('pulse')
subdir('pulsecore')
subdir('daemon')
subdir('modules')
subdir('utils')
4 changes: 4 additions & 0 deletions src/modules/module-protocol-stub.c
Expand Up @@ -319,6 +319,10 @@ int pa__init(pa_module*m) {
pa_log("Failed to generate socket path.");
goto fail;
}
if (pa_make_secure_parent_dir(u->socket_path, pa_in_system_mode() ? 0755U : 0700U, (uid_t)-1, (gid_t)-1, false) < 0) {
pa_log("Failed to create socket directory '%s': %s\n", u->socket_path, pa_cstrerror(errno));
goto fail;
}
# endif

if ((r = pa_unix_socket_remove_stale(u->socket_path)) < 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/pulse/fork-detect.c
Expand Up @@ -37,7 +37,7 @@ int pa_detect_fork(void) {
* however have to deal with this cleanly, so we try to detect the
* forks making sure all our calls fail cleanly after the fork. */

pa_assert_cc(sizeof(pa_atomic_t) >= sizeof(pid_t));
// pa_assert_cc(sizeof(pa_atomic_t) >= sizeof(pid_t));

for (;;) {
pid_t stored_pid = (pid_t) pa_atomic_load(&pid);
Expand Down

0 comments on commit 0b475be

Please sign in to comment.