mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
Implement some functions for win32
And disable building binaries for win32 that make no sense there
This commit is contained in:
parent
7b90e3b942
commit
d6d4336705
4 changed files with 72 additions and 18 deletions
|
|
@ -177,8 +177,11 @@ endif
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -256,9 +259,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 +296,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 +334,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)
|
||||||
|
|
|
||||||
|
|
@ -1078,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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,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
|
||||||
|
|
@ -147,20 +151,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;
|
||||||
|
|
@ -696,14 +698,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) {
|
||||||
|
|
@ -1499,6 +1508,9 @@ 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
|
#endif
|
||||||
|
|
||||||
pa_xfree(p);
|
pa_xfree(p);
|
||||||
|
|
@ -1558,6 +1570,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 */
|
||||||
|
|
||||||
|
|
@ -1570,6 +1583,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;
|
||||||
}
|
}
|
||||||
|
|
@ -2539,7 +2557,11 @@ void pa_set_env(const char *key, const char *value) {
|
||||||
|
|
||||||
/* This is not thread-safe */
|
/* This is not thread-safe */
|
||||||
|
|
||||||
|
#ifdef OS_IS_WIN32
|
||||||
|
SetEnvironmentVariable(key, value);
|
||||||
|
#else
|
||||||
setenv(key, value, 1);
|
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) {
|
||||||
|
|
@ -2564,7 +2586,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2682,11 +2708,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
|
||||||
|
|
@ -2835,10 +2872,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."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue