diff options
author | Georg Chini <georg@chini.tk> | 2017-12-03 22:27:53 +0100 |
---|---|---|
committer | Georg Chini <georg@chini.tk> | 2017-12-03 22:27:53 +0100 |
commit | e083357b88c6360edc3d8fe8bb1109c7f190709a (patch) | |
tree | 94cb3404d6600d785328dcab6a91944b329ec7da | |
parent | d6a0dcc3a2a9e73a7664be9ad62d7fffd1f926de (diff) | |
download | pulseaudio-e083357b88c6360edc3d8fe8bb1109c7f190709a.tar.gz |
switch-on-connect: add option to ignore virtual sinks/sources
module-switch-on-connect would switch to any new sink, even if the sink
was a filter or a null-sink.
This patch adds a command line option ignore_virtual to the module, which
lets module-switch-on-connect ignore virtual sinks and sources. The flag
is true by default because the purpose of the module is to switch to new
hardware when it becomes available.
-rw-r--r-- | src/modules/module-switch-on-connect.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/modules/module-switch-on-connect.c b/src/modules/module-switch-on-connect.c index 640024e95..0e2b32a97 100644 --- a/src/modules/module-switch-on-connect.c +++ b/src/modules/module-switch-on-connect.c @@ -41,15 +41,18 @@ PA_MODULE_VERSION(PACKAGE_VERSION); PA_MODULE_LOAD_ONCE(true); PA_MODULE_USAGE( "only_from_unavailable=<boolean, only switch from unavailable ports> " + "ignore_virtual=<boolean, ignore new virtual sinks and sources, defaults to true> " ); static const char* const valid_modargs[] = { "only_from_unavailable", + "ignore_virtual", NULL, }; struct userdata { bool only_from_unavailable; + bool ignore_virtual; }; static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, void* userdata) { @@ -75,6 +78,10 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, void* return PA_HOOK_OK; } + /* Ignore virtual sinks if not configured otherwise on the command line */ + if (u->ignore_virtual && !(sink->flags & PA_SINK_HARDWARE)) + return PA_HOOK_OK; + /* No default sink, nothing to move away, just set the new default */ if (!c->default_sink) { pa_core_set_configured_default_sink(c, sink->name); @@ -141,6 +148,10 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source, return PA_HOOK_OK; } + /* Ignore virtual sources if not configured otherwise on the command line */ + if (u->ignore_virtual && !(source->flags & PA_SOURCE_HARDWARE)) + return PA_HOOK_OK; + /* No default source, nothing to move away, just set the new default */ if (!c->default_source) { pa_core_set_configured_default_source(c, source->name); @@ -202,6 +213,12 @@ int pa__init(pa_module*m) { goto fail; } + u->ignore_virtual = true; + if (pa_modargs_get_value_boolean(ma, "ignore_virtual", &u->ignore_virtual) < 0) { + pa_log("Failed to get a boolean value for ignore_virtual."); + goto fail; + } + pa_modargs_free(ma); return 0; |