PipeWire  0.3.61
plugin-loader.h
Go to the documentation of this file.
1 /* Simple Plugin API
2  *
3  * Copyright © 2021 Wim Taymans
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef SPA_PLUGIN_LOADER_H
26 #define SPA_PLUGIN_LOADER_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <spa/utils/hook.h>
33 #include <spa/utils/dict.h>
34 
44 #define SPA_TYPE_INTERFACE_PluginLoader SPA_TYPE_INFO_INTERFACE_BASE "PluginLoader"
45 
46 #define SPA_VERSION_PLUGIN_LOADER 0
47 struct spa_plugin_loader { struct spa_interface iface; };
48 
50 #define SPA_VERSION_PLUGIN_LOADER_METHODS 0
51  uint32_t version;
52 
60  struct spa_handle *(*load) (void *object, const char *factory_name, const struct spa_dict *info);
61 
68  int (*unload)(void *object, struct spa_handle *handle);
69 };
70 
71 static inline struct spa_handle *
72 spa_plugin_loader_load(struct spa_plugin_loader *loader, const char *factory_name, const struct spa_dict *info)
73 {
74  struct spa_handle *res = NULL;
75  if (SPA_LIKELY(loader != NULL))
77  struct spa_plugin_loader_methods, res,
78  load, 0, factory_name, info);
79  return res;
80 }
81 
82 static inline int
83 spa_plugin_loader_unload(struct spa_plugin_loader *loader, struct spa_handle *handle)
84 {
85  int res = -1;
86  if (SPA_LIKELY(loader != NULL))
88  struct spa_plugin_loader_methods, res,
89  unload, 0, handle);
90  return res;
91 }
92 
97 #ifdef __cplusplus
98 } /* extern "C" */
99 #endif
100 
101 #endif /* SPA_PLUGIN_LOADER_H */
#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:255
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:80
static int spa_plugin_loader_unload(struct spa_plugin_loader *loader, struct spa_handle *handle)
Definition: plugin-loader.h:91
#define SPA_LIKELY(x)
Definition: defs.h:353
spa/utils/hook.h
Definition: dict.h:59
Definition: plugin.h:50
Definition: hook.h:158
Definition: plugin-loader.h:56
int(* unload)(void *object, struct spa_handle *handle)
Unload a SPA plugin.
Definition: plugin-loader.h:76
uint32_t version
Definition: plugin-loader.h:59
Definition: plugin-loader.h:54
struct spa_interface iface
Definition: plugin-loader.h:54
spa/utils/dict.h