Changeset 3355:0541a1f8b343 in roaraudio


Ignore:
Timestamp:
02/08/10 15:11:42 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

wrote plugin functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/plugins.c

    r3354 r3355  
    2525#include "roard.h" 
    2626 
     27#define MAX_PLUGINS    8 
     28 
     29static struct roar_dl_lhandle * g_plugins[MAX_PLUGINS]; 
     30 
     31static 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 
    2742int plugins_preinit  (void) { 
     43 memset(g_plugins, 0, sizeof(g_plugins)); 
     44 
    2845 return 0; 
    2946} 
    3047 
    3148int 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 
    3257 return 0; 
    3358} 
    3459 
    3560int 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 
    3669 return 0; 
    3770} 
    3871 
    3972int plugins_load  (const char * filename) { 
    40  return -1; 
     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; 
    4183} 
    4284 
Note: See TracChangeset for help on using the changeset viewer.