Browse Source

pulse-server: split out module handling

Part of !776.
lines
Barnabás Pőcze 1 year ago
parent
commit
c9f5deb81d
6 changed files with 42 additions and 20 deletions
  1. +1
    -0
      src/modules/meson.build
  2. +2
    -0
      src/modules/module-protocol-pulse/internal.h
  3. +23
    -11
      src/modules/module-protocol-pulse/module.c
  4. +12
    -2
      src/modules/module-protocol-pulse/module.h
  5. +1
    -1
      src/modules/module-protocol-pulse/modules/registry.h
  6. +3
    -6
      src/modules/module-protocol-pulse/pulse-server.c

+ 1
- 0
src/modules/meson.build View File

@ -141,6 +141,7 @@ pipewire_module_protocol_pulse_sources = [
'module-protocol-pulse/manager.c',
'module-protocol-pulse/media-roles.c',
'module-protocol-pulse/message.c',
'module-protocol-pulse/module.c',
'module-protocol-pulse/operation.c',
'module-protocol-pulse/pending-sample.c',
'module-protocol-pulse/pulse-server.c',


+ 2
- 0
src/modules/module-protocol-pulse/internal.h View File

@ -83,4 +83,6 @@ struct impl {
extern bool debug_messages;
void broadcast_subscribe_event(struct impl *impl, uint32_t mask, uint32_t event, uint32_t id);
#endif

+ 23
- 11
src/modules/module-protocol-pulse/module.c View File

@ -23,11 +23,23 @@
* DEALINGS IN THE SOFTWARE.
*/
#include "module.h"
#include <stdlib.h>
#include <string.h>
#include <spa/utils/defs.h>
#include <spa/utils/list.h>
#include <spa/utils/hook.h>
#include <spa/utils/string.h>
static int module_unload(struct client *client, struct module *module);
#include <pipewire/log.h>
#include <pipewire/map.h>
#include <pipewire/properties.h>
#include <pipewire/work-queue.h>
#include "client.h"
#include "defs.h"
#include "format.h"
#include "internal.h"
#include "module.h"
static void on_module_unload(void *obj, void *data, int res, uint32_t id)
{
@ -52,20 +64,20 @@ struct module *module_new(struct impl *impl, const struct module_methods *method
module->impl = impl;
module->methods = methods;
spa_hook_list_init(&module->listener_list);
module->user_data = SPA_PTROFF(module, sizeof(struct module), void);
module->user_data = SPA_PTROFF(module, sizeof(*module), void);
module->loaded = false;
return module;
}
static void module_add_listener(struct module *module,
struct spa_hook *listener,
const struct module_events *events, void *data)
void module_add_listener(struct module *module,
struct spa_hook *listener,
const struct module_events *events, void *data)
{
spa_hook_list_append(&module->listener_list, listener, events, data);
}
static int module_load(struct client *client, struct module *module)
int module_load(struct client *client, struct module *module)
{
pw_log_info("load module id:%u name:%s", module->idx, module->name);
if (module->methods->load == NULL)
@ -75,7 +87,7 @@ static int module_load(struct client *client, struct module *module)
return module->methods->load(client, module);
}
static void module_free(struct module *module)
void module_free(struct module *module)
{
struct impl *impl = module->impl;
@ -92,7 +104,7 @@ static void module_free(struct module *module)
free(module);
}
static int module_unload(struct client *client, struct module *module)
int module_unload(struct client *client, struct module *module)
{
struct impl *impl = module->impl;
int res = 0;
@ -253,7 +265,7 @@ static const struct module_info *find_module_info(const char *name)
return NULL;
}
static struct module *create_module(struct client *client, const char *name, const char *args)
struct module *module_create(struct client *client, const char *name, const char *args)
{
struct impl *impl = client->impl;
const struct module_info *info;


+ 12
- 2
src/modules/module-protocol-pulse/module.h View File

@ -27,11 +27,13 @@
#define PIPEWIRE_PULSE_MODULE_H
#include <spa/param/audio/raw.h>
#include <spa/utils/hook.h>
#include "client.h"
#include "internal.h"
struct module;
struct pw_properties;
struct module_info {
const char *name;
@ -45,8 +47,6 @@ struct module_events {
void (*loaded) (void *data, int result);
};
#define module_emit_loaded(m,r) spa_hook_list_call(&m->listener_list, struct module_events, loaded, 0, r)
struct module_methods {
#define VERSION_MODULE_METHODS 0
uint32_t version;
@ -67,9 +67,19 @@ struct module {
unsigned int loaded:1;
};
#define module_emit_loaded(m,r) spa_hook_list_call(&m->listener_list, struct module_events, loaded, 0, r)
struct module *module_create(struct client *client, const char *name, const char *args);
void module_free(struct module *module);
struct module *module_new(struct impl *impl, const struct module_methods *methods, size_t user_data);
int module_load(struct client *client, struct module *module);
int module_unload(struct client *client, struct module *module);
void module_schedule_unload(struct module *module);
void module_add_listener(struct module *module,
struct spa_hook *listener,
const struct module_events *events, void *data);
void module_args_add_props(struct pw_properties *props, const char *str);
int module_args_to_audioinfo(struct impl *impl, struct pw_properties *props, struct spa_audio_info_raw *info);


+ 1
- 1
src/modules/module-protocol-pulse/modules/registry.h View File

@ -26,7 +26,7 @@
#ifndef PIPEWIRE_PULSE_MODULE_REGISTRY_H
#define PIPEWIRE_PULSE_MODULE_REGISTRY_H
#include "../internal.h"
struct impl;
struct module *create_module_combine_sink(struct impl *impl, const char *argument);
struct module *create_module_echo_cancel(struct impl *impl, const char *argument);


+ 3
- 6
src/modules/module-protocol-pulse/pulse-server.c View File

@ -67,6 +67,7 @@
#include "format.h"
#include "internal.h"
#include "message.h"
#include "module.h"
#include "operation.h"
#include "pending-sample.h"
#include "reply.h"
@ -100,10 +101,6 @@ struct latency_offset_data {
unsigned int initialized:1;
};
/* Functions that modules can use */
static void broadcast_subscribe_event(struct impl *impl, uint32_t mask, uint32_t event, uint32_t id);
#include "module.c"
#include "message-handler.c"
static struct sample *find_sample(struct impl *impl, uint32_t idx, const char *name)
@ -122,7 +119,7 @@ static struct sample *find_sample(struct impl *impl, uint32_t idx, const char *n
return NULL;
}
static void broadcast_subscribe_event(struct impl *impl, uint32_t mask, uint32_t event, uint32_t id)
void broadcast_subscribe_event(struct impl *impl, uint32_t mask, uint32_t event, uint32_t id)
{
struct server *s;
spa_list_for_each(s, &impl->servers, link) {
@ -4548,7 +4545,7 @@ static int do_load_module(struct client *client, uint32_t command, uint32_t tag,
pw_log_info(NAME" %p: [%s] %s name:%s argument:%s", impl,
client->name, commands[command].name, name, argument);
module = create_module(client, name, argument);
module = module_create(client, name, argument);
if (module == NULL)
return -errno;


Loading…
Cancel
Save