[PATCH 04/11] Add names to routers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/modules/module-experimental-router.c |  2 +-
 src/modules/module-skoa-router.c         |  2 +-
 src/pulsecore/core.c                     | 12 ++++++++----
 src/pulsecore/router.c                   |  5 ++++-
 src/pulsecore/router.h                   |  3 ++-
 5 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/modules/module-experimental-router.c b/src/modules/module-experimental-router.c
index ac5f46e..0a127c4 100644
--- a/src/modules/module-experimental-router.c
+++ b/src/modules/module-experimental-router.c
@@ -93,7 +93,7 @@ int pa__init(pa_module *module) {
     pa_assert(module);
 
     module->userdata = u = pa_xnew0(struct userdata, 1);
-    u->router = pa_router_new(module->core);
+    u->router = pa_router_new(module->core, "module-experimental-router");
 
     if (!u->router)
         goto fail;
diff --git a/src/modules/module-skoa-router.c b/src/modules/module-skoa-router.c
index f763977..9406fef 100644
--- a/src/modules/module-skoa-router.c
+++ b/src/modules/module-skoa-router.c
@@ -45,7 +45,7 @@ int pa__init(pa_module *module) {
     pa_assert(module);
 
     module->userdata = u = pa_xnew0(struct userdata, 1);
-    u->router = pa_router_new(module->core);
+    u->router = pa_router_new(module->core, "module-skoa-router");
 
     if (!u->router)
         goto fail;
diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c
index 40f754c..7b34b12 100644
--- a/src/pulsecore/core.c
+++ b/src/pulsecore/core.c
@@ -33,6 +33,7 @@
 #include <pulse/xmalloc.h>
 
 #include <pulsecore/module.h>
+#include <pulsecore/router.h>
 #include <pulsecore/core-rtclock.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/core-scache.h>
@@ -218,19 +219,22 @@ static void core_free(pa_object *o) {
 }
 
 int pa_core_set_router(pa_core *c, pa_router *router) {
+    pa_router *old_router;
+
     pa_assert(c);
 
     if (c->router && router) {
-        pa_log("Tried to set the router when the router was already set.");
+        pa_log("Tried to set the router to %s, but the router is already set to %s.", router->name, c->router->name);
         return -1;
     }
 
+    old_router = c->router;
     c->router = router;
 
     if (c->router)
-        pa_log_info("Router set.");
-    else
-        pa_log_info("Router unset.");
+        pa_log_info("Router set to %s.", c->router->name);
+    else if (old_router)
+        pa_log_info("Router unset, was %s.", old_router->name);
 
     return 0;
 }
diff --git a/src/pulsecore/router.c b/src/pulsecore/router.c
index 509aef5..3accf75 100644
--- a/src/pulsecore/router.c
+++ b/src/pulsecore/router.c
@@ -27,13 +27,15 @@
 
 static void router_unlink(pa_router *router);
 
-pa_router *pa_router_new(pa_core *core) {
+pa_router *pa_router_new(pa_core *core, const char *name) {
     pa_router *router;
 
     pa_assert(core);
+    pa_assert(name);
 
     router = pa_xnew0(pa_router, 1);
     router->core = core;
+    router->name = pa_xstrdup(name);
 
     return router;
 }
@@ -71,6 +73,7 @@ void pa_router_free(pa_router *router) {
     pa_assert(router);
 
     router_unlink(router);
+    pa_xfree(router->name);
     pa_xfree(router);
 }
 
diff --git a/src/pulsecore/router.h b/src/pulsecore/router.h
index e27bb4a..e72d608 100644
--- a/src/pulsecore/router.h
+++ b/src/pulsecore/router.h
@@ -28,6 +28,7 @@ typedef struct pa_router pa_router;
 
 struct pa_router {
     pa_core *core;
+    char *name;
     bool registered;
 
     /* Called when a new node appears. May be NULL. */
@@ -48,7 +49,7 @@ struct pa_router {
     int (*set_card_profile)(pa_router *router, pa_card *card, pa_card_profile *profile, bool save);
 };
 
-pa_router *pa_router_new(pa_core *core);
+pa_router *pa_router_new(pa_core *core, const char *name);
 int pa_router_put(pa_router *router);
 void pa_router_free(pa_router *router);
 
-- 
1.8.3.1



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux