summaryrefslogtreecommitdiffstats
path: root/src/modules/module-card-restore.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/modules/module-card-restore.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/modules/module-card-restore.c')
-rw-r--r--src/modules/module-card-restore.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c
index 85583b2c..6b057b4c 100644
--- a/src/modules/module-card-restore.c
+++ b/src/modules/module-card-restore.c
@@ -35,6 +35,7 @@
#include <pulse/volume.h>
#include <pulse/timeval.h>
#include <pulse/util.h>
+#include <pulse/rtclock.h>
#include <pulsecore/core-error.h>
#include <pulsecore/module.h>
@@ -53,7 +54,7 @@ PA_MODULE_DESCRIPTION("Automatically restore profile of cards");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(TRUE);
-#define SAVE_INTERVAL 10
+#define SAVE_INTERVAL (10 * PA_USEC_PER_SEC)
static const char* const valid_modargs[] = {
NULL
@@ -75,12 +76,11 @@ struct entry {
char profile[PA_NAME_MAX];
} PA_GCC_PACKED ;
-static void save_time_callback(pa_mainloop_api*a, pa_time_event* e, const struct timeval *tv, void *userdata) {
+static void save_time_callback(pa_mainloop_api*a, pa_time_event* e, const struct timeval *t, void *userdata) {
struct userdata *u = userdata;
pa_assert(a);
pa_assert(e);
- pa_assert(tv);
pa_assert(u);
pa_assert(e == u->save_time_event);
@@ -132,14 +132,10 @@ fail:
}
static void trigger_save(struct userdata *u) {
- struct timeval tv;
-
if (u->save_time_event)
return;
- pa_gettimeofday(&tv);
- tv.tv_sec += SAVE_INTERVAL;
- u->save_time_event = u->core->mainloop->time_new(u->core->mainloop, &tv, save_time_callback, u);
+ u->save_time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + SAVE_INTERVAL, save_time_callback, u);
}
static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata) {