1 | //plugins.c: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010 |
---|
5 | * |
---|
6 | * This file is part of roard 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 | * RoarAudio 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, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
22 | * |
---|
23 | */ |
---|
24 | |
---|
25 | #include "roard.h" |
---|
26 | |
---|
27 | #define MAX_PLUGINS 8 |
---|
28 | |
---|
29 | static struct roar_dl_lhandle * g_plugins[MAX_PLUGINS]; |
---|
30 | |
---|
31 | static struct roar_dl_lhandle ** _find_free(void) { |
---|
32 | int i; |
---|
33 | |
---|
34 | for (i = 0; i < MAX_PLUGINS; i++) { |
---|
35 | if ( g_plugins[i] == NULL ) |
---|
36 | return &(g_plugins[i]); |
---|
37 | } |
---|
38 | |
---|
39 | return NULL; |
---|
40 | } |
---|
41 | |
---|
42 | int plugins_preinit (void) { |
---|
43 | memset(g_plugins, 0, sizeof(g_plugins)); |
---|
44 | |
---|
45 | return 0; |
---|
46 | } |
---|
47 | |
---|
48 | int plugins_init (void) { |
---|
49 | int i; |
---|
50 | |
---|
51 | for (i = 0; i < MAX_PLUGINS; i++) { |
---|
52 | if ( g_plugins[i] != NULL ) { |
---|
53 | roar_dl_ra_init(g_plugins[i], NULL); |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | return 0; |
---|
58 | } |
---|
59 | |
---|
60 | int plugins_free (void) { |
---|
61 | int i; |
---|
62 | |
---|
63 | for (i = 0; i < MAX_PLUGINS; i++) { |
---|
64 | if ( g_plugins[i] != NULL ) { |
---|
65 | roar_dl_close(g_plugins[i]); |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | return plugins_preinit(); |
---|
70 | } |
---|
71 | |
---|
72 | int plugins_load (const char * filename) { |
---|
73 | struct roar_dl_lhandle ** next = _find_free(); |
---|
74 | |
---|
75 | if ( next == NULL ) |
---|
76 | return -1; |
---|
77 | |
---|
78 | *next = roar_dl_open(filename, -1, 0 /* we delay this until plugins_init() */); |
---|
79 | if ( *next == NULL ) |
---|
80 | return -1; |
---|
81 | |
---|
82 | return 0; |
---|
83 | } |
---|
84 | |
---|
85 | //ll |
---|