Changeset 5640:00dd1147ce70 in roaraudio for roard
- Timestamp:
- 09/10/12 16:18:22 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- roard
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/clients.c
r5608 r5640 33 33 struct roar_client_server * g_clients[ROAR_CLIENTS_MAX]; 34 34 35 static struct roar_dl_proto 36 __proto_common_esd = { 37 .proto = ROAR_PROTO_ESOUND, 38 .description = "EsounD emulation", 39 .flags = ROAR_DL_PROTO_FLAGS_NONE, 40 .handle = emul_esd_check_client 41 }, __proto_common_rplay = { 42 .proto = ROAR_PROTO_RPLAY, 43 .description = "RPlay emulation", 44 .flags = ROAR_DL_PROTO_FLAGS_NONE, 45 .handle = emul_rplay_check_client 46 }, __proto_common_gopher = { 47 .proto = ROAR_PROTO_GOPHER, 48 .description = "The Internet Gopher Protocol", 49 .flags = ROAR_DL_PROTO_FLAGS_NONE, 50 .handle = emul_gopher_check_client, 51 .flushed = emul_gopher_flushed_client 52 }; 53 35 54 static struct roard_proto_handle __protos[MAX_PROTOS] = { 36 55 {.proto = ROAR_PROTO_ROARAUDIO, .lhandle = NULL, .type = ROARD_PROTO_TYPE_BUILDIN, 37 56 .impl = {.buildin = 0}}, 38 57 #if !defined(ROAR_WITHOUT_DCOMP_EMUL_ESD) && defined(ROAR_HAVE_H_ESD) 39 {.proto = ROAR_PROTO_ESOUND, .lhandle = NULL, .type = ROARD_PROTO_TYPE_ ROARDPROTO,40 .impl = {. roardproto = {ROAR_PROTO_ESOUND, ROAR_SUBSYS_WAVEFORM, "EsounD emulation", NULL, NULL, NULL, emul_esd_check_client, NULL, NULL}}},58 {.proto = ROAR_PROTO_ESOUND, .lhandle = NULL, .type = ROARD_PROTO_TYPE_COMMON, 59 .impl = {.common = &__proto_common_esd}}, 41 60 #endif 42 61 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RPLAY 43 {.proto = ROAR_PROTO_RPLAY, .lhandle = NULL, .type = ROARD_PROTO_TYPE_ ROARDPROTO,44 .impl = {. roardproto = {ROAR_PROTO_RPLAY, ROAR_SUBSYS_WAVEFORM, "RPlay emulation", NULL, NULL, NULL, emul_rplay_check_client, NULL, NULL}}},62 {.proto = ROAR_PROTO_RPLAY, .lhandle = NULL, .type = ROARD_PROTO_TYPE_COMMON, 63 .impl = {.common = &__proto_common_rplay}}, 45 64 #endif 46 65 #ifndef ROAR_WITHOUT_DCOMP_EMUL_GOPHER 47 {.proto = ROAR_PROTO_GOPHER, .lhandle = NULL, .type = ROARD_PROTO_TYPE_ROARDPROTO, 48 .impl = {.roardproto = {ROAR_PROTO_GOPHER, ROAR_SUBSYS_WAVEFORM, "The Internet Gopher Protocol", NULL, NULL, NULL, emul_gopher_check_client, NULL, 49 emul_gopher_flushed_client}}}, 66 {.proto = ROAR_PROTO_GOPHER, .lhandle = NULL, .type = ROARD_PROTO_TYPE_COMMON, 67 .impl = {.common = &__proto_common_gopher}}, 50 68 #endif 51 69 {.proto = -1} … … 276 294 ROAR_WARN("net_get_new_client(lsock=%p): proto(%i) marked as buildin but isn't. BAD.", lsock, proto); 277 295 supported = 0; 278 break;279 case ROARD_PROTO_TYPE_ROARDPROTO:280 supported = 1;281 if ( protohandle->impl.roardproto.new_client != NULL ) {282 if ( protohandle->impl.roardproto.new_client(client, &vio, lsock) == -1 ) {283 supported = 0;284 }285 }286 296 break; 287 297 case ROARD_PROTO_TYPE_COMMON: … … 334 344 case ROARD_PROTO_TYPE_BUILDIN: 335 345 /* noop */ 336 break;337 case ROARD_PROTO_TYPE_ROARDPROTO:338 if ( proto->impl.roardproto.delete_client != NULL )339 proto->impl.roardproto.delete_client(id);340 346 break; 341 347 case ROARD_PROTO_TYPE_COMMON: … … 854 860 ROAR_WARN("clients_check(id=%i): proto(%i) marked as buildin but isn't. BAD.", id, proto->proto); 855 861 break; 856 case ROARD_PROTO_TYPE_ROARDPROTO:857 if ( proto->impl.roardproto.check_client != NULL )858 rv = proto->impl.roardproto.check_client(id, &vio);859 break;860 862 case ROARD_PROTO_TYPE_COMMON: 861 863 if ( proto->impl.common->handle != NULL ) { … … 907 909 case ROARD_PROTO_TYPE_BUILDIN: 908 910 /* noop */ 909 break;910 case ROARD_PROTO_TYPE_ROARDPROTO:911 if ( p->impl.roardproto.flush_client != NULL ) {912 if ( p->lhandle != NULL )913 roar_dl_context_restore(p->lhandle);914 rv = p->impl.roardproto.flush_client(id, &vio);915 if ( p->lhandle != NULL )916 roar_dl_context_store(p->lhandle);917 return rv;918 }919 911 break; 920 912 case ROARD_PROTO_TYPE_COMMON: … … 964 956 case ROARD_PROTO_TYPE_BUILDIN: 965 957 /* noop */ 966 break;967 case ROARD_PROTO_TYPE_ROARDPROTO:968 if ( p->impl.roardproto.flushed_client != NULL ) {969 if ( p->lhandle != NULL )970 roar_dl_context_restore(p->lhandle);971 rv = p->impl.roardproto.flushed_client(id, &vio);972 if ( p->lhandle != NULL )973 roar_dl_context_store(p->lhandle);974 return rv;975 }976 958 break; 977 959 case ROARD_PROTO_TYPE_COMMON: … … 1102 1084 } 1103 1085 1104 int clients_register_proto(struct roard_proto * proto, struct roar_dl_lhandle * lhandle) {1105 const size_t len = sizeof(__protos)/sizeof(*__protos);1106 size_t i;1107 1108 if ( proto == NULL )1109 return -1;1110 1111 for (i = 0; __protos[i].proto != -1; i++);1112 1113 // i is now at pos of current EOS entry.1114 1115 // test if we have space for one more entry:1116 if ( (i+1) >= len )1117 return -1;1118 1119 memcpy(&(__protos[i].impl.roardproto), proto, sizeof(__protos[i].impl.roardproto));1120 1121 __protos[i].impl.roardproto.lhandle = lhandle;1122 1123 __protos[i].proto = proto->proto;1124 __protos[i].type = ROARD_PROTO_TYPE_ROARDPROTO;1125 __protos[i].lhandle = lhandle;1126 1127 return 0;1128 }1129 1130 1086 int clients_register_proto_common(const struct roar_dl_proto * proto, struct roar_dl_lhandle * lhandle) { 1131 1087 const size_t len = sizeof(__protos)/sizeof(*__protos); … … 1236 1192 case ROARD_PROTO_TYPE_BUILDIN: 1237 1193 continue; 1238 break;1239 case ROARD_PROTO_TYPE_ROARDPROTO:1240 flags[1] = 'R';1241 1242 if ( p->impl.roardproto.subsystems & ROAR_SUBSYS_WAVEFORM )1243 subsys[0] = 'W';1244 if ( p->impl.roardproto.subsystems & ROAR_SUBSYS_MIDI )1245 subsys[1] = 'M';1246 if ( p->impl.roardproto.subsystems & ROAR_SUBSYS_CB )1247 subsys[2] = 'C';1248 if ( p->impl.roardproto.subsystems & ROAR_SUBSYS_LIGHT )1249 subsys[3] = 'L';1250 if ( p->impl.roardproto.subsystems & ROAR_SUBSYS_RAW )1251 subsys[4] = 'R';1252 if ( p->impl.roardproto.subsystems & ROAR_SUBSYS_COMPLEX )1253 subsys[5] = 'X';1254 1255 description = p->impl.roardproto.description;1256 1194 break; 1257 1195 case ROARD_PROTO_TYPE_COMMON: -
roard/include/client.h
r5607 r5640 89 89 enum roard_proto_type { 90 90 ROARD_PROTO_TYPE_BUILDIN = 0, 91 ROARD_PROTO_TYPE_ROARDPROTO = 1, 91 // ROARD_PROTO_TYPE_ROARDPROTO = 1, // old. Removed in 1.0beta6. 92 92 ROARD_PROTO_TYPE_COMMON = 2 93 93 }; … … 101 101 union { 102 102 int buildin; // dummy 103 struct roard_proto roardproto;104 // add common here when ready.105 103 const struct roar_dl_proto * common; 106 104 } impl; … … 143 141 const struct roard_proto_handle * clients_get_protohandle(const int proto); 144 142 int clients_register_proto_common(const struct roar_dl_proto * proto, struct roar_dl_lhandle * lhandle); 145 int clients_register_proto (struct roard_proto * proto, struct roar_dl_lhandle * lhandle);146 143 int clients_unregister_proto(int proto); 147 144 void print_protolist (enum output_format format); -
roard/include/emul_esd.h.OLD
r5381 r5640 48 48 49 49 int emul_esd_exec_command (int client, int cmd, struct roar_vio_calls * vio); 50 int emul_esd_check_client (int client, struct roar_vio_calls * vio );50 int emul_esd_check_client (int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); 51 51 52 52 int emul_esd_int_read_buf (int client, int * data, void * buf); -
roard/include/emul_gopher.h.OLD
r5381 r5640 29 29 #include <roaraudio.h> 30 30 31 int emul_gopher_check_client(int client, struct roar_vio_calls * vio );32 int emul_gopher_flushed_client(int client, struct roar_vio_calls * vio );31 int emul_gopher_check_client(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); 32 int emul_gopher_flushed_client(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); 33 33 34 34 #endif -
roard/include/emul_rplay.h.OLD
r5381 r5640 39 39 }; 40 40 41 int emul_rplay_check_client (int client, struct roar_vio_calls * vio );41 int emul_rplay_check_client (int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara); 42 42 43 43 int emul_rplay_exec_command (int client, struct roar_vio_calls * vio, char * command); -
roard/include/plugins.h
r5639 r5640 41 41 void print_pluginlist(enum output_format format); 42 42 43 int plugins_reg_proto(struct roard_proto * proto);44 45 #define ROARD_DL_REG__UNI_PRE(name) \46 static int __reg_ ## name(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib) { \47 size_t i; \48 \49 (void)para, (void)lib;50 51 #define ROARD_DL_REG__UNI_POST \52 \53 return 0; \54 }55 56 #define ROARD_DL_REG_PROTO(proto) \57 ROARD_DL_REG__UNI_PRE(proto) \58 for (i = 0; i < (sizeof((proto))/sizeof(*(proto))); i++) \59 plugins_reg_proto(&((proto)[i])); \60 ROARD_DL_REG__UNI_POST61 62 // Register Protocol callbacks:63 #define ROARD_DL_REGFN_PROTO() ROAR_DL_PLUGIN_REG(ROAR_DL_FN_PROTO, __reg_proto)64 65 43 // Check version: 66 44 #define ROARD_DL_CHECK_VERSIONS() ROAR_DL_PLUGIN_CHECK_VERSIONS(ROARD_DL_APPNAME, ROARD_DL_ABIVERSION) -
roard/plugins.c
r5639 r5640 30 30 static struct _roard_plugin { 31 31 struct roar_dl_lhandle * lhandle; 32 int protocols[MAX_PROTOS];33 32 } g_plugins[MAX_PLUGINS]; 34 33 static struct _roard_plugin * _pp = NULL; … … 76 75 77 76 static inline void plugins_delete(struct _roard_plugin * plugin) { 78 int i;79 80 77 ROAR_DBG("plugins_delete(plugin=%p) = ?", plugin); 81 78 82 79 roar_dl_appsched_trigger(plugin->lhandle, ROAR_DL_APPSCHED_FREE); 83 84 for (i = 0; i < MAX_PROTOS; i++) {85 if ( plugin->protocols[i] != -1 ) {86 clients_unregister_proto(plugin->protocols[i]);87 }88 }89 80 90 81 roar_dl_close(plugin->lhandle); … … 179 170 struct _roard_plugin * next = _find_free(); 180 171 struct roar_dl_librarypara * para; 181 int i;182 172 183 173 ROAR_DBG("plugins_load(filename=\"%s\", args=\"%s\") = ?", filename, args); … … 185 175 if ( next == NULL ) 186 176 return -1; 187 188 for (i = 0; i < MAX_PLUGINS; i++)189 next->protocols[i] = -1;190 177 191 178 if ( (para = roar_dl_para_new(args, NULL, ROARD_DL_APPNAME, ROARD_DL_ABIVERSION)) == NULL ) { … … 244 231 } 245 232 246 int plugins_reg_proto(struct roard_proto * proto) {247 int i;248 249 if ( _pp == NULL )250 return -1;251 252 for (i = 0; i < MAX_PROTOS; i++) {253 if ( _pp->protocols[i] == -1 ) {254 _pp->protocols[i] = proto->proto;255 break;256 }257 }258 259 if ( i == MAX_PROTOS ) {260 roar_err_set(ROAR_ERROR_NOMEM);261 return -1;262 }263 264 return clients_register_proto(proto, _pp->lhandle);265 }266 267 233 static int plugin_callback(enum roar_dl_fnreg_action action, int fn, int subtype, const void * object, size_t objectlen, int version, int options, void * userdata, struct roar_dl_lhandle * lhandle) { 268 234
Note: See TracChangeset
for help on using the changeset viewer.