mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
echo-cancel: Use volume sharing by default
Uses the shared volume infrastructure by default with an option to fallback on the old pretend-volume-sharing-that-kind-of-works if someone wants it that way. Users who keep left != right (or any sort of unbalanced channel volumes) will likely want to disable shared volumes since it will cause their master sink/source volume to be balanced. This really isn't a very pleasant scenario since users would need to manually set up echo cancellation in their config for this (until we have a way to store module configuration). That said, the majority case benefits from the volume sharing, so let's not wait for the configuration infrastructure to be ready to use this.
This commit is contained in:
parent
ec099f9306
commit
38be4a2d44
2 changed files with 24 additions and 11 deletions
|
|
@ -1734,7 +1734,7 @@ module_echo_cancel_la_SOURCES = \
|
||||||
modules/echo-cancel/adrian.c modules/echo-cancel/adrian.h
|
modules/echo-cancel/adrian.c modules/echo-cancel/adrian.h
|
||||||
module_echo_cancel_la_LDFLAGS = $(MODULE_LDFLAGS)
|
module_echo_cancel_la_LDFLAGS = $(MODULE_LDFLAGS)
|
||||||
module_echo_cancel_la_LIBADD = $(MODULE_LIBADD) $(LIBSPEEX_LIBS)
|
module_echo_cancel_la_LIBADD = $(MODULE_LIBADD) $(LIBSPEEX_LIBS)
|
||||||
module_echo_cancel_la_CFLAGS = $(AM_CFLAGS) $(LIBSPEEX_CFLAGS)
|
module_echo_cancel_la_CFLAGS = $(AM_CFLAGS) $(SERVER_CFLAGS) $(LIBSPEEX_CFLAGS)
|
||||||
if HAVE_ORC
|
if HAVE_ORC
|
||||||
ORC_SOURCE += modules/echo-cancel/adrian-aec
|
ORC_SOURCE += modules/echo-cancel/adrian-aec
|
||||||
nodist_module_echo_cancel_la_SOURCES = \
|
nodist_module_echo_cancel_la_SOURCES = \
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ PA_MODULE_USAGE(
|
||||||
"aec_args=<parameters for the AEC engine> "
|
"aec_args=<parameters for the AEC engine> "
|
||||||
"save_aec=<save AEC data in /tmp> "
|
"save_aec=<save AEC data in /tmp> "
|
||||||
"autoloaded=<set if this module is being loaded automatically> "
|
"autoloaded=<set if this module is being loaded automatically> "
|
||||||
|
"use_volume_sharing=<yes or no> "
|
||||||
));
|
));
|
||||||
|
|
||||||
/* NOTE: Make sure the enum and ec_table are maintained in the correct order */
|
/* NOTE: Make sure the enum and ec_table are maintained in the correct order */
|
||||||
|
|
@ -212,6 +213,7 @@ static const char* const valid_modargs[] = {
|
||||||
"aec_args",
|
"aec_args",
|
||||||
"save_aec",
|
"save_aec",
|
||||||
"autoloaded",
|
"autoloaded",
|
||||||
|
"use_volume_sharing",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1334,6 +1336,7 @@ int pa__init(pa_module*m) {
|
||||||
pa_memchunk silence;
|
pa_memchunk silence;
|
||||||
pa_echo_canceller_method_t ec_method;
|
pa_echo_canceller_method_t ec_method;
|
||||||
uint32_t adjust_time_sec;
|
uint32_t adjust_time_sec;
|
||||||
|
pa_bool_t use_volume_sharing = TRUE;
|
||||||
|
|
||||||
pa_assert(m);
|
pa_assert(m);
|
||||||
|
|
||||||
|
|
@ -1366,6 +1369,11 @@ int pa__init(pa_module*m) {
|
||||||
sink_ss = sink_master->sample_spec;
|
sink_ss = sink_master->sample_spec;
|
||||||
sink_map = sink_master->channel_map;
|
sink_map = sink_master->channel_map;
|
||||||
|
|
||||||
|
if (pa_modargs_get_value_boolean(ma, "use_volume_sharing", &use_volume_sharing) < 0) {
|
||||||
|
pa_log("use_volume_sharing= expects a boolean argument");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
u = pa_xnew0(struct userdata, 1);
|
u = pa_xnew0(struct userdata, 1);
|
||||||
if (!u) {
|
if (!u) {
|
||||||
pa_log("Failed to alloc userdata");
|
pa_log("Failed to alloc userdata");
|
||||||
|
|
@ -1450,8 +1458,8 @@ int pa__init(pa_module*m) {
|
||||||
pa_proplist_setf(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Echo-Cancel Source %s on %s", source_data.name, z ? z : source_master->name);
|
pa_proplist_setf(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Echo-Cancel Source %s on %s", source_data.name, z ? z : source_master->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
u->source = pa_source_new(m->core, &source_data,
|
u->source = pa_source_new(m->core, &source_data, (source_master->flags & (PA_SOURCE_LATENCY | PA_SOURCE_DYNAMIC_LATENCY))
|
||||||
(source_master->flags & (PA_SOURCE_LATENCY|PA_SOURCE_DYNAMIC_LATENCY)));
|
| (use_volume_sharing ? PA_SOURCE_SHARE_VOLUME_WITH_MASTER : 0));
|
||||||
pa_source_new_data_done(&source_data);
|
pa_source_new_data_done(&source_data);
|
||||||
|
|
||||||
if (!u->source) {
|
if (!u->source) {
|
||||||
|
|
@ -1462,11 +1470,13 @@ int pa__init(pa_module*m) {
|
||||||
u->source->parent.process_msg = source_process_msg_cb;
|
u->source->parent.process_msg = source_process_msg_cb;
|
||||||
u->source->set_state = source_set_state_cb;
|
u->source->set_state = source_set_state_cb;
|
||||||
u->source->update_requested_latency = source_update_requested_latency_cb;
|
u->source->update_requested_latency = source_update_requested_latency_cb;
|
||||||
pa_source_enable_decibel_volume(u->source, TRUE);
|
|
||||||
pa_source_set_get_volume_callback(u->source, source_get_volume_cb);
|
|
||||||
pa_source_set_set_volume_callback(u->source, source_set_volume_cb);
|
|
||||||
pa_source_set_get_mute_callback(u->source, source_get_mute_cb);
|
pa_source_set_get_mute_callback(u->source, source_get_mute_cb);
|
||||||
pa_source_set_set_mute_callback(u->source, source_set_mute_cb);
|
pa_source_set_set_mute_callback(u->source, source_set_mute_cb);
|
||||||
|
if (!use_volume_sharing) {
|
||||||
|
pa_source_set_get_volume_callback(u->source, source_get_volume_cb);
|
||||||
|
pa_source_set_set_volume_callback(u->source, source_set_volume_cb);
|
||||||
|
pa_source_enable_decibel_volume(u->source, TRUE);
|
||||||
|
}
|
||||||
u->source->userdata = u;
|
u->source->userdata = u;
|
||||||
|
|
||||||
pa_source_set_asyncmsgq(u->source, source_master->asyncmsgq);
|
pa_source_set_asyncmsgq(u->source, source_master->asyncmsgq);
|
||||||
|
|
@ -1498,8 +1508,8 @@ int pa__init(pa_module*m) {
|
||||||
pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Echo-Cancel Sink %s on %s", sink_data.name, z ? z : sink_master->name);
|
pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Echo-Cancel Sink %s on %s", sink_data.name, z ? z : sink_master->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
u->sink = pa_sink_new(m->core, &sink_data,
|
u->sink = pa_sink_new(m->core, &sink_data, (sink_master->flags & (PA_SINK_LATENCY | PA_SINK_DYNAMIC_LATENCY))
|
||||||
(sink_master->flags & (PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY)));
|
| (use_volume_sharing ? PA_SINK_SHARE_VOLUME_WITH_MASTER : 0));
|
||||||
pa_sink_new_data_done(&sink_data);
|
pa_sink_new_data_done(&sink_data);
|
||||||
|
|
||||||
if (!u->sink) {
|
if (!u->sink) {
|
||||||
|
|
@ -1511,9 +1521,11 @@ int pa__init(pa_module*m) {
|
||||||
u->sink->set_state = sink_set_state_cb;
|
u->sink->set_state = sink_set_state_cb;
|
||||||
u->sink->update_requested_latency = sink_update_requested_latency_cb;
|
u->sink->update_requested_latency = sink_update_requested_latency_cb;
|
||||||
u->sink->request_rewind = sink_request_rewind_cb;
|
u->sink->request_rewind = sink_request_rewind_cb;
|
||||||
pa_sink_enable_decibel_volume(u->sink, TRUE);
|
|
||||||
pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
|
|
||||||
pa_sink_set_set_mute_callback(u->sink, sink_set_mute_cb);
|
pa_sink_set_set_mute_callback(u->sink, sink_set_mute_cb);
|
||||||
|
if (!use_volume_sharing) {
|
||||||
|
pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
|
||||||
|
pa_sink_enable_decibel_volume(u->sink, TRUE);
|
||||||
|
}
|
||||||
u->sink->userdata = u;
|
u->sink->userdata = u;
|
||||||
|
|
||||||
pa_sink_set_asyncmsgq(u->sink, sink_master->asyncmsgq);
|
pa_sink_set_asyncmsgq(u->sink, sink_master->asyncmsgq);
|
||||||
|
|
@ -1587,7 +1599,8 @@ int pa__init(pa_module*m) {
|
||||||
u->sink_input->state_change = sink_input_state_change_cb;
|
u->sink_input->state_change = sink_input_state_change_cb;
|
||||||
u->sink_input->may_move_to = sink_input_may_move_to_cb;
|
u->sink_input->may_move_to = sink_input_may_move_to_cb;
|
||||||
u->sink_input->moving = sink_input_moving_cb;
|
u->sink_input->moving = sink_input_moving_cb;
|
||||||
u->sink_input->volume_changed = sink_input_volume_changed_cb;
|
if (!use_volume_sharing)
|
||||||
|
u->sink_input->volume_changed = sink_input_volume_changed_cb;
|
||||||
u->sink_input->mute_changed = sink_input_mute_changed_cb;
|
u->sink_input->mute_changed = sink_input_mute_changed_cb;
|
||||||
u->sink_input->userdata = u;
|
u->sink_input->userdata = u;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue