From 0955e3d45b6e992308e2d51fcbf28a9f9376f788 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Sun, 5 Apr 2009 02:13:43 +0300 Subject: Base mainloop on pa_rtclock_now() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/utils/pacat.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src/utils/pacat.c') diff --git a/src/utils/pacat.c b/src/utils/pacat.c index 0b6df3d8..f00a32eb 100644 --- a/src/utils/pacat.c +++ b/src/utils/pacat.c @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -583,9 +584,7 @@ static void sigusr1_signal_callback(pa_mainloop_api*m, pa_signal_event *e, int s pa_operation_unref(pa_stream_update_timing_info(stream, stream_update_timing_callback, NULL)); } -static void time_event_callback(pa_mainloop_api*m, pa_time_event *e, const struct timeval *tv, void *userdata) { - struct timeval next; - +static void time_event_callback(pa_mainloop_api *m, pa_time_event *e, const struct timeval *t, void *userdata) { if (stream && pa_stream_get_state(stream) == PA_STREAM_READY) { pa_operation *o; if (!(o = pa_stream_update_timing_info(stream, stream_update_timing_callback, NULL))) @@ -594,10 +593,7 @@ static void time_event_callback(pa_mainloop_api*m, pa_time_event *e, const struc pa_operation_unref(o); } - pa_gettimeofday(&next); - pa_timeval_add(&next, TIME_EVENT_USEC); - - m->time_restart(e, &next); + pa_context_rttime_restart(context, e, pa_rtclock_now() + TIME_EVENT_USEC); } static void help(const char *argv0) { @@ -1068,13 +1064,8 @@ int main(int argc, char *argv[]) { } if (verbose) { - struct timeval tv; - - pa_gettimeofday(&tv); - pa_timeval_add(&tv, TIME_EVENT_USEC); - - if (!(time_event = mainloop_api->time_new(mainloop_api, &tv, time_event_callback, NULL))) { - pa_log(_("time_new() failed.\n")); + if (!(time_event = pa_context_rttime_new(context, pa_rtclock_now() + TIME_EVENT_USEC, time_event_callback, NULL))) { + pa_log(_("pa_context_rttime_new() failed.\n")); goto quit; } } -- cgit