]> code.delx.au - pulseaudio/commitdiff
device-manager: Only store and save details for non-monitor sources
authorColin Guthrie <cguthrie@mandriva.org>
Mon, 29 Jun 2009 19:10:04 +0000 (20:10 +0100)
committerColin Guthrie <cguthrie@mandriva.org>
Thu, 1 Oct 2009 08:08:28 +0000 (09:08 +0100)
src/modules/module-device-manager.c

index 3ebdd48575c8f3f8bd4c9473a48afc3208d6e5c2..77b6f2fe4fb99e5063687ba7b65cd0e19e87538d 100644 (file)
@@ -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);
         }