summaryrefslogtreecommitdiffstats
path: root/src/utils/pacat.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marc-andre.lureau@nokia.com>2009-04-05 02:13:43 +0300
committerMarc-André Lureau <marcandre.lureau@gmail.com>2009-06-20 17:29:31 +0300
commit0955e3d45b6e992308e2d51fcbf28a9f9376f788 (patch)
tree4fc673713b46d0fdd33c5529d1a06354db9d33ba /src/utils/pacat.c
parent125c52889626b2ac408ecbcc8ea85575f5808e07 (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/utils/pacat.c')
-rw-r--r--src/utils/pacat.c19
1 files changed, 5 insertions, 14 deletions
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 <pulse/i18n.h>
#include <pulse/pulseaudio.h>
+#include <pulse/rtclock.h>
#include <pulsecore/macro.h>
#include <pulsecore/core-util.h>
@@ -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;
}
}