source: Remove output_from_master field

The only source still using the output_from_master field of the source structure
was module-echo-cancel. Due to the differences between the echo-cancel source
and the other virtual sources, consolidation did not seem useful. To faciliate
removing the output_from_master field from the source, a dummy vsource structure
was created for module-echo-cancel. After that, the output_from_master field was
removed.
This commit is contained in:
Georg Chini 2021-02-01 18:57:36 +01:00
parent 5d05301663
commit 664d175da8
7 changed files with 27 additions and 64 deletions

View file

@ -34,6 +34,7 @@
#include "echo-cancel.h"
#include <modules/virtual-sink-common.h>
#include <modules/virtual-source-common.h>
#include <pulse/xmalloc.h>
#include <pulse/timeval.h>
@ -222,6 +223,7 @@ struct userdata {
pa_rtpoll_item *rtpoll_item_read, *rtpoll_item_write;
pa_source *source;
pa_vsource *vsource;
bool source_auto_desc;
pa_source_output *source_output;
pa_memblockq *source_memblockq; /* echo canceller needs fixed sized chunks */
@ -1731,6 +1733,10 @@ int pa__init(pa_module*m) {
pa_source_set_asyncmsgq(u->source, source_master->asyncmsgq);
/* Create vsource structure. Only needed for output_from_master field, otherwise
* unused because the virtual source here is too different from other filters */
u->vsource = pa_virtual_source_vsource_new(u->source);
/* Create sink */
pa_sink_new_data_init(&sink_data);
sink_data.driver = __FILE__;
@ -1817,7 +1823,7 @@ int pa__init(pa_module*m) {
u->source_output->moving = source_output_moving_cb;
u->source_output->userdata = u;
u->source->output_from_master = u->source_output;
u->vsource->output_from_master = u->source_output;
/* Create sink input */
pa_sink_input_new_data_init(&sink_input_data);
@ -1987,6 +1993,9 @@ void pa__done(pa_module*m) {
if (u->vsink)
pa_xfree(u->vsink);
if (u->vsource)
pa_xfree(u->vsource);
if (u->source)
pa_source_unref(u->source);
if (u->sink)

View file

@ -273,7 +273,7 @@ module_echo_cancel_sources = [
module_echo_cancel_orc_sources = []
module_echo_cancel_flags = []
module_echo_cancel_deps = [libatomic_ops_dep]
module_echo_cancel_libs = [libvirtual_sink]
module_echo_cancel_libs = [libvirtual_sink, libvirtual_source]
if get_option('adrian-aec')
module_echo_cancel_sources += [

View file

@ -272,10 +272,7 @@ static bool find_paired_master(struct userdata *u, struct filter *filter, pa_obj
}
/* Make sure we're not routing to another instance of
* the same filter. */
if (so->source->vsource)
filter->source_master = so->source->vsource->output_from_master->source;
else
filter->source_master = so->source->output_from_master->source;
filter->source_master = so->source->vsource->output_from_master->source;
} else {
filter->source_master = so->source;
}
@ -477,18 +474,12 @@ static void find_filters_for_module(struct userdata *u, pa_module *m, const char
pa_assert(pa_source_is_filter(source));
if (!fltr) {
if (source->vsource)
fltr = filter_new(name, parameters, NULL, source->vsource->output_from_master->source);
else
fltr = filter_new(name, parameters, NULL, source->output_from_master->source);
fltr = filter_new(name, parameters, NULL, source->vsource->output_from_master->source);
fltr->module_index = m->index;
fltr->source = source;
} else {
fltr->source = source;
if (source->vsource)
fltr->source_master = source->vsource->output_from_master->source;
else
fltr->source_master = source->output_from_master->source;
fltr->source_master = source->vsource->output_from_master->source;
}
break;

View file

@ -529,7 +529,6 @@ void pa_core_update_default_sink(pa_core *core) {
* a > b -> return 1 */
static int compare_sources(pa_source *a, pa_source *b, bool ignore_configured_virtual_default) {
pa_core *core;
bool a_is_vsource, b_is_vsource;
core = a->core;
@ -573,25 +572,10 @@ static int compare_sources(pa_source *a, pa_source *b, bool ignore_configured_vi
if (a->priority > b->priority)
return 1;
/* Let sources like pipe source or null source win against filter sources
During consolidation, we have to detect the presence of the vsource or
output_to_master variable. When the virtual sources have been migrated,
this will simplify. */
a_is_vsource = false;
if (a->vsource)
a_is_vsource = true;
else if (a->output_from_master)
a_is_vsource = true;
b_is_vsource = false;
if (b->vsource)
b_is_vsource = true;
else if (b->output_from_master)
b_is_vsource = true;
if (a_is_vsource && !b_is_vsource)
/* Let sources like pipe source or null source win against filter sources */
if (a->vsource && !b->vsource)
return -1;
if (!a_is_vsource && b_is_vsource)
if (!a->vsource && b->vsource)
return 1;
/* If the sources are monitors, we can compare the monitored sinks. */

View file

@ -1307,19 +1307,10 @@ bool pa_source_output_may_move(pa_source_output *o) {
bool pa_source_output_is_filter_loop(pa_source_output *target, pa_source *s) {
unsigned PA_UNUSED i = 0;
/* During consolidation, we have to support s->output_from_master and
* s->vsource->output_from_master. The first will disappear after all
* virtual sources use the new code. */
while (s && (s->output_from_master || (s->vsource && s->vsource->output_from_master))) {
if (s->vsource) {
if (s->vsource->output_from_master == target)
return true;
s = s->vsource->output_from_master->source;
} else {
if (s->output_from_master == target)
return true;
s = s->output_from_master->source;
}
while (s && (s->vsource && s->vsource->output_from_master)) {
if (s->vsource->output_from_master == target)
return true;
s = s->vsource->output_from_master->source;
pa_assert(i++ < 100);
}
return false;
@ -1331,11 +1322,8 @@ static bool is_filter_source_moving(pa_source_output *o) {
if (!source)
return false;
while (source->output_from_master || (source->vsource && source->vsource->output_from_master)) {
if (source->vsource)
source = source->vsource->output_from_master->source;
else
source = source->output_from_master->source;
while (source->vsource && source->vsource->output_from_master) {
source = source->vsource->output_from_master->source;
if (!source)
return true;

View file

@ -273,7 +273,7 @@ pa_source* pa_source_new(
s->outputs = pa_idxset_new(NULL, NULL);
s->n_corked = 0;
s->monitor_of = NULL;
s->output_from_master = NULL;
s->vsource = NULL;
s->reference_volume = s->real_volume = data->volume;
pa_cvolume_reset(&s->soft_volume, s->sample_spec.channels);
@ -1234,19 +1234,11 @@ bool pa_source_flat_volume_enabled(pa_source *s) {
pa_source *pa_source_get_master(pa_source *s) {
pa_source_assert_ref(s);
/* During consolidation, we have to support s->output_from_master and
* s->vsource->output_from_master. The first will disappear after all
* virtual sources use the new code. */
while (s && (s->flags & PA_SOURCE_SHARE_VOLUME_WITH_MASTER)) {
if (PA_UNLIKELY(s->vsource && !s->vsource->output_from_master))
if (PA_UNLIKELY(!s->vsource || (s->vsource && !s->vsource->output_from_master)))
return NULL;
if (PA_UNLIKELY(!s->vsource && !s->output_from_master))
return NULL;
if (s->output_from_master)
s = s->output_from_master->source;
else
s = s->vsource->output_from_master->source;
s = s->vsource->output_from_master->source;
}
return s;
@ -1256,7 +1248,7 @@ pa_source *pa_source_get_master(pa_source *s) {
bool pa_source_is_filter(pa_source *s) {
pa_source_assert_ref(s);
return ((s->output_from_master != NULL || s->vsource->output_from_master != NULL));
return (s->vsource->output_from_master != NULL);
}
/* Called from main context */

View file

@ -162,7 +162,6 @@ struct pa_source {
pa_idxset *outputs;
unsigned n_corked;
pa_sink *monitor_of; /* may be NULL */
pa_source_output *output_from_master; /* non-NULL only for filter sources */
pa_vsource *vsource; /* non-NULL only for filter sources */
pa_volume_t base_volume; /* shall be constant */