PipeWire 1.2.6

Loading...
Searching...
No Matches
plugin-loader.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2021 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_PLUGIN_LOADER_H
6#define SPA_PLUGIN_LOADER_H
7
8#ifdef __cplusplus
9 extern "C" {
10#endif
11
12#include <spa/utils/hook.h>
13#include <spa/utils/dict.h>
14
24#define SPA_TYPE_INTERFACE_PluginLoader SPA_TYPE_INFO_INTERFACE_BASE "PluginLoader"
25
26#define SPA_VERSION_PLUGIN_LOADER 0
27 struct spa_plugin_loader { struct spa_interface iface; };
28
29 struct spa_plugin_loader_methods {
30#define SPA_VERSION_PLUGIN_LOADER_METHODS 0
31 uint32_t version;
32
40 struct spa_handle *(*load) (void *object, const char *factory_name, const struct spa_dict *info);
41
48 int (*unload)(void *object, struct spa_handle *handle);
49};
50
51 static inline struct spa_handle *
52 spa_plugin_loader_load(struct spa_plugin_loader *loader, const char *factory_name, const struct spa_dict *info)
53{
54 struct spa_handle *res = NULL;
55 if (SPA_LIKELY(loader != NULL))
56 spa_interface_call_res(&loader->iface,
57 struct spa_plugin_loader_methods, res,
58 load, 0, factory_name, info);
59 return res;
60}
61
62 static inline int
63 spa_plugin_loader_unload(struct spa_plugin_loader *loader, struct spa_handle *handle)
64{
65 int res = -1;
66 if (SPA_LIKELY(loader != NULL))
67 spa_interface_call_res(&loader->iface,
68 struct spa_plugin_loader_methods, res,
69 unload, 0, handle);
70 return res;
71}
72
77#ifdef __cplusplus
78} /* extern "C" */
79#endif
80
81#endif /* SPA_PLUGIN_LOADER_H */
spa_interface_call_res
#define spa_interface_call_res(iface, method_type, res, method, vers,...)
Invoke method named method in the callbacks on the given interface object.
Definition hook.h:251
spa_plugin_loader_load
static struct spa_handle * spa_plugin_loader_load(struct spa_plugin_loader *loader, const char *factory_name, const struct spa_dict *info)
Definition plugin-loader.h:60
spa_plugin_loader_unload
static int spa_plugin_loader_unload(struct spa_plugin_loader *loader, struct spa_handle *handle)
Definition plugin-loader.h:71
SPA_LIKELY
#define SPA_LIKELY(x)
Definition defs.h:367
hook.h
spa/utils/hook.h
spa_dict
Definition dict.h:39
spa_handle
Definition plugin.h:30
spa_interface
Definition hook.h:138
spa_plugin_loader_methods
Definition plugin-loader.h:36
spa_plugin_loader_methods::unload
int(* unload)(void *object, struct spa_handle *handle)
Unload a SPA plugin.
Definition plugin-loader.h:56
spa_plugin_loader_methods::version
uint32_t version
Definition plugin-loader.h:39
spa_plugin_loader
Definition plugin-loader.h:34
spa_plugin_loader::iface
struct spa_interface iface
Definition plugin-loader.h:34
dict.h
spa/utils/dict.h