comp-loader: add support for loading pipewire modules as components

This commit is contained in:
George Kiagiadakis
2023-11-14 15:34:11 +02:00
parent 4593245fbb
commit 6a88d8aa2c

View File

@@ -10,6 +10,8 @@
#include "wp.h" #include "wp.h"
#include "registry.h" #include "registry.h"
#include <pipewire/impl.h>
WP_DEFINE_LOCAL_LOG_TOPIC ("wp-internal-comp-loader") WP_DEFINE_LOCAL_LOG_TOPIC ("wp-internal-comp-loader")
/*** ComponentData ***/ /*** ComponentData ***/
@@ -711,6 +713,7 @@ wp_internal_comp_loader_supports_type (WpComponentLoader * cl,
const gchar * type) const gchar * type)
{ {
return g_str_equal (type, "module") || return g_str_equal (type, "module") ||
g_str_equal (type, "pw-module") ||
g_str_equal (type, "virtual") || g_str_equal (type, "virtual") ||
g_str_equal (type, "built-in") || g_str_equal (type, "built-in") ||
g_str_equal (type, "profile") || g_str_equal (type, "profile") ||
@@ -768,6 +771,17 @@ wp_internal_comp_loader_load (WpComponentLoader * self, WpCore * core,
else else
g_task_return_error (task, g_steal_pointer (&error)); g_task_return_error (task, g_steal_pointer (&error));
} }
else if (g_str_equal (type, "pw-module")) {
if (!pw_context_load_module (wp_core_get_pw_context (core), component,
args ? wp_spa_json_get_data (args) : NULL, NULL)) {
g_task_return_new_error (task, WP_DOMAIN_LIBRARY,
WP_LIBRARY_ERROR_OPERATION_FAILED,
"Failed to load pipewire module %s: %s", component, strerror (errno));
}
else {
g_task_return_pointer (task, NULL, NULL);
}
}
else if (g_str_equal (type, "virtual")) { else if (g_str_equal (type, "virtual")) {
g_task_return_pointer (task, NULL, NULL); g_task_return_pointer (task, NULL, NULL);
} }