From d6d9fb295d03a411974a148e469465e0f7c59891 Mon Sep 17 00:00:00 2001 From: Maarten Bosmans Date: Tue, 4 Jan 2011 11:17:53 +0100 Subject: Clean up includes Instead should be included. That file includes poll.h on platform where it is appropriate. Also remove some unnecessary includes. --- src/pulse/thread-mainloop.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/pulse') diff --git a/src/pulse/thread-mainloop.c b/src/pulse/thread-mainloop.c index c3cf49c4..d8c82c8c 100644 --- a/src/pulse/thread-mainloop.c +++ b/src/pulse/thread-mainloop.c @@ -31,12 +31,6 @@ #include #include -#ifdef HAVE_POLL_H -#include -#else -#include -#endif - #include #include #include @@ -46,6 +40,7 @@ #include #include #include +#include #include "thread-mainloop.h" -- cgit From 4f1d4044f8409ff29eeb7f97324daba496e40714 Mon Sep 17 00:00:00 2001 From: Maarten Bosmans Date: Tue, 4 Jan 2011 17:03:13 +0100 Subject: Use instead of The check whether POSIX socket.h or WIN32 winsock2.h must be included can be made centrally. The downside is that some functionality of e.g. arpa/inet.h is also implemented in winsock.h, so that some files that don't use socket functions, but do use inet.h functions, must also include pulsecore/socket.h. (as well as arpa/inet.h) --- src/pulse/context.c | 6 +----- src/pulse/mainloop.c | 2 +- src/pulse/timeval.c | 1 - src/pulse/util.c | 16 ++++++---------- 4 files changed, 8 insertions(+), 17 deletions(-) (limited to 'src/pulse') diff --git a/src/pulse/context.c b/src/pulse/context.c index 7a539b4d..ca816507 100644 --- a/src/pulse/context.c +++ b/src/pulse/context.c @@ -39,9 +39,6 @@ #include #endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif #ifdef HAVE_SYS_UN_H #include #endif @@ -57,9 +54,7 @@ #include #include -#include #include - #include #include #include @@ -69,6 +64,7 @@ #include #include #include +#include #include #include #include diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c index 8f743ec7..8c261381 100644 --- a/src/pulse/mainloop.c +++ b/src/pulse/mainloop.c @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include "mainloop.h" diff --git a/src/pulse/timeval.c b/src/pulse/timeval.c index cde4417c..c4a08419 100644 --- a/src/pulse/timeval.c +++ b/src/pulse/timeval.c @@ -31,7 +31,6 @@ #include #endif -#include #include #include diff --git a/src/pulse/util.c b/src/pulse/util.c index ca766dab..3206e94c 100644 --- a/src/pulse/util.c +++ b/src/pulse/util.c @@ -37,10 +37,6 @@ #include #endif -#ifdef HAVE_SYS_SOCKET_H -#include -#endif - #ifdef HAVE_NETDB_H #include #endif @@ -56,7 +52,7 @@ #include #include -#include +#include #include #include #include @@ -195,11 +191,11 @@ char *pa_get_binary_name(char *s, size_t l) { { char *rp; - if ((rp = pa_readlink("/proc/curproc/file"))) { - pa_strlcpy(s, pa_path_get_filename(rp), l); - pa_xfree(rp); - return s; - } + if ((rp = pa_readlink("/proc/curproc/file"))) { + pa_strlcpy(s, pa_path_get_filename(rp), l); + pa_xfree(rp); + return s; + } } #endif -- cgit From bb12ff83564d43566089dd979639c6993ba76665 Mon Sep 17 00:00:00 2001 From: Maarten Bosmans Date: Thu, 6 Jan 2011 00:51:33 +0100 Subject: Apply #ifdefs around functionality not available on win32 And also the reverse: around some win32 specific functionality --- src/pulse/context.c | 6 ++++++ src/pulse/util.c | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/pulse') diff --git a/src/pulse/context.c b/src/pulse/context.c index ca816507..8f632b5d 100644 --- a/src/pulse/context.c +++ b/src/pulse/context.c @@ -585,10 +585,12 @@ static char *get_old_legacy_runtime_dir(void) { return NULL; } +#ifdef HAVE_GETUID if (st.st_uid != getuid()) { pa_xfree(p); return NULL; } +#endif return p; } @@ -607,10 +609,12 @@ static char *get_very_old_legacy_runtime_dir(void) { return NULL; } +#ifdef HAVE_GETUID if (st.st_uid != getuid()) { pa_xfree(p); return NULL; } +#endif return p; } @@ -997,6 +1001,7 @@ int pa_context_connect( /* Set up autospawning */ if (!(flags & PA_CONTEXT_NOAUTOSPAWN) && c->conf->autospawn) { +#ifdef HAVE_GETUID if (getuid() == 0) pa_log_debug("Not doing autospawn since we are root."); else { @@ -1005,6 +1010,7 @@ int pa_context_connect( if (api) c->spawn_api = *api; } +#endif } pa_context_set_state(c, PA_CONTEXT_CONNECTING); diff --git a/src/pulse/util.c b/src/pulse/util.c index 3206e94c..c5cfc8ca 100644 --- a/src/pulse/util.c +++ b/src/pulse/util.c @@ -75,11 +75,15 @@ char *pa_get_user_name(char *s, size_t l) { pa_assert(s); pa_assert(l > 0); - if ((p = (getuid() == 0 ? "root" : NULL)) || - (p = getenv("USER")) || - (p = getenv("LOGNAME")) || - (p = getenv("USERNAME"))) - { + p = NULL; +#ifdef HAVE_GETUID + p = getuid() == 0 ? "root" : NULL; +#endif + if (!p) p = getenv("USER"); + if (!p) p = getenv("LOGNAME"); + if (!p) p = getenv("USERNAME"); + + if (p) { name = pa_strlcpy(s, p, l); } else { #ifdef HAVE_PWD_H -- cgit From a39a83665f07a0819a31ee2d1ab60210a67c47a2 Mon Sep 17 00:00:00 2001 From: Maarten Bosmans Date: Tue, 18 Jan 2011 11:26:57 +0100 Subject: win32: Implement rtclock based on QueryPerformanceCounter Also remove some unnecessary headers. --- src/pulse/def.h | 1 - src/pulse/mainloop-api.h | 1 - src/pulse/rtclock.c | 2 +- src/pulse/timeval.c | 15 +++++---------- 4 files changed, 6 insertions(+), 13 deletions(-) (limited to 'src/pulse') diff --git a/src/pulse/def.h b/src/pulse/def.h index 4a8da137..ac4ae538 100644 --- a/src/pulse/def.h +++ b/src/pulse/def.h @@ -25,7 +25,6 @@ #include #include -#include #include #include diff --git a/src/pulse/mainloop-api.h b/src/pulse/mainloop-api.h index aa0d5e73..0ce2219b 100644 --- a/src/pulse/mainloop-api.h +++ b/src/pulse/mainloop-api.h @@ -24,7 +24,6 @@ ***/ #include -#include #include #include diff --git a/src/pulse/rtclock.c b/src/pulse/rtclock.c index 49ff6aae..baa0f3a5 100644 --- a/src/pulse/rtclock.c +++ b/src/pulse/rtclock.c @@ -23,10 +23,10 @@ #include #endif +#include #include #include "rtclock.h" -#include "timeval.h" pa_usec_t pa_rtclock_now(void) { struct timeval tv; diff --git a/src/pulse/timeval.c b/src/pulse/timeval.c index c4a08419..10ba322f 100644 --- a/src/pulse/timeval.c +++ b/src/pulse/timeval.c @@ -37,29 +37,22 @@ #include "timeval.h" struct timeval *pa_gettimeofday(struct timeval *tv) { -#ifdef HAVE_GETTIMEOFDAY pa_assert(tv); - pa_assert_se(gettimeofday(tv, NULL) == 0); - return tv; -#elif defined(OS_IS_WIN32) +#if defined(OS_IS_WIN32) /* * Copied from implementation by Steven Edwards (LGPL). * Found on wine mailing list. */ - #if defined(_MSC_VER) || defined(__BORLANDC__) #define EPOCHFILETIME (116444736000000000i64) #else #define EPOCHFILETIME (116444736000000000LL) #endif - FILETIME ft; LARGE_INTEGER li; int64_t t; - pa_assert(tv); - GetSystemTimeAsFileTime(&ft); li.LowPart = ft.dwLowDateTime; li.HighPart = ft.dwHighDateTime; @@ -68,11 +61,13 @@ struct timeval *pa_gettimeofday(struct timeval *tv) { t /= 10; /* In microseconds */ tv->tv_sec = (time_t) (t / PA_USEC_PER_SEC); tv->tv_usec = (suseconds_t) (t % PA_USEC_PER_SEC); - - return tv; +#elif defined(HAVE_GETTIMEOFDAY) + pa_assert_se(gettimeofday(tv, NULL) == 0); #else #error "Platform lacks gettimeofday() or equivalent function." #endif + + return tv; } pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) { -- cgit From 821562b9bc8d1a9033daaae0fd5373498a085054 Mon Sep 17 00:00:00 2001 From: Maarten Bosmans Date: Wed, 5 Jan 2011 19:50:44 +0100 Subject: Use pa_read, pa_write and pa_poll instead of system functions --- src/pulse/thread-mainloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pulse') diff --git a/src/pulse/thread-mainloop.c b/src/pulse/thread-mainloop.c index d8c82c8c..ef4ef56e 100644 --- a/src/pulse/thread-mainloop.c +++ b/src/pulse/thread-mainloop.c @@ -67,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. */ pa_mutex_unlock(mutex); - r = poll(ufds, nfds, timeout); + r = pa_poll(ufds, nfds, timeout); pa_mutex_lock(mutex); return r; -- cgit