audio: pipewire: Use client config files instead of module names Pipewire, as of 0.3.22, uses client config files to load modules instead of explicitly specifying them (PW_KEY_CONTEXT_PROFILE_MODULES is deprecated). Use the new method to load the realtime module to boost the audio thread priority.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c
index 32d7d5a..6d436f9 100644
--- a/src/audio/pipewire/SDL_pipewire.c
+++ b/src/audio/pipewire/SDL_pipewire.c
@@ -31,8 +31,22 @@
#include <pipewire/extensions/metadata.h>
#include <spa/param/audio/format-utils.h>
-/* Older versions of Pipewire may not define this, but it's safe to pass at
- * runtime even if older installations don't recognize it.
+/*
+ * The following keys are defined for compatability when building against older versions of Pipewire
+ * prior to their introduction and can be removed if the minimum required Pipewire version is increased
+ * to or beyond their point of introduction.
+ */
+
+/*
+ * Introduced in 0.3.22
+ * Taken from /src/pipewire/keys.h
+ */
+#ifndef PW_KEY_CONFIG_NAME
+#define PW_KEY_CONFIG_NAME "config.name"
+#endif
+
+/*
+ * Introduced in 0.3.33
* Taken from src/pipewire/keys.h
*/
#ifndef PW_KEY_NODE_RATE
@@ -1099,8 +1113,17 @@ PIPEWIRE_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
return SDL_SetError("Pipewire: Failed to create stream loop (%i)", errno);
}
- /* Load the rtkit module so Pipewire can set the loop thread to the appropriate priority */
- props = PIPEWIRE_pw_properties_new(PW_KEY_CONTEXT_PROFILE_MODULES, "default,rtkit", NULL);
+ /*
+ * Load the realtime module so Pipewire can set the loop thread to the appropriate priority.
+ *
+ * NOTE: Pipewire versions 0.3.22 or higher require the PW_KEY_CONFIG_NAME property (with client-rt.conf),
+ * lower versions require explicitly specifying the 'rtkit' module.
+ *
+ * PW_KEY_CONTEXT_PROFILE_MODULES is deprecated and can be safely removed if the minimum required
+ * Pipewire version is increased to 0.3.22 or higher at some point.
+ */
+ props = PIPEWIRE_pw_properties_new(PW_KEY_CONFIG_NAME, "client-rt.conf",
+ PW_KEY_CONTEXT_PROFILE_MODULES, "default,rtkit", NULL);
if (props == NULL) {
return SDL_SetError("Pipewire: Failed to create stream context properties (%i)", errno);
}