mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -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
|
|
@ -113,6 +113,7 @@ struct session {
|
|||
|
||||
struct userdata {
|
||||
pa_module *module;
|
||||
pa_core *core;
|
||||
|
||||
pa_sap_context sap_context;
|
||||
pa_io_event* sap_event;
|
||||
|
|
@ -622,15 +623,13 @@ static void sap_event_cb(pa_mainloop_api *m, pa_io_event *e, int fd, pa_io_event
|
|||
}
|
||||
}
|
||||
|
||||
static void check_death_event_cb(pa_mainloop_api *m, pa_time_event *t, const struct timeval *ptv, void *userdata) {
|
||||
static void check_death_event_cb(pa_mainloop_api *m, pa_time_event *t, const struct timeval *tv, void *userdata) {
|
||||
struct session *s, *n;
|
||||
struct userdata *u = userdata;
|
||||
struct timeval now;
|
||||
struct timeval tv;
|
||||
|
||||
pa_assert(m);
|
||||
pa_assert(t);
|
||||
pa_assert(ptv);
|
||||
pa_assert(u);
|
||||
|
||||
pa_rtclock_get(&now);
|
||||
|
|
@ -648,9 +647,7 @@ static void check_death_event_cb(pa_mainloop_api *m, pa_time_event *t, const str
|
|||
}
|
||||
|
||||
/* Restart timer */
|
||||
pa_gettimeofday(&tv);
|
||||
pa_timeval_add(&tv, DEATH_TIMEOUT*PA_USEC_PER_SEC);
|
||||
m->time_restart(t, &tv);
|
||||
pa_core_rttime_restart(u->module->core, t, pa_rtclock_now() + DEATH_TIMEOUT * PA_USEC_PER_SEC);
|
||||
}
|
||||
|
||||
int pa__init(pa_module*m) {
|
||||
|
|
@ -664,7 +661,6 @@ int pa__init(pa_module*m) {
|
|||
socklen_t salen;
|
||||
const char *sap_address;
|
||||
int fd = -1;
|
||||
struct timeval tv;
|
||||
|
||||
pa_assert(m);
|
||||
|
||||
|
|
@ -697,6 +693,7 @@ int pa__init(pa_module*m) {
|
|||
|
||||
m->userdata = u = pa_xnew(struct userdata, 1);
|
||||
u->module = m;
|
||||
u->core = m->core;
|
||||
u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL));
|
||||
|
||||
u->sap_event = m->core->mainloop->io_new(m->core->mainloop, fd, PA_IO_EVENT_INPUT, sap_event_cb, u);
|
||||
|
|
@ -706,9 +703,7 @@ int pa__init(pa_module*m) {
|
|||
u->n_sessions = 0;
|
||||
u->by_origin = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
|
||||
pa_gettimeofday(&tv);
|
||||
pa_timeval_add(&tv, DEATH_TIMEOUT * PA_USEC_PER_SEC);
|
||||
u->check_death_event = m->core->mainloop->time_new(m->core->mainloop, &tv, check_death_event_cb, u);
|
||||
u->check_death_event = pa_core_rttime_new(m->core, pa_rtclock_now() + DEATH_TIMEOUT * PA_USEC_PER_SEC, check_death_event_cb, u);
|
||||
|
||||
pa_modargs_free(ma);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue