daemon: Add support for running as a service on win32

* Minimal implementation of --system on win32.
* Wrap main with a Windows Service on win32 (with a fallback to
  running it directly).
* Update PA_SYSTEM_{RUNTIME,STATE,CONFIG}_PATH and HOME dynamically
  on Windows (overrides the build config, similar to the existing
  config path replacement logic).

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/549>
This commit is contained in:
Patrick Gaskin 2021-05-30 15:28:30 -04:00 committed by PulseAudio Marge Bot
parent 87b4d68978
commit 4f3ca10d9e
4 changed files with 151 additions and 1 deletions

View file

@ -83,6 +83,7 @@
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#include <shlobj.h>
#endif
#ifndef ENOTSUP
@ -171,6 +172,15 @@ char *pa_win32_get_toplevel(HANDLE handle) {
return toplevel;
}
char *pa_win32_get_system_appdata() {
static char appdata[MAX_PATH] = {0};
if (!*appdata && SHGetFolderPathAndSubDirA(NULL, CSIDL_COMMON_APPDATA|CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, "PulseAudio", appdata) != S_OK)
return NULL;
return appdata;
}
#endif
static void set_nonblock(int fd, bool nonblock) {