mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
parent
c49ae39888
commit
c9f5deb81d
6 changed files with 41 additions and 19 deletions
|
|
@ -141,6 +141,7 @@ pipewire_module_protocol_pulse_sources = [
|
||||||
'module-protocol-pulse/manager.c',
|
'module-protocol-pulse/manager.c',
|
||||||
'module-protocol-pulse/media-roles.c',
|
'module-protocol-pulse/media-roles.c',
|
||||||
'module-protocol-pulse/message.c',
|
'module-protocol-pulse/message.c',
|
||||||
|
'module-protocol-pulse/module.c',
|
||||||
'module-protocol-pulse/operation.c',
|
'module-protocol-pulse/operation.c',
|
||||||
'module-protocol-pulse/pending-sample.c',
|
'module-protocol-pulse/pending-sample.c',
|
||||||
'module-protocol-pulse/pulse-server.c',
|
'module-protocol-pulse/pulse-server.c',
|
||||||
|
|
|
||||||
|
|
@ -83,4 +83,6 @@ struct impl {
|
||||||
|
|
||||||
extern bool debug_messages;
|
extern bool debug_messages;
|
||||||
|
|
||||||
|
void broadcast_subscribe_event(struct impl *impl, uint32_t mask, uint32_t event, uint32_t id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,23 @@
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* 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>
|
#include <spa/utils/string.h>
|
||||||
|
#include <pipewire/log.h>
|
||||||
|
#include <pipewire/map.h>
|
||||||
|
#include <pipewire/properties.h>
|
||||||
|
#include <pipewire/work-queue.h>
|
||||||
|
|
||||||
static int module_unload(struct client *client, struct module *module);
|
#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)
|
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->impl = impl;
|
||||||
module->methods = methods;
|
module->methods = methods;
|
||||||
spa_hook_list_init(&module->listener_list);
|
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;
|
module->loaded = false;
|
||||||
|
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void module_add_listener(struct module *module,
|
void module_add_listener(struct module *module,
|
||||||
struct spa_hook *listener,
|
struct spa_hook *listener,
|
||||||
const struct module_events *events, void *data)
|
const struct module_events *events, void *data)
|
||||||
{
|
{
|
||||||
spa_hook_list_append(&module->listener_list, listener, events, 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);
|
pw_log_info("load module id:%u name:%s", module->idx, module->name);
|
||||||
if (module->methods->load == NULL)
|
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);
|
return module->methods->load(client, module);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void module_free(struct module *module)
|
void module_free(struct module *module)
|
||||||
{
|
{
|
||||||
struct impl *impl = module->impl;
|
struct impl *impl = module->impl;
|
||||||
|
|
||||||
|
|
@ -92,7 +104,7 @@ static void module_free(struct module *module)
|
||||||
free(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;
|
struct impl *impl = module->impl;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
@ -253,7 +265,7 @@ static const struct module_info *find_module_info(const char *name)
|
||||||
return NULL;
|
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;
|
struct impl *impl = client->impl;
|
||||||
const struct module_info *info;
|
const struct module_info *info;
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,13 @@
|
||||||
#define PIPEWIRE_PULSE_MODULE_H
|
#define PIPEWIRE_PULSE_MODULE_H
|
||||||
|
|
||||||
#include <spa/param/audio/raw.h>
|
#include <spa/param/audio/raw.h>
|
||||||
|
#include <spa/utils/hook.h>
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
struct module;
|
struct module;
|
||||||
|
struct pw_properties;
|
||||||
|
|
||||||
struct module_info {
|
struct module_info {
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
@ -45,8 +47,6 @@ struct module_events {
|
||||||
void (*loaded) (void *data, int result);
|
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 {
|
struct module_methods {
|
||||||
#define VERSION_MODULE_METHODS 0
|
#define VERSION_MODULE_METHODS 0
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
|
|
@ -67,9 +67,19 @@ struct module {
|
||||||
unsigned int loaded:1;
|
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);
|
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_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);
|
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);
|
int module_args_to_audioinfo(struct impl *impl, struct pw_properties *props, struct spa_audio_info_raw *info);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
#ifndef PIPEWIRE_PULSE_MODULE_REGISTRY_H
|
#ifndef PIPEWIRE_PULSE_MODULE_REGISTRY_H
|
||||||
#define 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_combine_sink(struct impl *impl, const char *argument);
|
||||||
struct module *create_module_echo_cancel(struct impl *impl, const char *argument);
|
struct module *create_module_echo_cancel(struct impl *impl, const char *argument);
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
#include "module.h"
|
||||||
#include "operation.h"
|
#include "operation.h"
|
||||||
#include "pending-sample.h"
|
#include "pending-sample.h"
|
||||||
#include "reply.h"
|
#include "reply.h"
|
||||||
|
|
@ -100,10 +101,6 @@ struct latency_offset_data {
|
||||||
unsigned int initialized:1;
|
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"
|
#include "message-handler.c"
|
||||||
|
|
||||||
static struct sample *find_sample(struct impl *impl, uint32_t idx, const char *name)
|
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;
|
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;
|
struct server *s;
|
||||||
spa_list_for_each(s, &impl->servers, link) {
|
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,
|
pw_log_info(NAME" %p: [%s] %s name:%s argument:%s", impl,
|
||||||
client->name, commands[command].name, name, argument);
|
client->name, commands[command].name, name, argument);
|
||||||
|
|
||||||
module = create_module(client, name, argument);
|
module = module_create(client, name, argument);
|
||||||
if (module == NULL)
|
if (module == NULL)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue