Changeset 5275:811818eb5b81 in roaraudio for roard
- Timestamp:
- 11/19/11 22:54:26 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- roard
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/clients.c
r5242 r5275 38 38 #ifndef ROAR_WITHOUT_DCOMP_EMUL_ESD 39 39 #ifdef ROAR_HAVE_H_ESD 40 {ROAR_PROTO_ESOUND, NULL, emul_esd_check_client, NULL, NULL},40 {ROAR_PROTO_ESOUND, ROAR_SUBSYS_WAVEFORM, "EsounD emulation", NULL, emul_esd_check_client, NULL, NULL}, 41 41 #endif 42 42 #endif 43 43 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RPLAY 44 {ROAR_PROTO_RPLAY, NULL, emul_rplay_check_client, NULL, NULL},44 {ROAR_PROTO_RPLAY, ROAR_SUBSYS_WAVEFORM, "RPlay emulation", NULL, emul_rplay_check_client, NULL, NULL}, 45 45 #endif 46 46 #ifndef ROAR_WITHOUT_DCOMP_EMUL_GOPHER 47 {ROAR_PROTO_GOPHER, NULL, emul_gopher_check_client, NULL, emul_gopher_flushed_client},48 #endif 49 {-1, NULL}47 {ROAR_PROTO_GOPHER, ROAR_SUBSYS_WAVEFORM, "The Internet Gopher Protocol", NULL, emul_gopher_check_client, NULL, emul_gopher_flushed_client}, 48 #endif 49 {-1, 0, NULL, NULL, NULL, NULL, NULL} 50 50 }; 51 51 … … 58 58 for (i = 0; i < ROAR_CLIENTS_MAX; i++) 59 59 g_clients[i] = NULL; 60 61 for (i = 0; g_proto[i].proto != -1; i++); 62 63 for (; i < MAX_PROTOS; i++) 64 g_proto[i].proto = -1; 60 65 61 66 return 0; … … 826 831 memcpy(&(g_proto[i]), proto, sizeof(*g_proto)); 827 832 828 i++; 829 830 memset(&(g_proto[i]), 0, sizeof(*g_proto)); 831 g_proto[i].proto = -1; 832 833 return 0; 834 } 835 833 return 0; 834 } 835 836 int clients_unregister_proto(int proto) { 837 const size_t len = sizeof(g_proto)/sizeof(*g_proto); 838 size_t i; 839 840 if ( proto < 0 ) { 841 roar_err_set(ROAR_ERROR_RANGE); 842 return -1; 843 } 844 845 for (i = 0; i < len; i++) { 846 if ( g_proto[i].proto == proto ) { 847 memset(&(g_proto[i]), 0, sizeof(*g_proto)); 848 g_proto[i].proto = -1; 849 return 0; 850 } 851 } 852 853 roar_err_set(ROAR_ERROR_NOENT); 854 return -1; 855 } 856 857 void print_protolist (enum output_format format) { 858 const size_t len = sizeof(g_proto)/sizeof(*g_proto); 859 struct roard_proto * p; 860 char subsys[7] = " "; 861 size_t i; 862 863 switch (format) { 864 case FORMAT_NATIVE: 865 printf(" Protocol Flag Subsys - Description\n"); 866 printf("------------------------------------------------------\n"); 867 printf(" roar WM LRX - RoarAudio native protocol\n"); 868 #ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE 869 printf(" simple WM LRX - PulseAudio simple protocol\n"); 870 #endif 871 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND 872 printf(" rsound W - RSound emulation\n"); 873 #endif 874 break; 875 case FORMAT_WIKI: 876 printf("||=Protocol =||=Flag =||=Subsys =||=Description =||\n"); 877 printf("||roar || ||WM LRX ||RoarAudio native protocol ||\n"); 878 #ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE 879 printf("||simple || ||WM LRX ||PulseAudio simple protocol ||\n"); 880 #endif 881 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND 882 printf("||rsound || ||W ||RSound emulation ||\n"); 883 #endif 884 break; 885 case FORMAT_CSV: 886 printf("Protocol,Flag,Subsys,Description\n"); 887 printf("roar,,WM LRX,RoarAudio native protocol\n"); 888 #ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE 889 printf("simple,,WM LRX,PulseAudio simple protocol\n"); 890 #endif 891 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND 892 printf("rsound,,W,RSound emulation\n"); 893 #endif 894 break; 895 default: 896 roar_err_set(ROAR_ERROR_NOTSUP); 897 return; 898 } 899 900 for (i = 0; i < len; i++) { 901 p = &(g_proto[i]); 902 if ( p->proto == -1 ) 903 continue; 904 905 strncpy(subsys, " ", 6); 906 907 if ( p->subsystems & ROAR_SUBSYS_WAVEFORM ) 908 subsys[0] = 'W'; 909 if ( p->subsystems & ROAR_SUBSYS_MIDI ) 910 subsys[1] = 'M'; 911 if ( p->subsystems & ROAR_SUBSYS_CB ) 912 subsys[2] = 'C'; 913 if ( p->subsystems & ROAR_SUBSYS_LIGHT ) 914 subsys[3] = 'L'; 915 if ( p->subsystems & ROAR_SUBSYS_RAW ) 916 subsys[4] = 'R'; 917 if ( p->subsystems & ROAR_SUBSYS_COMPLEX ) 918 subsys[5] = 'X'; 919 920 switch (format) { 921 case FORMAT_NATIVE: 922 printf(" %-13s %s - %s\n", roar_proto2str(p->proto), subsys, p->description); 923 break; 924 case FORMAT_WIKI: 925 printf("||%s || ||%s ||%s ||\n", roar_proto2str(p->proto), subsys, p->description); 926 break; 927 case FORMAT_CSV: 928 printf("%s,,%s,%s\n", roar_proto2str(p->proto), subsys, p->description); 929 break; 930 } 931 } 932 } 836 933 837 934 int client_stream_exec (int client, int stream) { -
roard/include/client.h
r5192 r5275 76 76 struct roard_proto { 77 77 int proto; 78 int subsystems; 79 const char * description; 78 80 int (*new_client)(int client, struct roar_vio_calls * vio, struct roard_listen * lsock); 79 81 int (*check_client)(int client, struct roar_vio_calls * vio); … … 114 116 115 117 // proto support 116 int clients_register_proto(struct roard_proto * proto); 118 int clients_register_proto (struct roard_proto * proto); 119 int clients_unregister_proto(int proto); 120 void print_protolist (enum output_format format); 117 121 118 122 // stream functions -
roard/include/plugins.h
r5266 r5275 29 29 #include <roaraudio.h> 30 30 31 #define ROARD_DL_APPNAME "roard <0/RoarAudio>" 32 #define ROARD_DL_ABIVERSION NULL 33 31 34 struct roard_plugins_sched { 32 35 int (*init)(void); … … 40 43 int plugins_update (void); 41 44 42 int plugins_load (const char * filename );45 int plugins_load (const char * filename, const char * args); 43 46 44 47 int plugins_reg_sched(struct roard_plugins_sched * sched); … … 62 65 ROARD_DL_REG__UNI_POST 63 66 67 // Register Scheduler callbacks: 64 68 #define ROARD_DL_REGFN_SCHED() ROAR_DL_PLUGIN_REG(ROAR_DL_FN_ROARDSCHED, __reg_sched) 65 69 … … 70 74 ROARD_DL_REG__UNI_POST 71 75 76 // Register Protocol callbacks: 72 77 #define ROARD_DL_REGFN_PROTO() ROAR_DL_PLUGIN_REG(ROAR_DL_FN_PROTO, __reg_proto) 78 79 // Check version: 80 #define ROARD_DL_CHECK_VERSIONS() ROAR_DL_PLUGIN_CHECK_VERSIONS(ROARD_DL_APPNAME, ROARD_DL_ABIVERSION) 73 81 74 82 #endif -
roard/plugins.c
r4708 r5275 31 31 struct roar_dl_lhandle * lhandle; 32 32 struct roard_plugins_sched * sched; 33 int protocols[MAX_PROTOS]; 33 34 } g_plugins[MAX_PLUGINS]; 34 35 static struct _roard_plugin * _pp = NULL; … … 53 54 } 54 55 56 static void inline plugins_delete(struct _roard_plugin * plugin) { 57 int i; 58 59 if ( plugin->sched != NULL ) 60 if ( plugin->sched->free != NULL ) 61 plugin->sched->free(); 62 63 for (i = 0; i < MAX_PROTOS; i++) { 64 if ( plugin->protocols[i] != -1 ) { 65 clients_unregister_proto(plugin->protocols[i]); 66 } 67 } 68 69 roar_dl_close(plugin->lhandle); 70 memset(plugin, 0, sizeof(struct _roard_plugin)); 71 plugin->lhandle = NULL; 72 } 73 55 74 int plugins_init (void) { 56 75 int i; … … 62 81 _pp->sched = NULL; 63 82 64 roar_dl_ra_init(g_plugins[i].lhandle, NULL); 83 if ( roar_dl_ra_init(g_plugins[i].lhandle, NULL, NULL) == -1 ) { 84 ROAR_WARN("plugins_init(void): Can not RA init lib at %p: %s", g_plugins[i].lhandle, roar_error2str(roar_error)); 85 plugins_delete(&(g_plugins[i])); 86 continue; 87 } 65 88 66 89 if ( g_plugins[i].sched != NULL ) … … 80 103 for (i = 0; i < MAX_PLUGINS; i++) { 81 104 if ( g_plugins[i].lhandle != NULL ) { 82 if ( g_plugins[i].sched != NULL ) 83 if ( g_plugins[i].sched->free != NULL ) 84 g_plugins[i].sched->free(); 85 86 roar_dl_close(g_plugins[i].lhandle); 105 plugins_delete(&(g_plugins[i])); 87 106 } 88 107 } … … 105 124 } 106 125 107 int plugins_load (const char * filename ) {126 int plugins_load (const char * filename, const char * args) { 108 127 struct _roard_plugin * next = _find_free(); 128 struct roar_dl_librarypara * para; 129 int i; 109 130 110 131 if ( next == NULL ) 111 132 return -1; 112 133 113 next->lhandle = roar_dl_open(filename, -1, 0 /* we delay this until plugins_init() */); 134 for (i = 0; i < MAX_PROTOS; i++) 135 next->protocols[i] = -1; 136 137 if ( (para = roar_dl_para_new(args, NULL, ROARD_DL_APPNAME, ROARD_DL_ABIVERSION)) == NULL ) { 138 ROAR_WARN("Can not load plugin (allocate para set): %s: %s", filename, roar_error2str(roar_error)); 139 return -1; 140 } 141 142 next->lhandle = roar_dl_open(filename, ROAR_DL_FLAG_DEFAUTS, 0 /* we delay this until plugins_init() */, para); 143 roar_dl_para_unref(para); 144 114 145 if ( next->lhandle == NULL ) { 115 146 ROAR_ERR("plugins_load(filename='%s'): can not load plugin: %s", filename, roar_dl_errstr(NULL)); … … 130 161 131 162 int plugins_reg_proto(struct roard_proto * proto) { 163 int i; 164 132 165 if ( _pp == NULL ) 133 166 return -1; 167 168 for (i = 0; i < MAX_PROTOS; i++) { 169 if ( _pp->protocols[i] == -1 ) { 170 _pp->protocols[i] = proto->proto; 171 break; 172 } 173 } 174 175 if ( i == MAX_PROTOS ) { 176 roar_err_set(ROAR_ERROR_NOMEM); 177 return -1; 178 } 134 179 135 180 return clients_register_proto(proto); -
roard/roard.c
r5257 r5275 260 260 printf( 261 261 " --plugin-load FILE - Load plugin FILE\n" 262 " --plugin-args ARGS - Arguments for the plugin\n" 263 " (must be given before the --plugin-load)\n" 262 264 ); 263 265 … … 417 419 // printf("\n Options:\n\n"); 418 420 printf("\n"); 419 }420 421 static void list_proto (void) {422 printf(" Protocol Flag Subsys - Description\n");423 printf("------------------------------------------------------\n");424 printf(" roar WM LRX - RoarAudio native protocol\n");425 #if !defined(ROAR_WITHOUT_DCOMP_EMUL_ESD) && defined(ROAR_HAVE_H_ESD)426 printf(" esd W - EsounD emulation\n");427 #endif428 #ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE429 printf(" simple WM LRX - PulseAudio simple protocol\n");430 #endif431 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND432 printf(" rsound W - RSound emulation\n");433 #endif434 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RPLAY435 printf(" rplay W - RPlay emulation\n");436 #endif437 #ifndef ROAR_WITHOUT_DCOMP_EMUL_GOPHER438 printf(" gopher - The Internet Gopher Protocol\n");439 #endif440 421 } 441 422 … … 1380 1361 int sysclocksync = 0; 1381 1362 // char * server = ROAR_DEFAULT_SOCK_GLOBAL; 1363 const char * plugin_args = NULL; 1382 1364 #ifdef ROAR_SUPPORT_LISTEN 1383 1365 int port = ROAR_DEFAULT_PORT; … … 1701 1683 } else if ( strcmp(k, "--plugin-load") == 0 ) { 1702 1684 _CKHAVEARGS(1); 1703 if ( plugins_load(argv[++i] ) == -1 ) {1685 if ( plugins_load(argv[++i], plugin_args) == -1 ) { 1704 1686 ROAR_ERR("Can not load plugin"); 1705 1687 } 1688 plugin_args = NULL; 1689 } else if ( strcmp(k, "--plugin-args") == 0 ) { 1690 _CKHAVEARGS(1); 1691 plugin_args = argv[++i]; 1706 1692 1707 1693 } else if ( strcmp(k, "--guest-acclev") == 0 ) { … … 2140 2126 2141 2127 } else if ( strcmp(k, "--list-proto") == 0 ) { 2142 list_proto();2128 print_protolist(print_format); 2143 2129 return 0; 2144 2130
Note: See TracChangeset
for help on using the changeset viewer.