[pulseaudio-discuss] [PATCH v2 4/4] Revert "card: Support adding ports dynamically"

Mikel Astiz mikel.astiz.oss at gmail.com
Mon Mar 4 07:38:34 PST 2013


From: Mikel Astiz <mikel.astiz at bmw-carit.de>

This reverts commit a9c3f2fb0fc1a1ee0072aac6425ad7311a2a5888.

It has been recently agreed that ports should somehow have some physical
meaning, leading to the port merge in module-bluetooth-device.

With this assumption in mind, it is very unlikely that a card would
add or remove ports dynamically. Therefore, the core can be simplified
by removing the support for this.

The revert affects the code added to module-card-restore in commit
a1a0ad1af209e58c136ac1c884aa5d14672a7144, which can now be partially
removed.

Conflicts:
	src/pulsecore/card.c
	src/pulsecore/core.h
---
 src/modules/module-card-restore.c | 43 ---------------------------------------
 src/pulsecore/card.c              | 19 -----------------
 src/pulsecore/card.h              |  1 -
 src/pulsecore/core.h              |  1 -
 4 files changed, 64 deletions(-)

diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c
index 3b061b6..2b3235c 100644
--- a/src/modules/module-card-restore.c
+++ b/src/modules/module-card-restore.c
@@ -65,7 +65,6 @@ struct userdata {
     pa_hook_slot *card_new_hook_slot;
     pa_hook_slot *card_put_hook_slot;
     pa_hook_slot *card_profile_hook_slot;
-    pa_hook_slot *port_new_hook_slot;
     pa_hook_slot *port_offset_hook_slot;
     pa_time_event *save_time_event;
     pa_database *database;
@@ -127,15 +126,6 @@ static struct port_info *port_info_new(pa_device_port *port) {
     return p_info;
 }
 
-static void port_info_update(struct port_info *p_info, pa_device_port *port) {
-    pa_assert(p_info);
-    pa_assert(port);
-
-    pa_xfree(p_info->name);
-    p_info->name = pa_xstrdup(port->name);
-    p_info->offset = port->latency_offset;
-}
-
 static void port_info_free(struct port_info *p_info) {
     pa_assert(p_info);
 
@@ -413,37 +403,6 @@ static pa_hook_result_t card_profile_change_callback(pa_core *c, pa_card *card,
     return PA_HOOK_OK;
 }
 
-static pa_hook_result_t card_port_add_callback(pa_core *c, pa_device_port *port, struct userdata *u) {
-    struct entry *entry;
-    pa_card *card;
-
-    pa_assert(port);
-    card = port->card;
-
-    if ((entry = entry_read(u, card->name))) {
-        struct port_info *p_info;
-
-        if ((p_info = pa_hashmap_get(entry->ports, port->name)))
-            port_info_update(p_info, port);
-        else {
-            p_info = port_info_new(port);
-            pa_assert_se(pa_hashmap_put(entry->ports, p_info->name, p_info) >= 0);
-        }
-
-        pa_log_info("Storing port info for port %s on card %s.", port->name, card->name);
-
-    } else {
-        entry = entry_from_card(card);
-        show_full_info(card);
-    }
-
-    if (entry_write(u, card->name, entry))
-        trigger_save(u);
-
-    entry_free(entry);
-    return PA_HOOK_OK;
-}
-
 static pa_hook_result_t port_offset_change_callback(pa_core *c, pa_device_port *port, struct userdata *u) {
     struct entry *entry;
     pa_card *card;
@@ -529,7 +488,6 @@ int pa__init(pa_module*m) {
     u->card_new_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_CARD_NEW], PA_HOOK_EARLY, (pa_hook_cb_t) card_new_hook_callback, u);
     u->card_put_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_CARD_PUT], PA_HOOK_NORMAL, (pa_hook_cb_t) card_put_hook_callback, u);
     u->card_profile_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_CARD_PROFILE_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) card_profile_change_callback, u);
-    u->port_new_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_PORT_ADDED], PA_HOOK_NORMAL, (pa_hook_cb_t) card_port_add_callback, u);
     u->port_offset_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_PORT_LATENCY_OFFSET_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) port_offset_change_callback, u);
     u->hooks_connected = true;
 
@@ -569,7 +527,6 @@ void pa__done(pa_module*m) {
         pa_hook_slot_free(u->card_new_hook_slot);
         pa_hook_slot_free(u->card_put_hook_slot);
         pa_hook_slot_free(u->card_profile_hook_slot);
-        pa_hook_slot_free(u->port_new_hook_slot);
         pa_hook_slot_free(u->port_offset_hook_slot);
     }
 
diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
index 6149d2b..7cf45df 100644
--- a/src/pulsecore/card.c
+++ b/src/pulsecore/card.c
@@ -114,25 +114,6 @@ void pa_card_add_profile(pa_card *c, pa_card_profile *profile) {
     pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_CARD_PROFILE_ADDED], profile);
 }
 
-void pa_card_add_ports(pa_card *c, pa_hashmap *ports) {
-    pa_device_port *p;
-    void *state;
-
-    pa_assert(c);
-    pa_assert(ports);
-
-    /* take ownership of the ports */
-    PA_HASHMAP_FOREACH(p, ports, state) {
-        p->card = c;
-        pa_assert_se(pa_hashmap_put(c->ports, p->name, p) >= 0);
-    }
-
-    pa_subscription_post(c->core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, c->index);
-
-    while ((p = pa_hashmap_steal_first(ports)) != NULL)
-        pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_PORT_ADDED], p);
-}
-
 void pa_card_new_data_set_profile(pa_card_new_data *data, const char *profile) {
     pa_assert(data);
 
diff --git a/src/pulsecore/card.h b/src/pulsecore/card.h
index 393dbac..32deb7b 100644
--- a/src/pulsecore/card.h
+++ b/src/pulsecore/card.h
@@ -114,7 +114,6 @@ pa_card *pa_card_new(pa_core *c, pa_card_new_data *data);
 void pa_card_free(pa_card *c);
 
 void pa_card_add_profile(pa_card *c, pa_card_profile *profile);
-void pa_card_add_ports(pa_card *c, pa_hashmap *ports);
 
 int pa_card_set_profile(pa_card *c, const char *name, pa_bool_t save);
 
diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
index 381897a..533ba9e 100644
--- a/src/pulsecore/core.h
+++ b/src/pulsecore/core.h
@@ -116,7 +116,6 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_CARD_PROFILE_ADDED,
     PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED,
     PA_CORE_HOOK_PORT_AVAILABLE_CHANGED,
-    PA_CORE_HOOK_PORT_ADDED,
     PA_CORE_HOOK_PORT_LATENCY_OFFSET_CHANGED,
     PA_CORE_HOOK_MAX
 } pa_core_hook_t;
-- 
1.8.1.2



More information about the pulseaudio-discuss mailing list