diff --git a/src/daemon/pipewire-pulse.conf.in b/src/daemon/pipewire-pulse.conf.in index 4a1633054..c481684ef 100644 --- a/src/daemon/pipewire-pulse.conf.in +++ b/src/daemon/pipewire-pulse.conf.in @@ -43,6 +43,10 @@ context.modules = [ #pulse.min.quantum = 256/48000 # 5ms #pulse.default.format = F32 #pulse.default.position = [ FL FR ] + # These overrides are only applied when running in a vm. + vm.overrides = { + pulse.min.quantum = 1024/48000 # 22ms + } } } ] diff --git a/src/daemon/pipewire.conf.in b/src/daemon/pipewire.conf.in index 90a22e2c7..394b2e109 100644 --- a/src/daemon/pipewire.conf.in +++ b/src/daemon/pipewire.conf.in @@ -25,6 +25,11 @@ context.properties = { #default.video.height = 480 #default.video.rate.num = 25 #default.video.rate.denom = 1 + # + # These overrides are only applied when running in a vm. + vm.overrides = { + default.clock.min-quantum = 1024 + } } context.spa-libs = { diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index c30c28f0a..5522cd7fe 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -60,6 +60,7 @@ #define spa_debug pw_log_debug +#include #include #include #include @@ -6225,27 +6226,29 @@ struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context, const char *str; struct spa_json it[2]; char value[512]; + const struct spa_support *support; + struct spa_cpu *cpu; + uint32_t n_support; int res; impl = calloc(1, sizeof(struct impl) + user_data_size); if (impl == NULL) goto error_exit; + if (props == NULL) props = pw_properties_new(NULL, NULL); if (props == NULL) goto error_free; - str = pw_properties_get(props, "server.address"); - if (str == NULL) { - pw_properties_setf(props, "server.address", - "[ \"%s-%s\" ]", - PW_PROTOCOL_PULSE_DEFAULT_SERVER, - get_server_name(context)); - str = pw_properties_get(props, "server.address"); + support = pw_context_get_support(context, &n_support); + cpu = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_CPU); + + if ((str = pw_properties_get(props, "vm.overrides")) != NULL) { + if (cpu != NULL && spa_cpu_get_vm_type(cpu) != SPA_CPU_VM_NONE) + pw_properties_update_string(props, str, strlen(str)); + pw_properties_set(props, "vm.overrides", NULL); } - if (str == NULL) - goto error_free; load_defaults(&impl->defs, props); @@ -6270,6 +6273,17 @@ struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context, pw_context_add_listener(context, &impl->context_listener, &context_events, impl); + str = pw_properties_get(props, "server.address"); + if (str == NULL) { + pw_properties_setf(props, "server.address", + "[ \"%s-%s\" ]", + PW_PROTOCOL_PULSE_DEFAULT_SERVER, + get_server_name(context)); + str = pw_properties_get(props, "server.address"); + } + if (str == NULL) + goto error_free; + spa_json_init(&it[0], str, strlen(str)); if (spa_json_enter_array(&it[0], &it[1]) > 0) { while (spa_json_get_string(&it[1], value, sizeof(value)-1) > 0) { diff --git a/src/pipewire/context.c b/src/pipewire/context.c index 144bedbc2..ce9c52235 100644 --- a/src/pipewire/context.c +++ b/src/pipewire/context.c @@ -246,11 +246,23 @@ struct pw_context *pw_context_new(struct pw_loop *main_loop, } this->conf = conf; + n_support = pw_get_support(this->support, SPA_N_ELEMENTS(this->support) - 6); + cpu = spa_support_find(this->support, n_support, SPA_TYPE_INTERFACE_CPU); + if ((str = pw_properties_get(conf, "context.properties")) != NULL) { pw_properties_update_string(properties, str, strlen(str)); pw_log_info(NAME" %p: parsed context.properties section", this); } + if ((str = pw_properties_get(properties, "vm.overrides")) != NULL) { + if (cpu != NULL && spa_cpu_get_vm_type(cpu) != SPA_CPU_VM_NONE) + pw_properties_update_string(properties, str, strlen(str)); + pw_properties_set(properties, "vm.overrides", NULL); + } + if (pw_properties_get(properties, PW_KEY_CPU_MAX_ALIGN) == NULL && cpu != NULL) + pw_properties_setf(properties, PW_KEY_CPU_MAX_ALIGN, + "%u", spa_cpu_get_max_align(cpu)); + if (getenv("PIPEWIRE_DEBUG") == NULL && (str = pw_properties_get(properties, "log.level")) != NULL) pw_log_set_level(atoi(str)); @@ -287,16 +299,12 @@ struct pw_context *pw_context_new(struct pw_loop *main_loop, this->data_system = this->data_loop->system; this->main_loop = main_loop; - n_support = pw_get_support(this->support, SPA_N_ELEMENTS(this->support) - 6); this->support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_System, this->main_loop->system); this->support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Loop, this->main_loop->loop); this->support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_LoopUtils, this->main_loop->utils); this->support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DataSystem, this->data_system); this->support[n_support++] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DataLoop, this->data_loop->loop); - if ((cpu = spa_support_find(this->support, n_support, SPA_TYPE_INTERFACE_CPU)) != NULL) - pw_properties_setf(properties, PW_KEY_CPU_MAX_ALIGN, "%u", spa_cpu_get_max_align(cpu)); - if ((str = pw_properties_get(properties, "support.dbus")) == NULL || pw_properties_parse_bool(str)) { lib = pw_properties_get(properties, PW_KEY_LIBRARY_NAME_DBUS);