PipeWire  0.3.35
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/defs.h>
34 
40 #define SPA_TYPE_INTERFACE_PluginLoader SPA_TYPE_INFO_INTERFACE_BASE "PluginLoader"
41 
42 #define SPA_VERSION_PLUGIN_LOADER 0
44 
46 #define SPA_VERSION_PLUGIN_LOADER_METHODS 0
47  uint32_t version;
48 
56  struct spa_handle *(*load) (void *object, const char *factory_name, const struct spa_dict *info);
57 
64  int (*unload)(void *object, struct spa_handle *handle);
65 };
66 
67 /* static */ inline struct spa_handle *
68 spa_plugin_loader_load(struct spa_plugin_loader *loader, const char *factory_name, const struct spa_dict *info)
69 {
70  struct spa_handle *res = NULL;
71  if (SPA_LIKELY(loader != NULL))
73  struct spa_plugin_loader_methods, res,
74  load, 0, factory_name, info);
75  return res;
76 }
77 
78 /* static */ inline int
80 {
81  int res = -1;
82  if (SPA_LIKELY(loader != NULL))
84  struct spa_plugin_loader_methods, res,
85  unload, 0, handle);
86  return res;
87 }
88 
93 #ifdef __cplusplus
94 } /* extern "C" */
95 #endif
96 
97 #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:208
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:68
int spa_plugin_loader_unload(struct spa_plugin_loader *loader, struct spa_handle *handle)
Definition: plugin-loader.h:79
#define SPA_LIKELY(x)
Definition: defs.h:236
Definition: pipewire.c:68
Definition: utils/dict.h:48
Definition: plugin.h:44
Definition: hook.h:146
Definition: plugin-loader.h:45
int(* unload)(void *object, struct spa_handle *handle)
Unload a SPA plugin.
Definition: plugin-loader.h:64
uint32_t version
Definition: plugin-loader.h:47
Definition: plugin-loader.h:43
struct spa_interface iface
Definition: plugin-loader.h:43