diff options
Diffstat (limited to 'src/pulsecore')
-rw-r--r-- | src/pulsecore/asyncmsgq.c | 10 | ||||
-rw-r--r-- | src/pulsecore/rtpoll.c | 49 |
2 files changed, 50 insertions, 9 deletions
diff --git a/src/pulsecore/asyncmsgq.c b/src/pulsecore/asyncmsgq.c index 5c7af2a8..e191b05f 100644 --- a/src/pulsecore/asyncmsgq.c +++ b/src/pulsecore/asyncmsgq.c @@ -159,7 +159,7 @@ int pa_asyncmsgq_send(pa_asyncmsgq *a, pa_msgobject *object, int code, const voi pa_assert_se(i.semaphore); - /* Thus mutex makes the queue multiple-writer safe. This lock is only used on the writing side */ + /* This mutex makes the queue multiple-writer safe. This lock is only used on the writing side */ pa_mutex_lock(a->mutex); pa_assert_se(pa_asyncq_push(a->asyncq, &i, TRUE) == 0); pa_mutex_unlock(a->mutex); @@ -196,7 +196,13 @@ int pa_asyncmsgq_get(pa_asyncmsgq *a, pa_msgobject **object, int *code, void **u if (chunk) *chunk = a->current->memchunk; -/* pa_log_debug("Get q=%p object=%p (%s) code=%i data=%p chunk.length=%lu", (void*) a, (void*) a->current->object, a->current->object ? a->current->object->parent.type_name : NULL, a->current->code, (void*) a->current->userdata, (unsigned long) a->current->memchunk.length); */ +/* pa_log_debug("Get q=%p object=%p (%s) code=%i data=%p chunk.length=%lu", */ +/* (void*) a, */ +/* (void*) a->current->object, */ +/* a->current->object ? a->current->object->parent.type_name : NULL, */ +/* a->current->code, */ +/* (void*) a->current->userdata, */ +/* (unsigned long) a->current->memchunk.length); */ return 0; } diff --git a/src/pulsecore/rtpoll.c b/src/pulsecore/rtpoll.c index 183d97c2..01dfd620 100644 --- a/src/pulsecore/rtpoll.c +++ b/src/pulsecore/rtpoll.c @@ -50,29 +50,39 @@ #include <pulsecore/rtsig.h> #include <pulsecore/flist.h> #include <pulsecore/core-util.h> - #include <pulsecore/winsock.h> +#include <pulsecore/ratelimit.h> #include "rtpoll.h" +/* #define DEBUG_TIMING */ + struct pa_rtpoll { struct pollfd *pollfd, *pollfd2; unsigned n_pollfd_alloc, n_pollfd_used; - pa_bool_t timer_enabled; struct timeval next_elapse; + pa_bool_t timer_enabled:1; - pa_bool_t scan_for_dead; - pa_bool_t running, installed, rebuild_needed, quit; + pa_bool_t scan_for_dead:1; + pa_bool_t running:1; + pa_bool_t installed:1; + pa_bool_t rebuild_needed:1; + pa_bool_t quit:1; #ifdef HAVE_PPOLL + pa_bool_t timer_armed:1; +#ifdef __linux__ + pa_bool_t dont_use_ppoll:1; +#endif int rtsig; sigset_t sigset_unblocked; timer_t timer; - pa_bool_t timer_armed; -#ifdef __linux__ - pa_bool_t dont_use_ppoll; #endif + +#ifdef DEBUG_TIMING + pa_usec_t timestamp; + pa_usec_t slept, awake; #endif PA_LLIST_HEAD(pa_rtpoll_item, items); @@ -149,6 +159,11 @@ pa_rtpoll *pa_rtpoll_new(void) { PA_LLIST_HEAD_INIT(pa_rtpoll_item, p->items); +#ifdef DEBUG_TIMING + p->timestamp = pa_rtclock_usec(); + p->slept = p->awake = 0; +#endif + return p; } @@ -377,6 +392,14 @@ int pa_rtpoll_run(pa_rtpoll *p, pa_bool_t wait) { pa_timeval_add(&timeout, pa_timeval_diff(&p->next_elapse, &now)); } +#ifdef DEBUG_TIMING + { + pa_usec_t now = pa_rtclock_usec(); + p->awake = now - p->timestamp; + p->timestamp = now; + } +#endif + /* OK, now let's sleep */ #ifdef HAVE_PPOLL @@ -396,6 +419,18 @@ int pa_rtpoll_run(pa_rtpoll *p, pa_bool_t wait) { #endif r = poll(p->pollfd, p->n_pollfd_used, (!wait || p->quit || p->timer_enabled) ? (int) ((timeout.tv_sec*1000) + (timeout.tv_usec / 1000)) : -1); +#ifdef DEBUG_TIMING + { + pa_usec_t now = pa_rtclock_usec(); + p->slept = now - p->timestamp; + p->timestamp = now; + + pa_log("Process time %llu ms; sleep time %llu ms", + (unsigned long long) (p->awake / PA_USEC_PER_MSEC), + (unsigned long long) (p->slept / PA_USEC_PER_MSEC)); + } +#endif + if (r < 0) { if (errno == EAGAIN || errno == EINTR) r = 0; |