mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	switch-on-connect: Add debug logs
Log when module-switch-on-connect tries to change the default sink or source.
This commit is contained in:
		
							parent
							
								
									b53d817754
								
							
						
					
					
						commit
						b15f12ef66
					
				
					 1 changed files with 28 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -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;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue