pulse-server: module does not depend on client

We don't need to pass the client to the module create and load
functions, they can work without a client.

The only place the client is used is to access the properties to make a
new connection to pipewire. This is also however not a good idea, we
should simply use the defaults used by the context or else a client
could set strange properties like remote.name etc for these internal
connections.

Also removing the dependency of the client will make it possible to load
modules from the startup script or other modules later.
This commit is contained in:
Wim Taymans 2022-12-06 18:26:29 +01:00
parent 80cb1d2566
commit 865d41b986
27 changed files with 40 additions and 48 deletions

View file

@ -36,7 +36,6 @@
#include <pipewire/properties.h>
#include <pipewire/work-queue.h>
#include "client.h"
#include "defs.h"
#include "format.h"
#include "internal.h"
@ -84,14 +83,14 @@ void module_add_listener(struct module *module,
spa_hook_list_append(&module->listener_list, listener, events, data);
}
int module_load(struct client *client, struct module *module)
int module_load(struct module *module)
{
pw_log_info("load module index:%u name:%s", module->index, module->info->name);
if (module->info->load == NULL)
return -ENOTSUP;
/* subscription event is sent when the module does a
* module_emit_loaded() */
return module->info->load(client, module);
return module->info->load(module);
}
void module_free(struct module *module)
@ -119,9 +118,6 @@ int module_unload(struct module *module)
struct impl *impl = module->impl;
int res = 0;
/* Note that client can be NULL (when the module is being unloaded
* internally and not by a client request */
pw_log_info("unload module index:%u name:%s", module->index, module->info->name);
if (module->info->unload)
@ -283,9 +279,8 @@ static int find_module_by_name(void *item_data, void *data)
return spa_streq(module->info->name, name) ? 1 : 0;
}
struct module *module_create(struct client *client, const char *name, const char *args)
struct module *module_create(struct impl *impl, const char *name, const char *args)
{
struct impl *impl = client->impl;
const struct module_info *info;
struct module *module;