[pulseaudio-commits] 2 commits - src/modules src/pulsecore
Georg Chini
gchini at kemper.freedesktop.org
Sun Dec 3 21:32:08 UTC 2017
src/modules/module-switch-on-connect.c | 17 +++++++++++++++++
src/pulsecore/sink.c | 6 ++++--
src/pulsecore/source.c | 6 ++++--
3 files changed, 25 insertions(+), 4 deletions(-)
New commits:
commit 59d264ac56d644f626251daa44ef7b39a9a9fe03
Author: Georg Chini <georg at chini.tk>
Date: Sun Dec 3 22:29:09 2017 +0100
sink, source: Don't finish move if unlink happens after pa_*_move_all_start()
When a sink input was unlinked between the calls to pa_sink_move_all_start() and
pa_sink_move_all_finish(), pa_sink_move_all_finish() tried to finish the move
of the already unlinked sink input, which lead to an assertion in
pa_sink_input_finish_move(). The same applies for the source side.
This patch fixes the problem by checking the state of the sink input or
source output in pa_*_move_all_finish().
Bug report: https://bugs.freedesktop.org/show_bug.cgi?id=103752
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 017b9539..39bf18f1 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -920,9 +920,11 @@ void pa_sink_move_all_finish(pa_sink *s, pa_queue *q, bool save) {
pa_assert(q);
while ((i = PA_SINK_INPUT(pa_queue_pop(q)))) {
- if (pa_sink_input_finish_move(i, s, save) < 0)
- pa_sink_input_fail_move(i);
+ if (PA_SINK_INPUT_IS_LINKED(i->state)) {
+ if (pa_sink_input_finish_move(i, s, save) < 0)
+ pa_sink_input_fail_move(i);
+ }
pa_sink_input_unref(i);
}
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index d579c357..6099c10d 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -860,9 +860,11 @@ void pa_source_move_all_finish(pa_source *s, pa_queue *q, bool save) {
pa_assert(q);
while ((o = PA_SOURCE_OUTPUT(pa_queue_pop(q)))) {
- if (pa_source_output_finish_move(o, s, save) < 0)
- pa_source_output_fail_move(o);
+ if (PA_SOURCE_OUTPUT_IS_LINKED(o->state)) {
+ if (pa_source_output_finish_move(o, s, save) < 0)
+ pa_source_output_fail_move(o);
+ }
pa_source_output_unref(o);
}
commit e083357b88c6360edc3d8fe8bb1109c7f190709a
Author: Georg Chini <georg at chini.tk>
Date: Sun Dec 3 22:27:53 2017 +0100
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.
diff --git a/src/modules/module-switch-on-connect.c b/src/modules/module-switch-on-connect.c
index 640024e9..0e2b32a9 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;
More information about the pulseaudio-commits
mailing list