mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-05 13:29:57 -05:00
Use pa_* instead of generic functions to improve portability
This commit is contained in:
parent
f2a9fd779e
commit
aebf66bef6
4 changed files with 15 additions and 14 deletions
|
|
@ -29,6 +29,7 @@
|
||||||
#ifndef HAVE_INET_NTOP
|
#ifndef HAVE_INET_NTOP
|
||||||
|
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
|
#include <pulsecore/macro.h>
|
||||||
#include <pulsecore/socket.h>
|
#include <pulsecore/socket.h>
|
||||||
|
|
||||||
#include "inet_ntop.h"
|
#include "inet_ntop.h"
|
||||||
|
|
@ -39,7 +40,8 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt) {
|
||||||
struct in6_addr *in6 = (struct in6_addr*)src;
|
struct in6_addr *in6 = (struct in6_addr*)src;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert(src && dst);
|
pa_assert(src);
|
||||||
|
pa_assert(dst);
|
||||||
|
|
||||||
switch (af) {
|
switch (af) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#ifndef HAVE_INET_PTON
|
#ifndef HAVE_INET_PTON
|
||||||
|
|
||||||
|
#include <pulsecore/macro.h>
|
||||||
#include <pulsecore/socket.h>
|
#include <pulsecore/socket.h>
|
||||||
|
|
||||||
#include "inet_pton.h"
|
#include "inet_pton.h"
|
||||||
|
|
@ -38,7 +39,8 @@ int inet_pton(int af, const char *src, void *dst) {
|
||||||
struct in6_addr *in6 = (struct in6_addr*)dst;
|
struct in6_addr *in6 = (struct in6_addr*)dst;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert(src && dst);
|
pa_assert(src);
|
||||||
|
pa_assert(dst);
|
||||||
|
|
||||||
switch (af) {
|
switch (af) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ static void consumer(void *_q) {
|
||||||
void *p;
|
void *p;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sleep(1);
|
pa_msleep(1000);
|
||||||
|
|
||||||
for (i = 0;; i++) {
|
for (i = 0;; i++) {
|
||||||
p = pa_asyncq_pop(q, TRUE);
|
p = pa_asyncq_pop(q, TRUE);
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sched.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
@ -34,25 +33,24 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <pulse/util.h>
|
||||||
#include <pulse/timeval.h>
|
#include <pulse/timeval.h>
|
||||||
#include <pulse/gccmacro.h>
|
#include <pulse/gccmacro.h>
|
||||||
|
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
#include <pulsecore/macro.h>
|
#include <pulsecore/macro.h>
|
||||||
|
#include <pulsecore/thread.h>
|
||||||
#include <pulsecore/core-util.h>
|
#include <pulsecore/core-util.h>
|
||||||
|
|
||||||
static int msec_lower, msec_upper;
|
static int msec_lower, msec_upper;
|
||||||
|
|
||||||
static void* work(void *p) PA_GCC_NORETURN;
|
static void work(void *p) PA_GCC_NORETURN;
|
||||||
|
|
||||||
static void* work(void *p) {
|
static void work(void *p) {
|
||||||
struct sched_param param;
|
|
||||||
|
|
||||||
pa_log_notice("CPU%i: Created thread.", PA_PTR_TO_UINT(p));
|
pa_log_notice("CPU%i: Created thread.", PA_PTR_TO_UINT(p));
|
||||||
|
|
||||||
memset(¶m, 0, sizeof(param));
|
pa_make_realtime(12);
|
||||||
param.sched_priority = 12;
|
|
||||||
pa_assert_se(pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m) == 0);
|
|
||||||
|
|
||||||
#ifdef HAVE_PTHREAD_SETAFFINITY_NP
|
#ifdef HAVE_PTHREAD_SETAFFINITY_NP
|
||||||
{
|
{
|
||||||
|
|
@ -69,7 +67,7 @@ static void* work(void *p) {
|
||||||
uint64_t nsec;
|
uint64_t nsec;
|
||||||
|
|
||||||
pa_log_notice("CPU%i: Sleeping for 1s", PA_PTR_TO_UINT(p));
|
pa_log_notice("CPU%i: Sleeping for 1s", PA_PTR_TO_UINT(p));
|
||||||
sleep(1);
|
pa_msleep(1000);
|
||||||
|
|
||||||
#ifdef CLOCK_REALTIME
|
#ifdef CLOCK_REALTIME
|
||||||
pa_assert_se(clock_gettime(CLOCK_REALTIME, &end) == 0);
|
pa_assert_se(clock_gettime(CLOCK_REALTIME, &end) == 0);
|
||||||
|
|
@ -101,7 +99,7 @@ static void* work(void *p) {
|
||||||
int main(int argc, char*argv[]) {
|
int main(int argc, char*argv[]) {
|
||||||
unsigned n;
|
unsigned n;
|
||||||
|
|
||||||
pa_log_set_level(PA_LOG_DEBUG);
|
pa_log_set_level(PA_LOG_INFO);
|
||||||
|
|
||||||
srand((unsigned) time(NULL));
|
srand((unsigned) time(NULL));
|
||||||
|
|
||||||
|
|
@ -122,8 +120,7 @@ int main(int argc, char*argv[]) {
|
||||||
pa_log_notice("Creating random latencies in the range of %ims to %ims.", msec_lower, msec_upper);
|
pa_log_notice("Creating random latencies in the range of %ims to %ims.", msec_lower, msec_upper);
|
||||||
|
|
||||||
for (n = 1; n < pa_ncpus(); n++) {
|
for (n = 1; n < pa_ncpus(); n++) {
|
||||||
pthread_t t;
|
pa_assert_se(pa_thread_new("rtstutter", work, PA_UINT_TO_PTR(n)));
|
||||||
pa_assert_se(pthread_create(&t, NULL, work, PA_UINT_TO_PTR(n)) == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
work(PA_INT_TO_PTR(0));
|
work(PA_INT_TO_PTR(0));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue