+ pa_xfree(c);
+}
+
+static void quit_callback(struct pa_mainloop_api*m, struct pa_time_event *e, const struct timeval *tv, void *userdata) {
+ struct pa_core *c = userdata;
+ assert(c->quit_event = e);
+
+ m->quit(m, 0);
+}
+
+void pa_core_check_quit(struct pa_core *c) {
+ assert(c);
+
+ if (!c->quit_event && c->exit_idle_time >= 0 && pa_idxset_ncontents(c->clients) == 0) {
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ tv.tv_sec+= c->exit_idle_time;
+ c->quit_event = c->mainloop->time_new(c->mainloop, &tv, quit_callback, c);
+ } else if (c->quit_event && pa_idxset_ncontents(c->clients) > 0) {
+ c->mainloop->time_free(c->quit_event);
+ c->quit_event = NULL;
+ }
+}