diff options
author | Lennart Poettering <lennart@poettering.net> | 2008-08-04 18:56:12 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2008-08-04 18:56:12 +0200 |
commit | c01f0bc01ff1c4bdd3cbb66ae79e45c73add5011 (patch) | |
tree | 319c2405fee78672164b5aeac735cfc3c99f6dc0 /src/modules/module-device-restore.c | |
parent | 32cf9db43475b33fd43f28897e4fa9ca149aba2c (diff) | |
download | pulseaudio-c01f0bc01ff1c4bdd3cbb66ae79e45c73add5011.tar.gz |
split out save trigger function
Diffstat (limited to 'src/modules/module-device-restore.c')
-rw-r--r-- | src/modules/module-device-restore.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/modules/module-device-restore.c b/src/modules/module-device-restore.c index d93b9e639..fcd40219f 100644 --- a/src/modules/module-device-restore.c +++ b/src/modules/module-device-restore.c @@ -143,6 +143,17 @@ fail: return NULL; } +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); +} + static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata) { struct userdata *u = userdata; struct entry entry, *old; @@ -158,6 +169,8 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 t != (PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE)) return; + memset(&entry, 0, sizeof(entry)); + if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK) { pa_sink *sink; @@ -206,14 +219,9 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 gdbm_store(u->gdbm_file, key, data, GDBM_REPLACE); - if (!u->save_time_event) { - struct timeval tv; - 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); - } - pa_xfree(name); + + trigger_save(u); } static pa_hook_result_t sink_fixate_hook_callback(pa_core *c, pa_sink_new_data *new_data, struct userdata *u) { |