2023-02-08 18:12:00 +01:00
|
|
|
/* PipeWire */
|
|
|
|
|
/* SPDX-FileCopyrightText: Copyright © 2020 Georges Basile Stavracas Neto */
|
|
|
|
|
/* SPDX-FileCopyrightText: Copyright © 2021 Wim Taymans <wim.taymans@gmail.com> */
|
|
|
|
|
/* SPDX-License-Identifier: MIT */
|
2021-04-15 15:53:05 -04:00
|
|
|
|
|
|
|
|
#ifndef PIPEWIRE_PULSE_MODULE_H
|
|
|
|
|
#define PIPEWIRE_PULSE_MODULE_H
|
|
|
|
|
|
|
|
|
|
#include <spa/param/audio/raw.h>
|
2021-06-19 00:09:09 +02:00
|
|
|
#include <spa/utils/hook.h>
|
2021-04-15 15:53:05 -04:00
|
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
|
|
struct module;
|
2021-06-19 00:09:09 +02:00
|
|
|
struct pw_properties;
|
2021-04-15 15:53:05 -04:00
|
|
|
|
|
|
|
|
struct module_info {
|
|
|
|
|
const char *name;
|
2022-03-17 17:22:02 +01:00
|
|
|
|
2022-02-13 17:48:37 +02:00
|
|
|
unsigned int load_once:1;
|
2022-03-17 17:22:02 +01:00
|
|
|
|
2022-06-01 20:53:42 +02:00
|
|
|
int (*prepare) (struct module *module);
|
2022-12-06 18:26:29 +01:00
|
|
|
int (*load) (struct module *module);
|
2022-03-17 17:22:02 +01:00
|
|
|
int (*unload) (struct module *module);
|
2022-06-01 17:42:12 +02:00
|
|
|
|
2023-09-13 12:26:57 +02:00
|
|
|
const char* const *valid_args;
|
2022-06-01 17:42:12 +02:00
|
|
|
const struct spa_dict *properties;
|
2022-06-01 18:26:18 +02:00
|
|
|
size_t data_size;
|
2021-04-15 15:53:05 -04:00
|
|
|
};
|
|
|
|
|
|
2022-03-17 17:22:02 +01:00
|
|
|
#define DEFINE_MODULE_INFO(name) \
|
|
|
|
|
__attribute__((used)) \
|
2022-04-13 18:13:12 +02:00
|
|
|
__attribute__((retain)) \
|
2022-03-17 17:22:02 +01:00
|
|
|
__attribute__((section("pw_mod_pulse_modules"))) \
|
|
|
|
|
__attribute__((aligned(__alignof__(struct module_info)))) \
|
|
|
|
|
const struct module_info name
|
|
|
|
|
|
2021-04-15 15:53:05 -04:00
|
|
|
struct module_events {
|
|
|
|
|
#define VERSION_MODULE_EVENTS 0
|
|
|
|
|
uint32_t version;
|
|
|
|
|
|
2021-06-10 18:37:48 +02:00
|
|
|
void (*loaded) (void *data, int result);
|
2021-11-12 18:54:17 +01:00
|
|
|
void (*destroy) (void *data);
|
2021-04-15 15:53:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct module {
|
2022-01-17 11:28:40 +01:00
|
|
|
uint32_t index;
|
2021-04-15 15:53:05 -04:00
|
|
|
const char *args;
|
|
|
|
|
struct pw_properties *props;
|
|
|
|
|
struct impl *impl;
|
2022-03-17 17:22:02 +01:00
|
|
|
const struct module_info *info;
|
2021-06-10 18:31:50 +02:00
|
|
|
struct spa_hook_list listener_list;
|
2021-04-15 15:53:05 -04:00
|
|
|
void *user_data;
|
2021-06-06 15:49:58 +02:00
|
|
|
unsigned int loaded:1;
|
2021-12-28 19:21:01 +01:00
|
|
|
unsigned int unloading:1;
|
2021-04-15 15:53:05 -04:00
|
|
|
};
|
|
|
|
|
|
2021-06-19 00:09:09 +02:00
|
|
|
#define module_emit_loaded(m,r) spa_hook_list_call(&m->listener_list, struct module_events, loaded, 0, r)
|
2021-11-12 18:54:17 +01:00
|
|
|
#define module_emit_destroy(m) spa_hook_list_call(&(m)->listener_list, struct module_events, destroy, 0)
|
2021-06-19 00:09:09 +02:00
|
|
|
|
2022-12-06 18:26:29 +01:00
|
|
|
struct module *module_create(struct impl *impl, const char *name, const char *args);
|
2021-06-19 00:09:09 +02:00
|
|
|
void module_free(struct module *module);
|
2022-12-06 18:26:29 +01:00
|
|
|
int module_load(struct module *module);
|
2022-01-30 17:08:55 +01:00
|
|
|
int module_unload(struct module *module);
|
2021-04-21 13:11:16 +02:00
|
|
|
void module_schedule_unload(struct module *module);
|
2021-04-15 15:53:05 -04:00
|
|
|
|
2021-06-19 00:09:09 +02:00
|
|
|
void module_add_listener(struct module *module,
|
|
|
|
|
struct spa_hook *listener,
|
|
|
|
|
const struct module_events *events, void *data);
|
|
|
|
|
|
2021-04-15 15:53:05 -04:00
|
|
|
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);
|
2021-09-21 17:37:39 +02:00
|
|
|
bool module_args_parse_bool(const char *str);
|
2023-05-04 18:43:08 +02:00
|
|
|
int module_args_to_audioinfo_keys(struct impl *impl, struct pw_properties *props,
|
|
|
|
|
const char *key_format, const char *key_rate,
|
|
|
|
|
const char *key_channels, const char *key_channel_map,
|
|
|
|
|
struct spa_audio_info_raw *info);
|
|
|
|
|
|
|
|
|
|
void audioinfo_to_properties(struct spa_audio_info_raw *info, struct pw_properties *props);
|
|
|
|
|
|
2021-04-15 15:53:05 -04:00
|
|
|
|
|
|
|
|
#endif
|