diff --git a/pressure-vessel/runtime.c b/pressure-vessel/runtime.c index 65d37667806bef3155bf3bc8fa4fb93083517c9d..9f85a3fc436f11a884de7402ec59fcf663107704 100644 --- a/pressure-vessel/runtime.c +++ b/pressure-vessel/runtime.c @@ -90,6 +90,7 @@ struct _PvRuntime gboolean runtime_is_just_usr; gboolean is_steamrt; gboolean is_scout; + gboolean is_flatpak_env; }; struct _PvRuntimeClass @@ -392,6 +393,8 @@ pv_runtime_init (PvRuntime *self) self->all_libc_from_provider = FALSE; self->variable_dir_fd = -1; self->mutable_sysroot_fd = -1; + self->is_flatpak_env = g_file_test ("/.flatpak-info", + G_FILE_TEST_IS_REGULAR); } static void @@ -4841,6 +4844,30 @@ pv_runtime_set_search_paths (PvRuntime *self, pv_environ_lock_env (container_env, "LD_LIBRARY_PATH", ld_library_path->str); } +void +pv_runtime_use_shared_sockets (PvRuntime *self, + FlatpakBwrap *bwrap, + PvEnviron *container_env) +{ + if (pv_environ_is_locked (container_env, "PULSE_SERVER") + || self->is_flatpak_env) + { + /* Make the PulseAudio driver the default. + * We do this unconditionally when we are under Flatpak for parity + * with the freedesktop.org Platform. */ + const gchar *alsa_config = "pcm.!default pulse\n" + "ctl.!default pulse\n"; + + if (bwrap != NULL) + { + flatpak_bwrap_add_args_data (bwrap, "asound.conf", + alsa_config, -1, + "/etc/asound.conf", + NULL); + } + } +} + static void pv_runtime_initable_iface_init (GInitableIface *iface, gpointer unused G_GNUC_UNUSED) diff --git a/pressure-vessel/runtime.h b/pressure-vessel/runtime.h index 6b3b91da926f63433f3f9b7e3fd40ef68c3ca20f..151e59e2e4d522c7e56ad0475d0168e4bede16f7 100644 --- a/pressure-vessel/runtime.h +++ b/pressure-vessel/runtime.h @@ -109,4 +109,8 @@ gboolean pv_runtime_garbage_collect_legacy (const char *variable_dir, const char *runtime_base, GError **error); +void pv_runtime_use_shared_sockets (PvRuntime *self, + FlatpakBwrap *bwrap, + PvEnviron *container_env); + G_DEFINE_AUTOPTR_CLEANUP_FUNC (PvRuntime, g_object_unref) diff --git a/pressure-vessel/wrap.c b/pressure-vessel/wrap.c index ebed24d0a875ec336f9f65ce21cdde1ce144248c..ba37233a7ed98402efbbbca77801f7f9f657c4fe 100644 --- a/pressure-vessel/wrap.c +++ b/pressure-vessel/wrap.c @@ -2417,22 +2417,8 @@ main (int argc, (runtime != NULL), is_flatpak_env); - if (runtime != NULL - && (pv_environ_is_locked(container_env, "PULSE_SERVER") - || is_flatpak_env) - && bwrap != NULL) - { - /* Make the PulseAudio driver the default. - * We do this unconditionally when we are under Flatpak for parity - * with the freedesktop.org Platform. */ - const gchar *alsa_config = "pcm.!default pulse\n" - "ctl.!default pulse\n"; - - flatpak_bwrap_add_args_data (bwrap, "asound.conf", - alsa_config, -1, - "/etc/asound.conf", - NULL); - } + if (runtime != NULL) + pv_runtime_use_shared_sockets (runtime, bwrap, container_env); if (is_flatpak_env) {