Changeset 3362:2bf10ee217b5 in roaraudio
- Timestamp:
- 02/08/10 16:36:13 (14 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- roard
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/include/plugins.h
r3354 r3362 28 28 #include <roaraudio.h> 29 29 30 struct roard_plugins_sched { 31 int (*init)(void); 32 int (*free)(void); 33 int (*update)(void); 34 }; 35 30 36 int plugins_preinit (void); 31 37 int plugins_init (void); 32 38 int plugins_free (void); 39 int plugins_update (void); 33 40 34 41 int plugins_load (const char * filename); 42 43 int plugins_reg_sched(struct roard_plugins_sched * sched); 35 44 36 45 #endif -
roard/loop.c
r3358 r3362 112 112 */ 113 113 114 if ( plugins_update() == -1 ) 115 alive = 0; 114 116 115 117 ROAR_DBG("main_loop(*): sending output data..."); -
roard/plugins.c
r3357 r3362 27 27 #define MAX_PLUGINS 8 28 28 29 static struct roar_dl_lhandle * g_plugins[MAX_PLUGINS]; 29 static struct _roard_plugin { 30 struct roar_dl_lhandle * lhandle; 31 struct roard_plugins_sched * sched; 32 } g_plugins[MAX_PLUGINS]; 33 static struct _roard_plugin * _pp = NULL; 30 34 31 static struct roar_dl_lhandle ** _find_free(void) {35 static struct _roard_plugin * _find_free(void) { 32 36 int i; 33 37 34 38 for (i = 0; i < MAX_PLUGINS; i++) { 35 if ( g_plugins[i] == NULL ) 39 if ( g_plugins[i].lhandle == NULL ) { 40 memset(&(g_plugins[i]), 0, sizeof(struct _roard_plugin)); 36 41 return &(g_plugins[i]); 42 } 37 43 } 38 44 … … 50 56 51 57 for (i = 0; i < MAX_PLUGINS; i++) { 52 if ( g_plugins[i] != NULL ) { 53 roar_dl_ra_init(g_plugins[i], NULL); 58 if ( g_plugins[i].lhandle != NULL ) { 59 _pp = &(g_plugins[i]); 60 61 roar_dl_ra_init(g_plugins[i].lhandle, NULL); 62 63 if ( g_plugins[i].sched->init != NULL ) 64 g_plugins[i].sched->init(); 65 66 _pp = NULL; 54 67 } 55 68 } … … 62 75 63 76 for (i = 0; i < MAX_PLUGINS; i++) { 64 if ( g_plugins[i] != NULL ) { 65 roar_dl_close(g_plugins[i]); 77 if ( g_plugins[i].lhandle != NULL ) { 78 if ( g_plugins[i].sched->free != NULL ) 79 g_plugins[i].sched->free(); 80 81 roar_dl_close(g_plugins[i].lhandle); 66 82 } 67 83 } … … 70 86 } 71 87 88 int plugins_update (void) { 89 int ret = 0; 90 int i; 91 92 for (i = 0; i < MAX_PLUGINS; i++) 93 if ( g_plugins[i].lhandle != NULL ) 94 if ( g_plugins[i].sched->update != NULL ) 95 if ( g_plugins[i].sched->update() == -1 ) 96 ret = -1; 97 98 return ret; 99 } 100 72 101 int plugins_load (const char * filename) { 73 struct roar_dl_lhandle ** next = _find_free();102 struct _roard_plugin * next = _find_free(); 74 103 75 104 if ( next == NULL ) 76 105 return -1; 77 106 78 *next= roar_dl_open(filename, -1, 0 /* we delay this until plugins_init() */);79 if ( *next== NULL )107 next->lhandle = roar_dl_open(filename, -1, 0 /* we delay this until plugins_init() */); 108 if ( next->lhandle == NULL ) 80 109 return -1; 81 110 … … 83 112 } 84 113 114 int plugins_reg_sched(struct roard_plugins_sched * sched) { 115 if ( _pp == NULL ) 116 return -1; 117 118 _pp->sched = sched; 119 120 return 0; 121 } 122 85 123 //ll
Note: See TracChangeset
for help on using the changeset viewer.