mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
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.
This commit is contained in:
parent
d6a0dcc3a2
commit
e083357b88
1 changed files with 17 additions and 0 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue