1 | //slfi.h: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015 |
---|
5 | * |
---|
6 | * This file is part of libroar a part of RoarAudio, |
---|
7 | * a cross-platform sound system for both, home and professional use. |
---|
8 | * See README for details. |
---|
9 | * |
---|
10 | * This file is free software; you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU General Public License version 3 |
---|
12 | * as published by the Free Software Foundation. |
---|
13 | * |
---|
14 | * libroar is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this software; see the file COPYING. If not, write to |
---|
21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
22 | * Boston, MA 02110-1301, USA. |
---|
23 | * |
---|
24 | * NOTE for everyone want's to change something and send patches: |
---|
25 | * read README and HACKING! There a addition information on |
---|
26 | * the license of this document you need to read before you send |
---|
27 | * any patches. |
---|
28 | * |
---|
29 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
30 | * or libpulse*: |
---|
31 | * The libs libroaresd, libroararts and libroarpulse link this lib |
---|
32 | * and are therefore GPL. Because of this it may be illigal to use |
---|
33 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
34 | */ |
---|
35 | |
---|
36 | // SLFI = Simple Light Filter Infrastructure |
---|
37 | |
---|
38 | #ifndef _LIBROARLIGHT_SLFI_H_ |
---|
39 | #define _LIBROARLIGHT_SLFI_H_ |
---|
40 | |
---|
41 | #include "libroarlight.h" |
---|
42 | |
---|
43 | enum roar_slfi_command { |
---|
44 | ROAR_SLFI_CMD_NONE = 0x00000000U, |
---|
45 | ROAR_SLFI_CMD_PUSH = 0x00000001U, /* push a new filter into the container */ |
---|
46 | ROAR_SLFI_CMD_MAX = 0xFFFFFFFFU |
---|
47 | }; |
---|
48 | |
---|
49 | #define ROAR_SLFI_FLAG_NONE 0x00000000U /* no flags */ |
---|
50 | #define ROAR_SLFI_FLAG_ON_UPDATE 0x00000001U /* update() only needs to be run if there is an actual update */ |
---|
51 | |
---|
52 | struct roar_slfi_inst; |
---|
53 | |
---|
54 | struct roar_slfi_filter { |
---|
55 | const char * name; |
---|
56 | const char * description; |
---|
57 | const uint32_t flags; |
---|
58 | // init |
---|
59 | int (*init)(struct roar_slfi_inst * inst, const struct roar_keyval * para, ssize_t paralen); |
---|
60 | // uninit |
---|
61 | int (*uninit)(struct roar_slfi_inst * inst); |
---|
62 | // update |
---|
63 | int (*update)(struct roar_slfi_inst * inst, uint8_t * universe, ssize_t size_of_universe, int32_t usecspassed, const uint8_t * event, size_t eventlen); |
---|
64 | // ctl |
---|
65 | int (*ctl)(struct roar_slfi_inst * inst, enum roar_slfi_command command, void * argp); |
---|
66 | }; |
---|
67 | |
---|
68 | #define ROAR_DL_FILTER_VERSION_SLFI 0 |
---|
69 | #define ROAR_DL_FILTER_SIZE_SLFI sizeof(struct roar_slfi_filter) |
---|
70 | |
---|
71 | #define ROAR_DL_PLUGIN_REG_SLFI(obj) \ |
---|
72 | static int _roaraudio_library_ROAR_DL_FN_FILTER(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib) { \ |
---|
73 | size_t i; \ |
---|
74 | (void)para, (void)lib; \ |
---|
75 | for (i = 0; i < (sizeof((obj))/sizeof(*(obj))); i++) { \ |
---|
76 | ROAR_DL_PLUGIN_REG_FN(ROAR_DL_FILTER_SUBTYPE_SLFI, (obj)[i], ROAR_DL_FILTER_VERSION_SLFI); \ |
---|
77 | } \ |
---|
78 | return 0; \ |
---|
79 | } |
---|
80 | |
---|
81 | struct roar_slfi_inst { |
---|
82 | size_t refc; |
---|
83 | const struct roar_slfi_filter * impl; |
---|
84 | uint32_t flags; // same as flags on *impl. just runtime updateable. |
---|
85 | void * userdata; |
---|
86 | struct roar_dl_lhandle * lhandle; // used in case we autoload this as plugin. |
---|
87 | int (*cb_event_add)(struct roar_slfi_inst * inst, void * userdata, uint8_t event); |
---|
88 | void * cb_event_add_userdata; |
---|
89 | }; |
---|
90 | |
---|
91 | struct roar_slfi_inst * roar_slfi_new(const char * name, int autoload, const struct roar_keyval * para, ssize_t paralen); |
---|
92 | int roar_slfi_ref(struct roar_slfi_inst * inst); |
---|
93 | int roar_slfi_unref(struct roar_slfi_inst * inst); |
---|
94 | int roar_slfi_update(struct roar_slfi_inst * inst, uint8_t * universe, ssize_t size_of_universe, int32_t usecspassed, const uint8_t * event, size_t eventlen); |
---|
95 | int roar_slfi_ctl(struct roar_slfi_inst * inst, enum roar_slfi_command command, void * argp); |
---|
96 | |
---|
97 | int roar_slfi_event_add(struct roar_slfi_inst * inst, uint8_t event); // does not perform any context switching. |
---|
98 | int roar_slfi_cb_set_event_add(struct roar_slfi_inst * inst, int (*cb)(struct roar_slfi_inst * inst, void * userdata, uint8_t event), void * userdata); |
---|
99 | |
---|
100 | #endif |
---|
101 | |
---|
102 | //ll |
---|