diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index 4277301..2ce59c2 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -81,6 +81,7 @@ static const pa_daemon_conf default_conf = { .log_meta = false, .log_time = false, .resample_method = PA_RESAMPLER_AUTO, + .mono_only_remixing = false, .disable_remixing = false, .disable_lfe_remixing = true, .lfe_crossover_freq = 0, @@ -552,6 +553,7 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) { { "deferred-volume-extra-delay-usec", pa_config_parse_int, &c->deferred_volume_extra_delay_usec, NULL }, { "nice-level", parse_nice_level, c, NULL }, + { "mono-only-remixing", pa_config_parse_bool, &c->mono_only_remixing, NULL }, { "disable-remixing", pa_config_parse_bool, &c->disable_remixing, NULL }, { "enable-remixing", pa_config_parse_not_bool, &c->disable_remixing, NULL }, { "disable-lfe-remixing", pa_config_parse_bool, &c->disable_lfe_remixing, NULL }, @@ -747,6 +749,7 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) { pa_strbuf_printf(s, "log-target = %s\n", pa_strempty(log_target)); pa_strbuf_printf(s, "log-level = %s\n", log_level_to_string[c->log_level]); pa_strbuf_printf(s, "resample-method = %s\n", pa_resample_method_to_string(c->resample_method)); + pa_strbuf_printf(s, "mono-only-remixing = %s\n", pa_yes_no(c->mono_only_remixing)); pa_strbuf_printf(s, "enable-remixing = %s\n", pa_yes_no(!c->disable_remixing)); pa_strbuf_printf(s, "enable-lfe-remixing = %s\n", pa_yes_no(!c->disable_lfe_remixing)); pa_strbuf_printf(s, "lfe-crossover-freq = %u\n", c->lfe_crossover_freq); diff --git a/src/daemon/daemon-conf.h b/src/daemon/daemon-conf.h index 82b619f..a2ed578 100644 --- a/src/daemon/daemon-conf.h +++ b/src/daemon/daemon-conf.h @@ -67,6 +67,7 @@ typedef struct pa_daemon_conf { no_cpu_limit, disable_shm, disable_memfd, + mono_only_remixing, disable_remixing, disable_lfe_remixing, load_default_script_file, diff --git a/src/daemon/daemon.conf.in b/src/daemon/daemon.conf.in index fcc9cb9..f79198a 100644 --- a/src/daemon/daemon.conf.in +++ b/src/daemon/daemon.conf.in @@ -53,6 +53,7 @@ ifelse(@HAVE_DBUS@, 1, [dnl ; log-backtrace = 0 ; resample-method = speex-float-1 +; mono-only-remixing = no ; enable-remixing = yes ; enable-lfe-remixing = no ; lfe-crossover-freq = 0 diff --git a/src/daemon/main.c b/src/daemon/main.c index ae1185d..8de6c9b 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -1037,6 +1037,7 @@ int main(int argc, char *argv[]) { c->resample_method = conf->resample_method; c->realtime_priority = conf->realtime_priority; c->realtime_scheduling = conf->realtime_scheduling; + c->mono_only_remixing = conf->mono_only_remixing; c->disable_remixing = conf->disable_remixing; c->disable_lfe_remixing = conf->disable_lfe_remixing; c->deferred_volume = conf->deferred_volume; diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index 2a96dfa..0002aaa 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -141,6 +141,7 @@ pa_core* pa_core_new(pa_mainloop_api *m, bool shared, bool enable_memfd, size_t c->running_as_daemon = false; c->realtime_scheduling = false; c->realtime_priority = 5; + c->mono_only_remixing = false; c->disable_remixing = false; c->disable_lfe_remixing = true; c->lfe_crossover_freq = 0; diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h index 00d7f2f..20a4b96 100644 --- a/src/pulsecore/core.h +++ b/src/pulsecore/core.h @@ -198,6 +198,7 @@ struct pa_core { bool disallow_exit:1; bool running_as_daemon:1; bool realtime_scheduling:1; + bool mono_only_remixing:1; bool disable_remixing:1; bool disable_lfe_remixing:1; bool deferred_volume:1; diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c index ea22cd2..2212475 100644 --- a/src/pulsecore/resampler.c +++ b/src/pulsecore/resampler.c @@ -836,6 +836,21 @@ static void setup_remap(const pa_resampler *r, pa_remap_t *m, bool *lfe_remixed) m->map_table_f[oc][ic] = 1.0f; } } + } else if (r->flags & PA_RESAMPLER_MONO_ONLY_REMIX) { + for (oc = 0; oc < n_oc; oc++) { + pa_channel_position_t b = r->o_cm.map[oc]; + + for (ic = 0; ic < n_ic; ic++) { + pa_channel_position_t a = r->i_cm.map[ic]; + + /* Remxing only for Mono */ + if (a == b || a == PA_CHANNEL_POSITION_MONO) { + m->map_table_f[oc][ic] = 1.0f; + } else if (b == PA_CHANNEL_POSITION_MONO) { + m->map_table_f[oc][ic] = 1.0f / (float) n_ic; + } + } + } } else { /* OK, we shall do the full monty: upmixing and downmixing. Our diff --git a/src/pulsecore/resampler.h b/src/pulsecore/resampler.h index 4469022..7bfe56a 100644 --- a/src/pulsecore/resampler.h +++ b/src/pulsecore/resampler.h @@ -68,7 +68,8 @@ typedef enum pa_resample_flags { PA_RESAMPLER_VARIABLE_RATE = 0x0001U, PA_RESAMPLER_NO_REMAP = 0x0002U, /* implies NO_REMIX */ PA_RESAMPLER_NO_REMIX = 0x0004U, - PA_RESAMPLER_NO_LFE = 0x0008U + PA_RESAMPLER_NO_LFE = 0x0008U, + PA_RESAMPLER_MONO_ONLY_REMIX = 0x0010U } pa_resample_flags_t; struct pa_resampler { diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index 361b445..51e4ae2 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -455,6 +455,7 @@ int pa_sink_input_new( data->resample_method, ((data->flags & PA_SINK_INPUT_VARIABLE_RATE) ? PA_RESAMPLER_VARIABLE_RATE : 0) | ((data->flags & PA_SINK_INPUT_NO_REMAP) ? PA_RESAMPLER_NO_REMAP : 0) | + (core->mono_only_remixing ? PA_RESAMPLER_MONO_ONLY_REMIX : 0) | (core->disable_remixing || (data->flags & PA_SINK_INPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0) | (core->disable_lfe_remixing ? PA_RESAMPLER_NO_LFE : 0)))) { pa_log_warn("Unsupported resampling operation."); @@ -2260,6 +2261,7 @@ int pa_sink_input_update_rate(pa_sink_input *i) { i->requested_resample_method, ((i->flags & PA_SINK_INPUT_VARIABLE_RATE) ? PA_RESAMPLER_VARIABLE_RATE : 0) | ((i->flags & PA_SINK_INPUT_NO_REMAP) ? PA_RESAMPLER_NO_REMAP : 0) | + (i->core->mono_only_remixing ? PA_RESAMPLER_MONO_ONLY_REMIX : 0) | (i->core->disable_remixing || (i->flags & PA_SINK_INPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0) | (i->core->disable_lfe_remixing ? PA_RESAMPLER_NO_LFE : 0)); diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index d74a60e..35fafc9 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -400,6 +400,7 @@ int pa_source_output_new( data->resample_method, ((data->flags & PA_SOURCE_OUTPUT_VARIABLE_RATE) ? PA_RESAMPLER_VARIABLE_RATE : 0) | ((data->flags & PA_SOURCE_OUTPUT_NO_REMAP) ? PA_RESAMPLER_NO_REMAP : 0) | + (core->mono_only_remixing ? PA_RESAMPLER_MONO_ONLY_REMIX : 0) | (core->disable_remixing || (data->flags & PA_SOURCE_OUTPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0) | (core->disable_lfe_remixing ? PA_RESAMPLER_NO_LFE : 0)))) { pa_log_warn("Unsupported resampling operation."); @@ -1714,6 +1715,7 @@ int pa_source_output_update_rate(pa_source_output *o) { o->requested_resample_method, ((o->flags & PA_SOURCE_OUTPUT_VARIABLE_RATE) ? PA_RESAMPLER_VARIABLE_RATE : 0) | ((o->flags & PA_SOURCE_OUTPUT_NO_REMAP) ? PA_RESAMPLER_NO_REMAP : 0) | + (o->core->mono_only_remixing ? PA_RESAMPLER_MONO_ONLY_REMIX : 0) | (o->core->disable_remixing || (o->flags & PA_SOURCE_OUTPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0) | (o->core->disable_lfe_remixing ? PA_RESAMPLER_NO_LFE : 0));