pulse-server: pass already created module object to module_info::create()

All modules need to manually create a `module` object and check
if it was successfully created. The same with argument parsing.
To simplify modules, move the module object creation and argument
parsing into `module_create()`, and pass the already initialized
module to `module_info::create()`.

The semantics of `module_info::create()` are kept, that is,
if it fails, `module_info::unload()` will not be called.
This commit is contained in:
Barnabás Pőcze 2022-06-01 18:26:18 +02:00
parent 5ad52bb88a
commit fa3a28ab68
25 changed files with 210 additions and 548 deletions

View file

@ -40,11 +40,12 @@ struct module_info {
unsigned int load_once:1;
struct module *(*create) (struct impl *impl, const char *args);
int (*create) (struct module *module);
int (*load) (struct client *client, struct module *module);
int (*unload) (struct module *module);
const struct spa_dict *properties;
size_t data_size;
};
#define DEFINE_MODULE_INFO(name) \
@ -79,7 +80,6 @@ struct module {
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, size_t user_data);
int module_load(struct client *client, struct module *module);
int module_unload(struct module *module);
void module_schedule_unload(struct module *module);