mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-09 13:29:59 -05:00
Base mainloop on pa_rtclock_now()
Move the mainloop to monotonic based time events.
Introduces 4 helper functions:
pa_{context,core}_rttime_{new,restart}(), that fill correctly a
timeval with the rtclock flag set if the mainloop supports it.
Both mainloop-test and mainloop-test-glib works with rt and timeval
based time events. PulseAudio and clients should be fully functional.
This patch has received several iterations, and this one as been
largely untested.
Signed-off-by: Marc-André Lureau <marca-andre.lureau@nokia.com>
This commit is contained in:
parent
125c528896
commit
0955e3d45b
42 changed files with 311 additions and 233 deletions
|
|
@ -27,6 +27,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <pulse/rtclock.h>
|
||||
#include <pulse/timeval.h>
|
||||
#include <pulse/xmalloc.h>
|
||||
|
||||
|
|
@ -37,6 +38,7 @@
|
|||
#include <pulsecore/macro.h>
|
||||
#include <pulsecore/refcnt.h>
|
||||
#include <pulsecore/flist.h>
|
||||
#include <pulsecore/core-rtclock.h>
|
||||
|
||||
#include "pdispatch.h"
|
||||
|
||||
|
|
@ -204,6 +206,7 @@ struct pa_pdispatch {
|
|||
pa_pdispatch_drain_callback drain_callback;
|
||||
void *drain_userdata;
|
||||
const pa_creds *creds;
|
||||
pa_bool_t use_rtclock:1;
|
||||
};
|
||||
|
||||
static void reply_info_free(struct reply_info *r) {
|
||||
|
|
@ -220,7 +223,7 @@ static void reply_info_free(struct reply_info *r) {
|
|||
pa_xfree(r);
|
||||
}
|
||||
|
||||
pa_pdispatch* pa_pdispatch_new(pa_mainloop_api *mainloop, const pa_pdispatch_cb_t*table, unsigned entries) {
|
||||
pa_pdispatch* pa_pdispatch_new(pa_mainloop_api *mainloop, pa_bool_t use_rtclock, const pa_pdispatch_cb_t *table, unsigned entries) {
|
||||
pa_pdispatch *pd;
|
||||
pa_assert(mainloop);
|
||||
|
||||
|
|
@ -235,6 +238,7 @@ pa_pdispatch* pa_pdispatch_new(pa_mainloop_api *mainloop, const pa_pdispatch_cb_
|
|||
pd->drain_callback = NULL;
|
||||
pd->drain_userdata = NULL;
|
||||
pd->creds = NULL;
|
||||
pd->use_rtclock = use_rtclock;
|
||||
|
||||
return pd;
|
||||
}
|
||||
|
|
@ -342,7 +346,7 @@ finish:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void timeout_callback(pa_mainloop_api*m, pa_time_event*e, const struct timeval *tv, void *userdata) {
|
||||
static void timeout_callback(pa_mainloop_api*m, pa_time_event*e, const struct timeval *t, void *userdata) {
|
||||
struct reply_info*r = userdata;
|
||||
|
||||
pa_assert(r);
|
||||
|
|
@ -371,10 +375,7 @@ void pa_pdispatch_register_reply(pa_pdispatch *pd, uint32_t tag, int timeout, pa
|
|||
r->free_cb = free_cb;
|
||||
r->tag = tag;
|
||||
|
||||
pa_gettimeofday(&tv);
|
||||
tv.tv_sec += timeout;
|
||||
|
||||
pa_assert_se(r->time_event = pd->mainloop->time_new(pd->mainloop, &tv, timeout_callback, r));
|
||||
pa_assert_se(r->time_event = pd->mainloop->time_new(pd->mainloop, pa_timeval_rtstore(&tv, pa_rtclock_now() + timeout * PA_USEC_PER_SEC, pd->use_rtclock), timeout_callback, r));
|
||||
|
||||
PA_LLIST_PREPEND(struct reply_info, pd->replies, r);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue