From 45a4d26aca37abd917c784ec8a40d26acc02246f Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sun, 27 Sep 2009 16:55:31 +0100 Subject: device-manager: Don't notify clients on every subscription (it happens all the time). Also compare the entries fully before saving. --- src/modules/module-device-manager.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/modules/module-device-manager.c b/src/modules/module-device-manager.c index 0764ad02..89fb4609 100644 --- a/src/modules/module-device-manager.c +++ b/src/modules/module-device-manager.c @@ -323,10 +323,18 @@ static void trigger_save(struct userdata *u) { } static pa_bool_t entries_equal(const struct entry *a, const struct entry *b) { - /** @todo: Compare the priority lists too */ - if (strncmp(a->description, b->description, sizeof(a->description))) + + pa_assert(a); + pa_assert(b); + + if (strncmp(a->description, b->description, sizeof(a->description)) + || strncmp(a->icon, b->icon, sizeof(a->icon))) return FALSE; + for (int i=0; i < NUM_ROLES; ++i) + if (a->priority[i] != b->priority[i]) + return FALSE; + return TRUE; } @@ -699,10 +707,6 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 pa_xfree(old); pa_xfree(name); - /* Even if the entries are equal, the availability or otherwise - of the sink/source may have changed so we notify clients all the same */ - notify_subscribers(u); - return; } @@ -857,6 +861,8 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, PA_GCC_UNUSED pa_sink pa_assert(u->core == c); pa_assert(u->on_hotplug); + notify_subscribers(u); + return route_sink_inputs(u, NULL); } @@ -866,6 +872,8 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, PA_GCC_UNUSED pa_so pa_assert(u->core == c); pa_assert(u->on_hotplug); + notify_subscribers(u); + return route_source_outputs(u, NULL); } @@ -880,6 +888,8 @@ static pa_hook_result_t sink_unlink_hook_callback(pa_core *c, pa_sink *sink, str if (c->state == PA_CORE_SHUTDOWN) return PA_HOOK_OK; + notify_subscribers(u); + return route_sink_inputs(u, sink); } @@ -894,6 +904,8 @@ static pa_hook_result_t source_unlink_hook_callback(pa_core *c, pa_source *sourc if (c->state == PA_CORE_SHUTDOWN) return PA_HOOK_OK; + notify_subscribers(u); + return route_source_outputs(u, source); } -- cgit