From aa5d56ba752490abb9a8a18081196d9de2f6976b Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Mon, 29 Jun 2009 20:10:04 +0100 Subject: [PATCH] device-manager: Only store and save details for non-monitor sources --- src/modules/module-device-manager.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/modules/module-device-manager.c b/src/modules/module-device-manager.c index 3ebdd48..77b6f2f 100644 --- a/src/modules/module-device-manager.c +++ b/src/modules/module-device-manager.c @@ -168,8 +168,8 @@ static pa_bool_t entries_equal(const struct entry *a, const struct entry *b) { 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; - char *name; + struct entry entry, *old = NULL; + char *name = NULL; pa_datum key, data; pa_assert(c); @@ -205,6 +205,9 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 if (!(source = pa_idxset_get_by_index(c->sources, idx))) return; + if (source->monitor_of) + return; + name = pa_sprintf_malloc("source:%s", source->name); if ((old = read_entry(u, name))) @@ -251,7 +254,7 @@ static pa_hook_result_t sink_new_hook_callback(pa_core *c, pa_sink_new_data *new if ((e = read_entry(u, name))) { if (strncmp(e->description, pa_proplist_gets(new_data->proplist, PA_PROP_DEVICE_DESCRIPTION), sizeof(e->description)) != 0) { - pa_log_info("Restoring description for sink %s.", name); + pa_log_info("Restoring description for sink %s.", new_data->name); pa_proplist_sets(new_data->proplist, PA_PROP_DEVICE_DESCRIPTION, e->description); } @@ -276,7 +279,8 @@ static pa_hook_result_t source_new_hook_callback(pa_core *c, pa_source_new_data if ((e = read_entry(u, name))) { if (strncmp(e->description, pa_proplist_gets(new_data->proplist, PA_PROP_DEVICE_DESCRIPTION), sizeof(e->description)) != 0) { - pa_log_info("Restoring description for sink %s.", name); + /* NB, We cannot detect if we are a monitor here... this could mess things up a bit... */ + pa_log_info("Restoring description for sink %s.", new_data->name); pa_proplist_sets(new_data->proplist, PA_PROP_DEVICE_DESCRIPTION, e->description); } @@ -325,6 +329,11 @@ static void apply_entry(struct userdata *u, const char *name, struct entry *e) { continue; } + if (source->monitor_of) { + pa_log_warn("Cowardly refusing to set the description for monitor source %s.", source->name); + continue; + } + pa_log_info("Setting description for source %s.", source->name); pa_source_set_description(source, e->description); } -- 2.7.4