Changeset 1248
- Timestamp:
- 06/09/08 10:21:44 (3 months ago)
- Files:
-
- configure.ac (modified) (1 diff)
- ingen/configure.ac (modified) (1 diff)
- ingen/src/libs/client/OSCClientReceiver.cpp (modified) (1 diff)
- ingen/src/libs/engine/ClientBroadcaster.cpp (modified) (1 diff)
- ingen/src/libs/engine/ClientBroadcaster.hpp (modified) (1 diff)
- ingen/src/libs/engine/events/DestroyEvent.cpp (modified) (1 diff)
- ingen/src/libs/engine/ObjectSender.cpp (modified) (2 diffs)
- ingen/src/libs/engine/OSCClientSender.cpp (modified) (21 diffs)
- ingen/src/libs/engine/OSCClientSender.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
configure.ac
r1247 r1248 289 289 290 290 # OSC support (mandatory for now due to laziness) 291 PKG_CHECK_MODULES(LIBLO, liblo )291 PKG_CHECK_MODULES(LIBLO, liblo >= 0.24) 292 292 293 293 # LV2 support ingen/configure.ac
r1245 r1248 141 141 142 142 # OSC support (mandatory for now due to laziness) 143 PKG_CHECK_MODULES(LIBLO, liblo )143 PKG_CHECK_MODULES(LIBLO, liblo >= 0.24) 144 144 145 145 # LV2 support ingen/src/libs/client/OSCClientReceiver.cpp
r1218 r1248 32 32 33 33 OSCClientReceiver::OSCClientReceiver(int listen_port) 34 : ClientInterface("localhost"), 35 _listen_port(listen_port), 36 _st(NULL)34 : ClientInterface("localhost") 35 , _listen_port(listen_port) 36 , _st(NULL) 37 37 { 38 38 start(false); // true = dump, false = shutup ingen/src/libs/engine/ClientBroadcaster.cpp
r898 r1248 92 92 } 93 93 94 95 void 96 ClientBroadcaster::bundle_begin() 97 { 98 for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) 99 (*i).second->bundle_begin(); 100 } 101 102 103 void 104 ClientBroadcaster::bundle_end() 105 { 106 for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) 107 (*i).second->bundle_end(); 108 } 109 94 110 95 111 void ingen/src/libs/engine/ClientBroadcaster.hpp
r876 r1248 61 61 //void send_client_registration(const string& url, int client_id); 62 62 63 void bundle_begin(); 64 void bundle_end(); 65 63 66 // Error that isn't the direct result of a request 64 67 void send_error(const string& msg); ingen/src/libs/engine/events/DestroyEvent.cpp
r1225 r1248 183 183 _node->deactivate(); 184 184 _responder->respond_ok(); 185 _engine.broadcaster()->bundle_begin(); 185 186 if (_disconnect_node_event) 186 187 _disconnect_node_event->post_process(); 187 188 _engine.broadcaster()->send_destroyed(_path); 189 _engine.broadcaster()->bundle_end(); 188 190 _engine.maid()->push(_patch_node_listnode); 189 191 } else if (_patch_port_listnode) { 190 192 assert(_port); 191 193 _responder->respond_ok(); 194 _engine.broadcaster()->bundle_begin(); 192 195 if (_disconnect_port_event) 193 196 _disconnect_port_event->post_process(); 194 197 _engine.broadcaster()->send_destroyed(_path); 198 _engine.broadcaster()->bundle_end(); 195 199 _engine.maid()->push(_patch_port_listnode); 196 200 } else { ingen/src/libs/engine/ObjectSender.cpp
r1113 r1248 34 34 ObjectSender::send_patch(ClientInterface* client, const PatchImpl* patch, bool recursive) 35 35 { 36 client->bundle_begin(); 37 36 38 client->new_patch(patch->path(), patch->internal_polyphony()); 37 39 client->polyphonic(patch->path(), patch->polyphonic()); 40 41 // Send variable 42 const GraphObjectImpl::Variables& data = patch->variables(); 43 for (GraphObjectImpl::Variables::const_iterator j = data.begin(); j != data.end(); ++j) 44 client->variable_change(patch->path(), (*j).first, (*j).second); 45 46 if (patch->enabled()) 47 client->patch_enabled(patch->path()); 48 49 client->bundle_end(); 38 50 39 51 if (recursive) { … … 61 73 62 74 } 63 64 // Send variable65 const GraphObjectImpl::Variables& data = patch->variables();66 for (GraphObjectImpl::Variables::const_iterator j = data.begin(); j != data.end(); ++j)67 client->variable_change(patch->path(), (*j).first, (*j).second);68 69 if (patch->enabled())70 client->patch_enabled(patch->path());71 75 } 72 76 ingen/src/libs/engine/OSCClientSender.cpp
r1113 r1248 39 39 OSCClientSender::bundle_begin() 40 40 { 41 // FIXME: Don't split bundles as for 'transfers'41 assert(!_transfer); 42 42 _transfer = lo_bundle_new(LO_TT_IMMEDIATE); 43 _send_state = SendingBundle; 44 43 45 } 44 46 … … 46 48 OSCClientSender::bundle_end() 47 49 { 48 // FIXME: Don't split bundles as for 'transfers'49 50 transfer_end(); 50 51 } … … 54 55 OSCClientSender::transfer_begin() 55 56 { 57 //cerr << "TRANSFER {" << endl; 58 assert(!_transfer); 56 59 _transfer = lo_bundle_new(LO_TT_IMMEDIATE); 60 _send_state = SendingTransfer; 57 61 } 58 62 … … 61 65 OSCClientSender::transfer_end() 62 66 { 67 //cerr << "} TRANSFER" << endl; 63 68 assert(_transfer); 64 69 lo_send_bundle(_address, _transfer); 65 70 lo_bundle_free(_transfer); 66 71 _transfer = NULL; 67 } 72 _send_state = Immediate; 73 } 74 75 76 int 77 OSCClientSender::send(const char *path, const char *types, ...) 78 { 79 if (!_enabled) 80 return 0; 81 82 va_list args; 83 va_start(args, types); 84 85 lo_message msg = lo_message_new(); 86 int ret = lo_message_add_varargs(msg, types, args); 87 88 if (!ret) 89 send_message(path, msg); 90 91 va_end(args); 92 93 return ret; 94 } 95 96 97 void 98 OSCClientSender::send_message(const char* path, lo_message msg) 99 { 100 // FIXME: size? liblo doesn't export this. 101 // Don't want to exceed max UDP packet size (1500 bytes?}) 102 static const size_t MAX_BUNDLE_SIZE = 1500 - 32*5; 103 104 if (!_enabled) 105 return; 106 107 if (_transfer) { 108 if (lo_bundle_length(_transfer) + lo_message_length(msg, path) > MAX_BUNDLE_SIZE) { 109 if (_send_state == SendingBundle) 110 cerr << "WARNING: Maximum bundle size reached, bundle split" << endl; 111 lo_send_bundle(_address, _transfer); 112 _transfer = lo_bundle_new(LO_TT_IMMEDIATE); 113 } 114 lo_bundle_add_message(_transfer, path, msg); 115 116 } else { 117 lo_send_message(_address, path, msg); 118 } 119 } 120 68 121 69 122 … … 150 203 OSCClientSender::error(const std::string& msg) 151 204 { 152 if (!_enabled) 153 return; 154 155 lo_send(_address, "/ingen/error", "s", msg.c_str()); 205 send("/ingen/error", "s", msg.c_str(), LO_ARGS_END); 156 206 } 157 207 … … 174 224 OSCClientSender::num_plugins(uint32_t num) 175 225 { 176 if (!_enabled) 177 return; 178 179 lo_message m = lo_message_new(); 180 lo_message_add_int32(m, num); 181 lo_send_message(_address, "/ingen/num_plugins", m); 226 send("/ingen/num_plugins", "i", num, LO_ARGS_END); 182 227 } 183 228 … … 256 301 uint32_t num_ports) 257 302 { 258 if (!_enabled)259 return;260 261 303 if (is_polyphonic) 262 lo_send(_address,"/ingen/new_node", "ssTi", plugin_uri.c_str(),263 node_path.c_str(), num_ports );304 send("/ingen/new_node", "ssTi", plugin_uri.c_str(), 305 node_path.c_str(), num_ports, LO_ARGS_END); 264 306 else 265 lo_send(_address,"/ingen/new_node", "ssFi", plugin_uri.c_str(),266 node_path.c_str(), num_ports );307 send("/ingen/new_node", "ssFi", plugin_uri.c_str(), 308 node_path.c_str(), num_ports, LO_ARGS_END); 267 309 } 268 310 … … 290 332 bool is_output) 291 333 { 292 if (!_enabled) 293 return; 294 295 lo_send(_address, "/ingen/new_port", "sisi", path.c_str(), index, data_type.c_str(), is_output); 334 send("/ingen/new_port", "sisi", path.c_str(), index, data_type.c_str(), is_output, LO_ARGS_END); 296 335 } 297 336 … … 328 367 OSCClientSender::object_destroyed(const std::string& path) 329 368 { 330 if (!_enabled)331 return;332 333 369 assert(path != "/"); 334 370 335 lo_send(_address, "/ingen/destroyed", "s", path.c_str());371 send("/ingen/destroyed", "s", path.c_str(), LO_ARGS_END); 336 372 } 337 373 … … 344 380 OSCClientSender::patch_cleared(const std::string& patch_path) 345 381 { 346 if (!_enabled) 347 return; 348 349 lo_send(_address, "/ingen/patch_cleared", "s", patch_path.c_str()); 382 send("/ingen/patch_cleared", "s", patch_path.c_str(), LO_ARGS_END); 350 383 } 351 384 … … 358 391 OSCClientSender::patch_enabled(const std::string& patch_path) 359 392 { 360 if (!_enabled) 361 return; 362 363 lo_send(_address, "/ingen/patch_enabled", "s", patch_path.c_str()); 393 send("/ingen/patch_enabled", "s", patch_path.c_str(), LO_ARGS_END); 364 394 } 365 395 … … 372 402 OSCClientSender::patch_disabled(const std::string& patch_path) 373 403 { 374 if (!_enabled) 375 return; 376 377 lo_send(_address, "/ingen/patch_disabled", "s", patch_path.c_str()); 404 send("/ingen/patch_disabled", "s", patch_path.c_str(), LO_ARGS_END); 378 405 } 379 406 … … 402 429 OSCClientSender::connection(const std::string& src_port_path, const std::string& dst_port_path) 403 430 { 404 if (!_enabled) 405 return; 406 407 lo_send(_address, "/ingen/new_connection", "ss", src_port_path.c_str(), dst_port_path.c_str()); 431 send("/ingen/new_connection", "ss", src_port_path.c_str(), dst_port_path.c_str(), LO_ARGS_END); 408 432 } 409 433 … … 417 441 OSCClientSender::disconnection(const std::string& src_port_path, const std::string& dst_port_path) 418 442 { 419 if (!_enabled) 420 return; 421 422 lo_send(_address, "/ingen/disconnection", "ss", src_port_path.c_str(), dst_port_path.c_str()); 443 send("/ingen/disconnection", "ss", src_port_path.c_str(), dst_port_path.c_str(), LO_ARGS_END); 423 444 } 424 445 … … 433 454 OSCClientSender::variable_change(const std::string& path, const std::string& key, const Atom& value) 434 455 { 435 if (!_enabled)436 return;437 438 456 lo_message m = lo_message_new(); 439 457 lo_message_add_string(m, path.c_str()); 440 458 lo_message_add_string(m, key.c_str()); 441 459 Raul::AtomLiblo::lo_message_add_atom(m, value); 442 lo_send_message(_address,"/ingen/variable_change", m);460 send_message("/ingen/variable_change", m); 443 461 } 444 462 … … 452 470 OSCClientSender::control_change(const std::string& port_path, float value) 453 471 { 454 if (!_enabled) 455 return; 456 457 lo_send(_address, "/ingen/control_change", "sf", port_path.c_str(), value); 472 send("/ingen/control_change", "sf", port_path.c_str(), value, LO_ARGS_END); 458 473 } 459 474 … … 486 501 const std::string& name) 487 502 { 488 if (!_enabled)489 return;490 491 503 // FIXME: size? liblo doesn't export this. 492 504 // Don't want to exceed max UDP packet size (1500 bytes) … … 522 534 OSCClientSender::new_patch(const std::string& path, uint32_t poly) 523 535 { 524 if (!_enabled) 525 return; 526 527 lo_send(_address, "/ingen/new_patch", "si", path.c_str(), poly); 536 send("/ingen/new_patch", "si", path.c_str(), poly, LO_ARGS_END); 528 537 529 538 /* … … 548 557 OSCClientSender::object_renamed(const std::string& old_path, const std::string& new_path) 549 558 { 550 if (!_enabled) 551 return; 552 553 lo_send(_address, "/ingen/object_renamed", "ss", old_path.c_str(), new_path.c_str()); 559 send("/ingen/object_renamed", "ss", old_path.c_str(), new_path.c_str(), LO_ARGS_END); 554 560 } 555 561 … … 560 566 OSCClientSender::program_add(const std::string& node_path, uint32_t bank, uint32_t program, const std::string& name) 561 567 { 562 if (!_enabled) 563 return; 564 565 lo_send(_address, "/ingen/program_add", "siis", 568 send("/ingen/program_add", "siis", 566 569 node_path.c_str(), bank, program, name.c_str()); 567 570 } … … 571 574 OSCClientSender::program_remove(const std::string& node_path, uint32_t bank, uint32_t program) 572 575 { 573 if (!_enabled) 574 return; 575 576 lo_send(_address, "/ingen/program_remove", "sii", 576 send("/ingen/program_remove", "sii", 577 577 node_path.c_str(), bank, program); 578 578 } ingen/src/libs/engine/OSCClientSender.hpp
r1191 r1248 135 135 136 136 private: 137 int send(const char *path, const char *types, ...); 138 void send_message(const char* path, lo_message m); 139 140 enum SendState { Immediate, SendingBundle, SendingTransfer }; 141 142 string _url; 137 143 lo_address _address; 138 139 lo_bundle _transfer; 140 141 bool _enabled; 144 SendState _send_state; 145 lo_bundle _transfer; 146 bool _enabled; 142 147 }; 143 148
