mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
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:
parent
80cb1d2566
commit
865d41b986
27 changed files with 40 additions and 48 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
#include <spa/param/audio/raw.h>
|
||||
#include <spa/utils/hook.h>
|
||||
|
||||
#include "client.h"
|
||||
#include "internal.h"
|
||||
|
||||
struct module;
|
||||
|
|
@ -41,7 +40,7 @@ struct module_info {
|
|||
unsigned int load_once:1;
|
||||
|
||||
int (*prepare) (struct module *module);
|
||||
int (*load) (struct client *client, struct module *module);
|
||||
int (*load) (struct module *module);
|
||||
int (*unload) (struct module *module);
|
||||
|
||||
const struct spa_dict *properties;
|
||||
|
|
@ -78,9 +77,9 @@ struct module {
|
|||
#define module_emit_loaded(m,r) spa_hook_list_call(&m->listener_list, struct module_events, loaded, 0, r)
|
||||
#define module_emit_destroy(m) spa_hook_list_call(&(m)->listener_list, struct module_events, destroy, 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);
|
||||
void module_free(struct module *module);
|
||||
int module_load(struct client *client, struct module *module);
|
||||
int module_load(struct module *module);
|
||||
int module_unload(struct module *module);
|
||||
void module_schedule_unload(struct module *module);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_always_sink_load(struct client *client, struct module *module)
|
||||
static int module_always_sink_load(struct module *module)
|
||||
{
|
||||
struct module_always_sink_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ static void on_sinks_timeout(void *d, uint64_t count)
|
|||
check_initialized(data);
|
||||
}
|
||||
|
||||
static int module_combine_sink_load(struct client *client, struct module *module)
|
||||
static int module_combine_sink_load(struct module *module)
|
||||
{
|
||||
struct module_combine_sink_data *data = module->user_data;
|
||||
struct pw_properties *props;
|
||||
|
|
@ -402,9 +402,7 @@ static int module_combine_sink_load(struct client *client, struct module *module
|
|||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
||||
const char *str;
|
||||
|
||||
data->core = pw_context_connect(module->impl->context,
|
||||
pw_properties_copy(client->props),
|
||||
0);
|
||||
data->core = pw_context_connect(module->impl->context, NULL, 0);
|
||||
if (data->core == NULL)
|
||||
return -errno;
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_ladspa_sink_load(struct client *client, struct module *module)
|
||||
static int module_ladspa_sink_load(struct module *module)
|
||||
{
|
||||
struct module_ladspa_sink_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_ladspa_source_load(struct client *client, struct module *module)
|
||||
static int module_ladspa_source_load(struct module *module)
|
||||
{
|
||||
struct module_ladspa_source_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_loopback_load(struct client *client, struct module *module)
|
||||
static int module_loopback_load(struct module *module)
|
||||
{
|
||||
struct module_loopback_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ struct module_native_protocol_tcp_data {
|
|||
struct pw_array servers;
|
||||
};
|
||||
|
||||
static int module_native_protocol_tcp_load(struct client *client, struct module *module)
|
||||
static int module_native_protocol_tcp_load(struct module *module)
|
||||
{
|
||||
struct module_native_protocol_tcp_data *data = module->user_data;
|
||||
struct impl *impl = client->impl;
|
||||
struct impl *impl = module->impl;
|
||||
const char *address;
|
||||
int res;
|
||||
|
||||
|
|
|
|||
|
|
@ -104,11 +104,11 @@ static const struct pw_core_events core_events = {
|
|||
.error = module_null_sink_core_error,
|
||||
};
|
||||
|
||||
static int module_null_sink_load(struct client *client, struct module *module)
|
||||
static int module_null_sink_load(struct module *module)
|
||||
{
|
||||
struct module_null_sink_data *d = module->user_data;
|
||||
|
||||
d->core = pw_context_connect(module->impl->context, pw_properties_copy(client->props), 0);
|
||||
d->core = pw_context_connect(module->impl->context, NULL, 0);
|
||||
if (d->core == NULL)
|
||||
return -errno;
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_pipe_sink_load(struct client *client, struct module *module)
|
||||
static int module_pipe_sink_load(struct module *module)
|
||||
{
|
||||
struct module_pipesink_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_pipe_source_load(struct client *client, struct module *module)
|
||||
static int module_pipe_source_load(struct module *module)
|
||||
{
|
||||
struct module_pipesrc_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_raop_discover_load(struct client *client, struct module *module)
|
||||
static int module_raop_discover_load(struct module *module)
|
||||
{
|
||||
struct module_raop_discover_data *data = module->user_data;
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_remap_sink_load(struct client *client, struct module *module)
|
||||
static int module_remap_sink_load(struct module *module)
|
||||
{
|
||||
struct module_remap_sink_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_remap_source_load(struct client *client, struct module *module)
|
||||
static int module_remap_source_load(struct module *module)
|
||||
{
|
||||
struct module_remap_source_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_roc_sink_input_load(struct client *client, struct module *module)
|
||||
static int module_roc_sink_input_load(struct module *module)
|
||||
{
|
||||
struct module_roc_sink_input_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_roc_sink_load(struct client *client, struct module *module)
|
||||
static int module_roc_sink_load(struct module *module)
|
||||
{
|
||||
struct module_roc_sink_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_roc_source_load(struct client *client, struct module *module)
|
||||
static int module_roc_source_load(struct module *module)
|
||||
{
|
||||
struct module_roc_source_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_rtp_recv_load(struct client *client, struct module *module)
|
||||
static int module_rtp_recv_load(struct module *module)
|
||||
{
|
||||
struct module_rtp_recv_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_rtp_send_load(struct client *client, struct module *module)
|
||||
static int module_rtp_send_load(struct module *module)
|
||||
{
|
||||
struct module_rtp_send_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -58,10 +58,10 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_simple_protocol_tcp_load(struct client *client, struct module *module)
|
||||
static int module_simple_protocol_tcp_load(struct module *module)
|
||||
{
|
||||
struct module_simple_protocol_tcp_data *data = module->user_data;
|
||||
struct impl *impl = client->impl;
|
||||
struct impl *impl = module->impl;
|
||||
char *args;
|
||||
size_t size;
|
||||
uint32_t i;
|
||||
|
|
|
|||
|
|
@ -175,13 +175,13 @@ static const struct pw_core_events core_events = {
|
|||
.done = on_core_done,
|
||||
};
|
||||
|
||||
static int module_switch_on_connect_load(struct client *client, struct module *module)
|
||||
static int module_switch_on_connect_load(struct module *module)
|
||||
{
|
||||
struct impl *impl = client->impl;
|
||||
struct impl *impl = module->impl;
|
||||
struct module_switch_on_connect_data *d = module->user_data;
|
||||
int res;
|
||||
|
||||
d->core = pw_context_connect(impl->context, pw_properties_copy(client->props), 0);
|
||||
d->core = pw_context_connect(impl->context, NULL, 0);
|
||||
if (d->core == NULL) {
|
||||
res = -errno;
|
||||
goto error;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_tunnel_sink_load(struct client *client, struct module *module)
|
||||
static int module_tunnel_sink_load(struct module *module)
|
||||
{
|
||||
struct module_tunnel_sink_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_tunnel_source_load(struct client *client, struct module *module)
|
||||
static int module_tunnel_source_load(struct module *module)
|
||||
{
|
||||
struct module_tunnel_source_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_x11_bell_load(struct client *client, struct module *module)
|
||||
static int module_x11_bell_load(struct module *module)
|
||||
{
|
||||
struct module_x11_bell_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ static const struct pw_impl_module_events module_events = {
|
|||
.destroy = module_destroy
|
||||
};
|
||||
|
||||
static int module_zeroconf_discover_load(struct client *client, struct module *module)
|
||||
static int module_zeroconf_discover_load(struct module *module)
|
||||
{
|
||||
struct module_zeroconf_discover_data *data = module->user_data;
|
||||
FILE *f;
|
||||
|
|
|
|||
|
|
@ -647,14 +647,13 @@ static const struct impl_events impl_events = {
|
|||
.server_stopped = impl_server_stopped,
|
||||
};
|
||||
|
||||
static int module_zeroconf_publish_load(struct client *client, struct module *module)
|
||||
static int module_zeroconf_publish_load(struct module *module)
|
||||
{
|
||||
struct module_zeroconf_publish_data *data = module->user_data;
|
||||
struct pw_loop *loop;
|
||||
int error;
|
||||
|
||||
data->core = pw_context_connect(module->impl->context,
|
||||
pw_properties_copy(client->props), 0);
|
||||
data->core = pw_context_connect(module->impl->context, NULL, 0);
|
||||
if (data->core == NULL) {
|
||||
pw_log_error("failed to connect to pipewire: %m");
|
||||
return -errno;
|
||||
|
|
|
|||
|
|
@ -5131,6 +5131,7 @@ static int do_load_module(struct client *client, uint32_t command, uint32_t tag,
|
|||
.sync = on_load_module_manager_sync,
|
||||
};
|
||||
|
||||
struct impl *impl = client->impl;
|
||||
const char *name, *argument;
|
||||
struct module *module;
|
||||
struct pending_module *pm;
|
||||
|
|
@ -5145,7 +5146,7 @@ static int do_load_module(struct client *client, uint32_t command, uint32_t tag,
|
|||
pw_log_info("[%s] %s name:%s argument:%s",
|
||||
client->name, commands[command].name, name, argument);
|
||||
|
||||
module = module_create(client, name, argument);
|
||||
module = module_create(impl, name, argument);
|
||||
if (module == NULL)
|
||||
return -errno;
|
||||
|
||||
|
|
@ -5159,7 +5160,7 @@ static int do_load_module(struct client *client, uint32_t command, uint32_t tag,
|
|||
|
||||
pw_log_debug("pending module %p: start tag:%d", pm, tag);
|
||||
|
||||
r = module_load(client, module);
|
||||
r = module_load(module);
|
||||
|
||||
module_add_listener(module, &pm->module_listener, &module_events, pm);
|
||||
client_add_listener(client, &pm->client_listener, &client_events, pm);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue