[pulseaudio-discuss] [PATCH 04/10] Use pa_* instead of generic functions to improve portability
Maarten Bosmans
mkbosmans at gmail.com
Wed Jan 5 17:39:51 PST 2011
---
src/pulse/context.c | 2 +-
src/pulse/thread-mainloop.c | 2 +-
src/pulsecore/inet_ntop.c | 3 ++-
src/pulsecore/inet_pton.c | 4 +++-
src/tests/asyncq-test.c | 2 +-
src/tests/rtstutter.c | 3 ++-
6 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/pulse/context.c b/src/pulse/context.c
index ca81650..7ede8a2 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -578,7 +578,7 @@ static char *get_old_legacy_runtime_dir(void) {
if (!pa_get_user_name(u, sizeof(u)))
return NULL;
- p = pa_sprintf_malloc("/tmp/pulse-%s", u);
+ p = pa_sprintf_malloc("%s/pulse-%s", pa_get_temp_dir(), u);
if (stat(p, &st) < 0) {
pa_xfree(p);
diff --git a/src/pulse/thread-mainloop.c b/src/pulse/thread-mainloop.c
index d8c82c8..ef4ef56 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;
diff --git a/src/pulsecore/inet_ntop.c b/src/pulsecore/inet_ntop.c
index 1948f0f..a83c177 100644
--- a/src/pulsecore/inet_ntop.c
+++ b/src/pulsecore/inet_ntop.c
@@ -29,6 +29,7 @@
#ifndef HAVE_INET_NTOP
#include "socket.h"
+#include <pulsecore/macro.h>
#include "inet_ntop.h"
@@ -38,7 +39,7 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) {
struct in6_addr *in6 = (struct in6_addr*)src;
#endif
- assert(src && dst);
+ pa_assert(src && dst);
switch (af) {
case AF_INET:
diff --git a/src/pulsecore/inet_pton.c b/src/pulsecore/inet_pton.c
index 041902a..9f48a3a 100644
--- a/src/pulsecore/inet_pton.c
+++ b/src/pulsecore/inet_pton.c
@@ -29,6 +29,8 @@
#ifndef HAVE_INET_PTON
#include "socket.h"
+#include <pulsecore/macro.h>
+
#include "inet_pton.h"
int inet_pton(int af, const char *src, void *dst) {
@@ -37,7 +39,7 @@ int inet_pton(int af, const char *src, void *dst) {
struct in6_addr *in6 = (struct in6_addr*)dst;
#endif
- assert(src && dst);
+ pa_assert(src && dst);
switch (af) {
case AF_INET:
diff --git a/src/tests/asyncq-test.c b/src/tests/asyncq-test.c
index 538bbb1..eae8cce 100644
--- a/src/tests/asyncq-test.c
+++ b/src/tests/asyncq-test.c
@@ -51,7 +51,7 @@ static void consumer(void *_q) {
void *p;
int i;
- sleep(1);
+ pa_msleep(1000);
for (i = 0;; i++) {
p = pa_asyncq_pop(q, TRUE);
diff --git a/src/tests/rtstutter.c b/src/tests/rtstutter.c
index c93fee9..a82c47b 100644
--- a/src/tests/rtstutter.c
+++ b/src/tests/rtstutter.c
@@ -31,6 +31,7 @@
#include <string.h>
#include <pthread.h>
+#include <pulse/util.h>
#include <pulse/timeval.h>
#include <pulse/gccmacro.h>
@@ -65,7 +66,7 @@ static void* work(void *p) {
uint64_t nsec;
pa_log_notice("CPU%i: Sleeping for 1s", PA_PTR_TO_UINT(p));
- sleep(1);
+ pa_msleep(1000);
#ifdef CLOCK_REALTIME
pa_assert_se(clock_gettime(CLOCK_REALTIME, &end) == 0);
--
1.7.1
More information about the pulseaudio-discuss
mailing list