Skip to content
Snippets Groups Projects
Commit 8afb754c authored by Simon McVittie's avatar Simon McVittie
Browse files

pv-runtime: Move PulseAudio setup into PvRuntime

parent c369b2cd
No related branches found
No related tags found
1 merge request!275Fix PulseAudio-related regressions
...@@ -90,6 +90,7 @@ struct _PvRuntime ...@@ -90,6 +90,7 @@ struct _PvRuntime
gboolean runtime_is_just_usr; gboolean runtime_is_just_usr;
gboolean is_steamrt; gboolean is_steamrt;
gboolean is_scout; gboolean is_scout;
gboolean is_flatpak_env;
}; };
struct _PvRuntimeClass struct _PvRuntimeClass
...@@ -392,6 +393,8 @@ pv_runtime_init (PvRuntime *self) ...@@ -392,6 +393,8 @@ pv_runtime_init (PvRuntime *self)
self->all_libc_from_provider = FALSE; self->all_libc_from_provider = FALSE;
self->variable_dir_fd = -1; self->variable_dir_fd = -1;
self->mutable_sysroot_fd = -1; self->mutable_sysroot_fd = -1;
self->is_flatpak_env = g_file_test ("/.flatpak-info",
G_FILE_TEST_IS_REGULAR);
} }
static void static void
...@@ -4841,6 +4844,30 @@ pv_runtime_set_search_paths (PvRuntime *self, ...@@ -4841,6 +4844,30 @@ pv_runtime_set_search_paths (PvRuntime *self,
pv_environ_lock_env (container_env, "LD_LIBRARY_PATH", ld_library_path->str); 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 static void
pv_runtime_initable_iface_init (GInitableIface *iface, pv_runtime_initable_iface_init (GInitableIface *iface,
gpointer unused G_GNUC_UNUSED) gpointer unused G_GNUC_UNUSED)
......
...@@ -109,4 +109,8 @@ gboolean pv_runtime_garbage_collect_legacy (const char *variable_dir, ...@@ -109,4 +109,8 @@ gboolean pv_runtime_garbage_collect_legacy (const char *variable_dir,
const char *runtime_base, const char *runtime_base,
GError **error); GError **error);
void pv_runtime_use_shared_sockets (PvRuntime *self,
FlatpakBwrap *bwrap,
PvEnviron *container_env);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PvRuntime, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (PvRuntime, g_object_unref)
...@@ -2417,22 +2417,8 @@ main (int argc, ...@@ -2417,22 +2417,8 @@ main (int argc,
(runtime != NULL), (runtime != NULL),
is_flatpak_env); is_flatpak_env);
if (runtime != NULL if (runtime != NULL)
&& (pv_environ_is_locked(container_env, "PULSE_SERVER") pv_runtime_use_shared_sockets (runtime, bwrap, container_env);
|| 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 (is_flatpak_env) if (is_flatpak_env)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment