From 3e53e3bba31fcf62fc7b50c5be5d1fe3f36955e0 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Fri, 15 Oct 2010 13:05:17 +0300 Subject: daemon-conf: Add sync volume parameters to daemon-conf Signed-off-by: Jyri Sarha Reviewed-by: Tanu Kaskinen Reviewd-by: Colin Guthrie --- src/daemon/daemon-conf.c | 9 +++++++++ src/daemon/daemon-conf.h | 5 ++++- src/daemon/daemon.conf.in | 4 ++++ src/daemon/main.c | 3 +++ src/modules/alsa/alsa-sink.c | 1 + src/modules/module-udev-detect.c | 2 +- src/pulsecore/core.c | 4 ++++ src/pulsecore/core.h | 3 +++ src/pulsecore/sink.c | 6 ++---- 9 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index 79dd49af..74e81351 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -89,8 +89,11 @@ static const pa_daemon_conf default_conf = { .no_cpu_limit = TRUE, .disable_shm = FALSE, .lock_memory = FALSE, + .sync_volume = TRUE, .default_n_fragments = 4, .default_fragment_size_msec = 25, + .sync_volume_safety_margin_usec = 8000, + .sync_volume_extra_delay_usec = 0, .default_sample_spec = { .format = PA_SAMPLE_S16NE, .rate = 44100, .channels = 2 }, .default_channel_map = { .channels = 2, .map = { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT } }, .shm_size = 0 @@ -508,6 +511,7 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) { { "enable-shm", pa_config_parse_not_bool, &c->disable_shm, NULL }, { "flat-volumes", pa_config_parse_bool, &c->flat_volumes, NULL }, { "lock-memory", pa_config_parse_bool, &c->lock_memory, NULL }, + { "enable-sync-volume", pa_config_parse_bool, &c->sync_volume, NULL }, { "exit-idle-time", pa_config_parse_int, &c->exit_idle_time, NULL }, { "scache-idle-time", pa_config_parse_int, &c->scache_idle_time, NULL }, { "realtime-priority", parse_rtprio, c, NULL }, @@ -523,6 +527,8 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) { { "default-channel-map", parse_channel_map, &ci, NULL }, { "default-fragments", parse_fragments, c, NULL }, { "default-fragment-size-msec", parse_fragment_size_msec, c, NULL }, + { "sync-volume-safety-margin-usec", pa_config_parse_unsigned, &c->sync_volume_safety_margin_usec, NULL }, + { "sync-volume-extra-delay-usec", pa_config_parse_int, &c->sync_volume_extra_delay_usec, NULL }, { "nice-level", parse_nice_level, c, NULL }, { "disable-remixing", pa_config_parse_bool, &c->disable_remixing, NULL }, { "enable-remixing", pa_config_parse_not_bool, &c->disable_remixing, NULL }, @@ -706,6 +712,7 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) { pa_strbuf_printf(s, "enable-shm = %s\n", pa_yes_no(!c->disable_shm)); pa_strbuf_printf(s, "flat-volumes = %s\n", pa_yes_no(c->flat_volumes)); pa_strbuf_printf(s, "lock-memory = %s\n", pa_yes_no(c->lock_memory)); + pa_strbuf_printf(s, "enable-sync-volume = %s\n", pa_yes_no(c->sync_volume)); pa_strbuf_printf(s, "exit-idle-time = %i\n", c->exit_idle_time); pa_strbuf_printf(s, "scache-idle-time = %i\n", c->scache_idle_time); pa_strbuf_printf(s, "dl-search-path = %s\n", pa_strempty(c->dl_search_path)); @@ -722,6 +729,8 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) { pa_strbuf_printf(s, "default-channel-map = %s\n", pa_channel_map_snprint(cm, sizeof(cm), &c->default_channel_map)); pa_strbuf_printf(s, "default-fragments = %u\n", c->default_n_fragments); pa_strbuf_printf(s, "default-fragment-size-msec = %u\n", c->default_fragment_size_msec); + pa_strbuf_printf(s, "sync-volume-safety-margin-usec = %u\n", c->sync_volume_safety_margin_usec); + pa_strbuf_printf(s, "sync-volume-extra-delay-usec = %d\n", c->sync_volume_extra_delay_usec); pa_strbuf_printf(s, "shm-size-bytes = %lu\n", (unsigned long) c->shm_size); pa_strbuf_printf(s, "log-meta = %s\n", pa_yes_no(c->log_meta)); pa_strbuf_printf(s, "log-time = %s\n", pa_yes_no(c->log_time)); diff --git a/src/daemon/daemon-conf.h b/src/daemon/daemon-conf.h index 41c3c4b7..9fd6aba6 100644 --- a/src/daemon/daemon-conf.h +++ b/src/daemon/daemon-conf.h @@ -75,7 +75,8 @@ typedef struct pa_daemon_conf { log_meta, log_time, flat_volumes, - lock_memory; + lock_memory, + sync_volume; pa_server_type_t local_server_type; int exit_idle_time, scache_idle_time, @@ -127,6 +128,8 @@ typedef struct pa_daemon_conf { #endif unsigned default_n_fragments, default_fragment_size_msec; + unsigned sync_volume_safety_margin_usec; + int sync_volume_extra_delay_usec; pa_sample_spec default_sample_spec; pa_channel_map default_channel_map; size_t shm_size; diff --git a/src/daemon/daemon.conf.in b/src/daemon/daemon.conf.in index 5de27ed8..9beba85e 100644 --- a/src/daemon/daemon.conf.in +++ b/src/daemon/daemon.conf.in @@ -80,3 +80,7 @@ ; default-fragments = 4 ; default-fragment-size-msec = 25 + +; enable-sync-volume = yes +; sync-volume-safety-margin-usec = 8000 +; sync-volume-extra-delay-usec = 0 diff --git a/src/daemon/main.c b/src/daemon/main.c index 0e7b54a5..f9fcc925 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -945,6 +945,8 @@ int main(int argc, char *argv[]) { c->default_channel_map = conf->default_channel_map; c->default_n_fragments = conf->default_n_fragments; c->default_fragment_size_msec = conf->default_fragment_size_msec; + c->sync_volume_safety_margin_usec = conf->sync_volume_safety_margin_usec; + c->sync_volume_extra_delay_usec = conf->sync_volume_extra_delay_usec; c->exit_idle_time = conf->exit_idle_time; c->scache_idle_time = conf->scache_idle_time; c->resample_method = conf->resample_method; @@ -952,6 +954,7 @@ int main(int argc, char *argv[]) { c->realtime_scheduling = !!conf->realtime_scheduling; c->disable_remixing = !!conf->disable_remixing; c->disable_lfe_remixing = !!conf->disable_lfe_remixing; + c->sync_volume = !!conf->sync_volume; c->running_as_daemon = !!conf->daemonize; c->disallow_exit = conf->disallow_exit; c->flat_volumes = conf->flat_volumes; diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 069ee95c..b740d53c 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -1831,6 +1831,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca goto fail; } + sync_volume = m->core->sync_volume; if (pa_modargs_get_value_boolean(ma, "sync_volume", &sync_volume) < 0) { pa_log("Failed to parse sync_volume argument."); goto fail; diff --git a/src/modules/module-udev-detect.c b/src/modules/module-udev-detect.c index 775094da..2eecc25a 100644 --- a/src/modules/module-udev-detect.c +++ b/src/modules/module-udev-detect.c @@ -666,7 +666,7 @@ int pa__init(pa_module *m) { struct udev_enumerate *enumerate = NULL; struct udev_list_entry *item = NULL, *first = NULL; int fd; - pa_bool_t use_tsched = TRUE, ignore_dB = FALSE, sync_volume = FALSE; + pa_bool_t use_tsched = TRUE, ignore_dB = FALSE, sync_volume = m->core->sync_volume; pa_assert(m); diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index f0726453..626ae65f 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -117,6 +117,9 @@ pa_core* pa_core_new(pa_mainloop_api *m, pa_bool_t shared, size_t shm_size) { c->default_n_fragments = 4; c->default_fragment_size_msec = 25; + c->sync_volume_safety_margin_usec = 8000; + c->sync_volume_extra_delay_usec = 0; + c->module_defer_unload_event = NULL; c->scache_auto_unload_event = NULL; @@ -141,6 +144,7 @@ pa_core* pa_core_new(pa_mainloop_api *m, pa_bool_t shared, size_t shm_size) { c->realtime_priority = 5; c->disable_remixing = FALSE; c->disable_lfe_remixing = FALSE; + c->sync_volume = TRUE; c->resample_method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 3; for (j = 0; j < PA_CORE_HOOK_MAX; j++) diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h index 6088f915..a1215bb5 100644 --- a/src/pulsecore/core.h +++ b/src/pulsecore/core.h @@ -142,6 +142,8 @@ struct pa_core { pa_channel_map default_channel_map; pa_sample_spec default_sample_spec; unsigned default_n_fragments, default_fragment_size_msec; + unsigned sync_volume_safety_margin_usec; + int sync_volume_extra_delay_usec; pa_defer_event *module_defer_unload_event; @@ -165,6 +167,7 @@ struct pa_core { pa_bool_t realtime_scheduling:1; pa_bool_t disable_remixing:1; pa_bool_t disable_lfe_remixing:1; + pa_bool_t sync_volume:1; pa_resample_method_t resample_method; int realtime_priority; diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index a42a1472..136508b2 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -53,8 +53,6 @@ #define ABSOLUTE_MIN_LATENCY (500) #define ABSOLUTE_MAX_LATENCY (10*PA_USEC_PER_SEC) #define DEFAULT_FIXED_LATENCY (250*PA_USEC_PER_MSEC) -#define VOLUME_CHANGE_SAFETY_MARGIN_DEFAULT (8*PA_USEC_PER_MSEC) -#define VOLUME_CHANGE_EXTRA_DELAY_DEFAULT (0*PA_USEC_PER_MSEC) PA_DEFINE_PUBLIC_CLASS(pa_sink, pa_msgobject); @@ -333,8 +331,8 @@ pa_sink* pa_sink_new( PA_LLIST_HEAD_INIT(pa_sink_volume_change, s->thread_info.volume_changes); s->thread_info.volume_changes_tail = NULL; pa_sw_cvolume_multiply(&s->thread_info.current_hw_volume, &s->soft_volume, &s->real_volume); - s->thread_info.volume_change_safety_margin = VOLUME_CHANGE_SAFETY_MARGIN_DEFAULT; - s->thread_info.volume_change_extra_delay = VOLUME_CHANGE_EXTRA_DELAY_DEFAULT; + s->thread_info.volume_change_safety_margin = core->sync_volume_safety_margin_usec; + s->thread_info.volume_change_extra_delay = core->sync_volume_extra_delay_usec; /* FIXME: This should probably be moved to pa_sink_put() */ pa_assert_se(pa_idxset_put(core->sinks, s, &s->index) >= 0); -- cgit