Antonio Larrosa
220b575aae
- Add patches from a MR to fix glfo#pipewire/wireplumber#162 (fix audio in virtual machines with pipewire): * 0001-core-add-API-to-check-if-running-in-a-virtual-machine.patch * 0002-alsa-monitor-set-period-size-and-headroom-props-if-running-in-virtual-machine.patch OBS-URL: https://build.opensuse.org/request/show/947467 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/wireplumber?expand=0&rev=21
102 lines
2.6 KiB
Diff
102 lines
2.6 KiB
Diff
From db728c2f7fff23446feeeaf3b3f16189a18a8f1e Mon Sep 17 00:00:00 2001
|
|
From: Julian Bouzas <julian.bouzas@collabora.com>
|
|
Date: Fri, 14 Jan 2022 14:34:38 -0500
|
|
Subject: [PATCH] core: add API to check if running in a virtual machine
|
|
|
|
---
|
|
lib/wp/core.c | 26 ++++++++++++++++++++++++++
|
|
lib/wp/core.h | 5 +++++
|
|
modules/module-lua-scripting/api.c | 9 +++++++++
|
|
3 files changed, 40 insertions(+)
|
|
|
|
diff --git a/lib/wp/core.c b/lib/wp/core.c
|
|
index 23f6f35f..3713135c 100644
|
|
--- a/lib/wp/core.c
|
|
+++ b/lib/wp/core.c
|
|
@@ -15,6 +15,7 @@
|
|
#include <pipewire/pipewire.h>
|
|
|
|
#include <spa/utils/result.h>
|
|
+#include <spa/support/cpu.h>
|
|
#include <spa/debug/types.h>
|
|
|
|
/*
|
|
@@ -986,6 +987,31 @@ wp_core_get_registry (WpCore * self)
|
|
return &self->registry;
|
|
}
|
|
|
|
+/*!
|
|
+ * \brief Checks whether core is a guest running in a virtual machine or not.
|
|
+ *
|
|
+ * \ingroup wpcore
|
|
+ * \param self the core
|
|
+ * \returns: TRUE if core is a guest, FALSE otherwise
|
|
+ */
|
|
+gboolean
|
|
+wp_core_is_guest (WpCore * self)
|
|
+{
|
|
+ const struct spa_support *support;
|
|
+ uint32_t n_support;
|
|
+ struct spa_cpu *cpu;
|
|
+
|
|
+ g_return_val_if_fail (WP_IS_CORE (self), FALSE);
|
|
+ g_return_val_if_fail (self->pw_context, FALSE);
|
|
+
|
|
+ support = pw_context_get_support (self->pw_context, &n_support);
|
|
+ cpu = spa_support_find (support, n_support, SPA_TYPE_INTERFACE_CPU);
|
|
+ if (!cpu)
|
|
+ return FALSE;
|
|
+
|
|
+ return spa_cpu_get_vm_type (cpu) != SPA_CPU_VM_NONE;
|
|
+}
|
|
+
|
|
WpCore *
|
|
wp_registry_get_core (WpRegistry * self)
|
|
{
|
|
diff --git a/lib/wp/core.h b/lib/wp/core.h
|
|
index 07a6125b..8efb922d 100644
|
|
--- a/lib/wp/core.h
|
|
+++ b/lib/wp/core.h
|
|
@@ -115,6 +115,11 @@ WP_API
|
|
gboolean wp_core_sync_finish (WpCore * self, GAsyncResult * res,
|
|
GError ** error);
|
|
|
|
+/* Misc */
|
|
+
|
|
+WP_API
|
|
+gboolean wp_core_is_guest (WpCore * self);
|
|
+
|
|
/* Object Manager */
|
|
|
|
WP_API
|
|
diff --git a/modules/module-lua-scripting/api.c b/modules/module-lua-scripting/api.c
|
|
index 876b4f6f..27033027 100644
|
|
--- a/modules/module-lua-scripting/api.c
|
|
+++ b/modules/module-lua-scripting/api.c
|
|
@@ -228,6 +228,14 @@ core_require_api (lua_State *L)
|
|
return wp_require_api_transition_new_from_lua (L, core);
|
|
}
|
|
|
|
+static int
|
|
+core_is_guest (lua_State *L)
|
|
+{
|
|
+ WpCore * core = get_wp_core (L);
|
|
+ lua_pushboolean (L, wp_core_is_guest (core));
|
|
+ return 1;
|
|
+}
|
|
+
|
|
static const luaL_Reg core_funcs[] = {
|
|
{ "get_info", core_get_info },
|
|
{ "idle_add", core_idle_add },
|
|
@@ -235,6 +243,7 @@ static const luaL_Reg core_funcs[] = {
|
|
{ "sync", core_sync },
|
|
{ "quit", core_quit },
|
|
{ "require_api", core_require_api },
|
|
+ { "is_guest", core_is_guest },
|
|
{ NULL, NULL }
|
|
};
|
|
|
|
--
|
|
GitLab
|
|
|