[PATCH 5/7] switch-on-connect: Add debug logs

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

 



Log when module-switch-on-connect tries to change the default sink or
source.
---
 src/modules/module-switch-on-connect.c | 36 ++++++++++++++++++++------
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/src/modules/module-switch-on-connect.c b/src/modules/module-switch-on-connect.c
index f277c7945..ebdd6aad0 100644
--- a/src/modules/module-switch-on-connect.c
+++ b/src/modules/module-switch-on-connect.c
@@ -68,14 +68,20 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, void*
     if (c->state != PA_CORE_RUNNING)
         return PA_HOOK_OK;
 
+    pa_log_debug("Trying to switch to new sink %s", sink->name);
+
     /* Don't switch to any internal devices */
     s = pa_proplist_gets(sink->proplist, PA_PROP_DEVICE_BUS);
-    if (pa_safe_streq(s, "pci") || pa_safe_streq(s, "isa"))
+    if (pa_safe_streq(s, "pci") || pa_safe_streq(s, "isa")) {
+        pa_log_debug("Refusing to switch to sink on %s bus", s);
         return PA_HOOK_OK;
+    }
 
     /* Ignore virtual sinks if not configured otherwise on the command line */
-    if (u->ignore_virtual && !(sink->flags & PA_SINK_HARDWARE))
+    if (u->ignore_virtual && !(sink->flags & PA_SINK_HARDWARE)) {
+        pa_log_debug("Refusing to switch to virtual sink");
         return PA_HOOK_OK;
+    }
 
     /* No default sink, nothing to move away, just set the new default */
     if (!c->default_sink) {
@@ -83,12 +89,16 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, void*
         return PA_HOOK_OK;
     }
 
-    if (c->default_sink == sink)
+    if (c->default_sink == sink) {
+        pa_log_debug("%s already is the default sink", sink->name);
         return PA_HOOK_OK;
+    }
 
     if (u->only_from_unavailable)
-        if (!c->default_sink->active_port || c->default_sink->active_port->available != PA_AVAILABLE_NO)
+        if (!c->default_sink->active_port || c->default_sink->active_port->available != PA_AVAILABLE_NO) {
+            pa_log_debug("Current default sink is available and module argument only_from_unavailable was set");
             return PA_HOOK_OK;
+        }
 
     old_default_sink = c->default_sink;
 
@@ -135,14 +145,20 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source,
     if (source->monitor_of)
         return PA_HOOK_OK;
 
+    pa_log_debug("Trying to switch to new source %s", source->name);
+
     /* Don't switch to any internal devices */
     s = pa_proplist_gets(source->proplist, PA_PROP_DEVICE_BUS);
-    if (pa_safe_streq(s, "pci") || pa_safe_streq(s, "isa"))
+    if (pa_safe_streq(s, "pci") || pa_safe_streq(s, "isa")) {
+        pa_log_debug("Refusing to switch to source on %s bus", s);
         return PA_HOOK_OK;
+    }
 
     /* Ignore virtual sources if not configured otherwise on the command line */
-    if (u->ignore_virtual && !(source->flags & PA_SOURCE_HARDWARE))
+    if (u->ignore_virtual && !(source->flags & PA_SOURCE_HARDWARE)) {
+        pa_log_debug("Refusing to switch to virtual source");
         return PA_HOOK_OK;
+    }
 
     /* No default source, nothing to move away, just set the new default */
     if (!c->default_source) {
@@ -150,12 +166,16 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source,
         return PA_HOOK_OK;
     }
 
-    if (c->default_source == source)
+    if (c->default_source == source) {
+        pa_log_debug("%s already is the default source", source->name);
         return PA_HOOK_OK;
+    }
 
     if (u->only_from_unavailable)
-        if (!c->default_source->active_port || c->default_source->active_port->available != PA_AVAILABLE_NO)
+        if (!c->default_source->active_port || c->default_source->active_port->available != PA_AVAILABLE_NO) {
+            pa_log_debug("Current default source is available and module argument only_from_unavailable was set");
             return PA_HOOK_OK;
+        }
 
     old_default_source = c->default_source;
 
-- 
2.18.0



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

  Powered by Linux