From 59bd793734d71c6baa5ed35044f18165ffe9685c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 18 Jun 2009 00:58:19 +0200 Subject: card-restore: we don't need to save card data that came from the database --- src/modules/module-card-restore.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/modules/module-card-restore.c') diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c index 85478d12..62c50616 100644 --- a/src/modules/module-card-restore.c +++ b/src/modules/module-card-restore.c @@ -197,8 +197,9 @@ static pa_hook_result_t card_new_hook_callback(pa_core *c, pa_card_new_data *new if ((e = read_entry(u, new_data->name)) && e->profile[0]) { if (!new_data->active_profile) { - pa_card_new_data_set_profile(new_data, e->profile); pa_log_info("Restoring profile for card %s.", new_data->name); + pa_card_new_data_set_profile(new_data, e->profile); + new_data->save_profile = FALSE; } else pa_log_debug("Not restoring profile for card %s, because already set.", new_data->name); -- cgit From 4951e08031a74864b889ecdaaa3bcaa3a1f0ceb7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 18 Jun 2009 00:59:33 +0200 Subject: card,stream-restore: minor cleanups --- src/modules/module-card-restore.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/modules/module-card-restore.c') diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c index 62c50616..85583b2c 100644 --- a/src/modules/module-card-restore.c +++ b/src/modules/module-card-restore.c @@ -223,11 +223,9 @@ int pa__init(pa_module*m) { goto fail; } - m->userdata = u = pa_xnew(struct userdata, 1); + m->userdata = u = pa_xnew0(struct userdata, 1); u->core = m->core; u->module = m; - u->save_time_event = NULL; - u->database = NULL; u->subscription = pa_subscription_new(m->core, PA_SUBSCRIPTION_MASK_CARD, subscribe_callback, u); -- cgit 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/modules/module-card-restore.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/modules/module-card-restore.c') 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 #include #include +#include #include #include @@ -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) { -- cgit From c4d90ea98617026fbeb9f8bc11e98ab528338274 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 22 Jun 2009 22:33:09 +0200 Subject: restore: change 'save' flag behaviour to reflect whether an entry shall and/or is in the on-disk databases --- src/modules/module-card-restore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules/module-card-restore.c') diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c index 85583b2c..ec55371c 100644 --- a/src/modules/module-card-restore.c +++ b/src/modules/module-card-restore.c @@ -199,7 +199,7 @@ static pa_hook_result_t card_new_hook_callback(pa_core *c, pa_card_new_data *new if (!new_data->active_profile) { pa_log_info("Restoring profile for card %s.", new_data->name); pa_card_new_data_set_profile(new_data, e->profile); - new_data->save_profile = FALSE; + new_data->save_profile = TRUE; } else pa_log_debug("Not restoring profile for card %s, because already set.", new_data->name); -- cgit