1 /* PipeWire 2 * 3 * Copyright © 2020 Georges Basile Stavracas Neto 4 * Copyright © 2021 Wim Taymans <wim.taymans@gmail.com> 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the "Software"), 8 * to deal in the Software without restriction, including without limitation 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice (including the next 14 * paragraph) shall be included in all copies or substantial portions of the 15 * Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 * DEALINGS IN THE SOFTWARE. 24 */ 25 26 #ifndef PIPEWIRE_PULSE_MODULE_H 27 #define PIPEWIRE_PULSE_MODULE_H 28 29 #include <spa/param/audio/raw.h> 30 #include <spa/utils/hook.h> 31 32 #include "client.h" 33 #include "internal.h" 34 35 struct module; 36 struct pw_properties; 37 38 struct module_info { 39 const char *name; 40 struct module *(*create) (struct impl *impl, const char *args); 41 }; 42 43 struct module_events { 44 #define VERSION_MODULE_EVENTS 0 45 uint32_t version; 46 47 void (*loaded) (void *data, int result); 48 void (*destroy) (void *data); 49 }; 50 51 struct module_methods { 52 #define VERSION_MODULE_METHODS 0 53 uint32_t version; 54 55 int (*load) (struct client *client, struct module *module); 56 int (*unload) (struct client *client, struct module *module); 57 }; 58 59 struct module { 60 uint32_t idx; 61 const char *name; 62 const char *args; 63 struct pw_properties *props; 64 struct impl *impl; 65 const struct module_methods *methods; 66 struct spa_hook_list listener_list; 67 void *user_data; 68 unsigned int loaded:1; 69 unsigned int unloading:1; 70 }; 71 72 #define module_emit_loaded(m,r) spa_hook_list_call(&m->listener_list, struct module_events, loaded, 0, r) 73 #define module_emit_destroy(m) spa_hook_list_call(&(m)->listener_list, struct module_events, destroy, 0) 74 75 struct module *module_create(struct client *client, const char *name, const char *args); 76 void module_free(struct module *module); 77 struct module *module_new(struct impl *impl, const struct module_methods *methods, size_t user_data); 78 int module_load(struct client *client, struct module *module); 79 int module_unload(struct client *client, struct module *module); 80 void module_schedule_unload(struct module *module); 81 82 void module_add_listener(struct module *module, 83 struct spa_hook *listener, 84 const struct module_events *events, void *data); 85 86 void module_args_add_props(struct pw_properties *props, const char *str); 87 int module_args_to_audioinfo(struct impl *impl, struct pw_properties *props, struct spa_audio_info_raw *info); 88 bool module_args_parse_bool(const char *str); 89 90 #endif 91