+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
c · 81 lines · 1.9 KB · SPDX: MIT
main
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 #include <spa/utils/hook.h>
9 #include <spa/utils/dict.h>
10  
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14  
15 #ifndef SPA_API_PLUGIN_LOADER
16 #ifdef SPA_API_IMPL
17 #define SPA_API_PLUGIN_LOADER SPA_API_IMPL
18 #else
19 #define SPA_API_PLUGIN_LOADER static inline
20 #endif
21 #endif
22  
23 /** \defgroup spa_plugin_loader Plugin Loader
24 * SPA plugin loader
25 */
26  
27 /**
28 * \addtogroup spa_plugin_loader
29 * \{
30 */
31  
32 #define SPA_TYPE_INTERFACE_PluginLoader SPA_TYPE_INFO_INTERFACE_BASE "PluginLoader"
33  
34 #define SPA_VERSION_PLUGIN_LOADER 0
35 struct spa_plugin_loader { struct spa_interface iface; };
36  
37 struct spa_plugin_loader_methods {
38 #define SPA_VERSION_PLUGIN_LOADER_METHODS 0
39 uint32_t version;
40  
41 /**
42 * Load a SPA plugin.
43 *
44 * \param factory_name Plugin factory name
45 * \param info Info dictionary for plugin. NULL if none.
46 * \return plugin handle, or NULL on error
47 */
48 struct spa_handle *(*load) (void *object, const char *factory_name, const struct spa_dict *info);
49  
50 /**
51 * Unload a SPA plugin.
52 *
53 * \param handle Plugin handle.
54 * \return 0 on success, < 0 on error
55 */
56 int (*unload)(void *object, struct spa_handle *handle);
57 };
58  
59 SPA_API_PLUGIN_LOADER struct spa_handle *
60 spa_plugin_loader_load(struct spa_plugin_loader *loader, const char *factory_name, const struct spa_dict *info)
61 {
62 return spa_api_method_null_r(struct spa_handle *, NULL, spa_plugin_loader, loader, &loader->iface,
63 load, 0, factory_name, info);
64 }
65  
66 SPA_API_PLUGIN_LOADER int
67 spa_plugin_loader_unload(struct spa_plugin_loader *loader, struct spa_handle *handle)
68 {
69 return spa_api_method_null_r(int, -1, spa_plugin_loader, loader, &loader->iface,
70 unload, 0, handle);
71 }
72  
73 /**
74 * \}
75 */
76  
77 #ifdef __cplusplus
78 } /* extern "C" */
79 #endif
80  
81 #endif /* SPA_PLUGIN_LOADER_H */