diff options
| author | Marc-André Lureau <marc-andre.lureau@nokia.com> | 2009-04-05 02:13:43 +0300 | 
|---|---|---|
| committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2009-06-20 17:29:31 +0300 | 
| commit | 0955e3d45b6e992308e2d51fcbf28a9f9376f788 (patch) | |
| tree | 4fc673713b46d0fdd33c5529d1a06354db9d33ba /src/pulse/context.c | |
| parent | 125c52889626b2ac408ecbcc8ea85575f5808e07 (diff) | |
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>
Diffstat (limited to 'src/pulse/context.c')
| -rw-r--r-- | src/pulse/context.c | 29 | 
1 files changed, 26 insertions, 3 deletions
diff --git a/src/pulse/context.c b/src/pulse/context.c index 3b7bf08d..0c1810f3 100644 --- a/src/pulse/context.c +++ b/src/pulse/context.c @@ -64,6 +64,7 @@  #include <pulsecore/dynarray.h>  #include <pulsecore/socket-client.h>  #include <pulsecore/pstream-util.h> +#include <pulsecore/core-rtclock.h>  #include <pulsecore/core-util.h>  #include <pulsecore/log.h>  #include <pulsecore/socket-util.h> @@ -540,7 +541,7 @@ static void setup_context(pa_context *c, pa_iochannel *io) {      pa_pstream_set_recieve_memblock_callback(c->pstream, pstream_memblock_callback, c);      pa_assert(!c->pdispatch); -    c->pdispatch = pa_pdispatch_new(c->mainloop, command_table, PA_COMMAND_MAX); +    c->pdispatch = pa_pdispatch_new(c->mainloop, c->use_rtclock, command_table, PA_COMMAND_MAX);      if (!c->conf->cookie_valid)          pa_log_info(_("No cookie loaded. Attempting to connect without.")); @@ -757,7 +758,7 @@ static void track_pulseaudio_on_dbus(pa_context *c, DBusBusType type, pa_dbus_wr      pa_assert(conn);      dbus_error_init(&error); -    if (!(*conn = pa_dbus_wrap_connection_new(c->mainloop, type, &error)) || dbus_error_is_set(&error)) { +    if (!(*conn = pa_dbus_wrap_connection_new(c->mainloop, c->use_rtclock, type, &error)) || dbus_error_is_set(&error)) {          pa_log_warn("Unable to contact DBUS: %s: %s", error.name, error.message);          goto finish;      } @@ -827,7 +828,7 @@ static int try_next_connection(pa_context *c) {          pa_xfree(c->server);          c->server = pa_xstrdup(u); -        if (!(c->client = pa_socket_client_new_string(c->mainloop, u, PA_NATIVE_DEFAULT_PORT))) +        if (!(c->client = pa_socket_client_new_string(c->mainloop, c->use_rtclock, u, PA_NATIVE_DEFAULT_PORT)))              continue;          c->is_local = !!pa_socket_client_is_local(c->client); @@ -1443,3 +1444,25 @@ finish:      if (pl)          pa_proplist_free(pl);  } + +pa_time_event* pa_context_rttime_new(pa_context *c, pa_usec_t usec, pa_time_event_cb_t cb, void *userdata) { +    struct timeval tv; + +    pa_assert(c); +    pa_assert(c->mainloop); + +    pa_timeval_rtstore(&tv, usec, c->use_rtclock); + +    return c->mainloop->time_new(c->mainloop, &tv, cb, userdata); +} + +void pa_context_rttime_restart(pa_context *c, pa_time_event *e, pa_usec_t usec) { +    struct timeval tv; + +    pa_assert(c); +    pa_assert(c->mainloop); + +    pa_timeval_rtstore(&tv, usec, c->use_rtclock); + +    c->mainloop->time_restart(e, &tv); +}  | 
