From c9683eb916ff52ab6907773360c655d776b24f23 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 19 Apr 2011 20:41:24 +0000 Subject: Make maximum UDP packet size a runtime parameter (--packet-size, -k). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3170 a436a847-0d15-0410-975c-d299462d15a1 --- src/shared/Configuration.cpp | 1 + src/shared/OSCSender.cpp | 13 ++++++------- src/shared/OSCSender.hpp | 7 +++++-- 3 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src/shared') diff --git a/src/shared/Configuration.cpp b/src/shared/Configuration.cpp index 650a1d8b..64185fb3 100644 --- a/src/shared/Configuration.cpp +++ b/src/shared/Configuration.cpp @@ -51,6 +51,7 @@ Configuration::Configuration() .add("uuid", 'u', "JACK session UUID", Atom::STRING, "") #endif .add("load", 'l', "Load patch", Atom::STRING, Atom()) + .add("packet-size", 'k', "Maximum UDP packet size", Atom::INT, 4096) .add("parallelism", 'p', "Number of concurrent process threads", Atom::INT, 1) .add("path", 'L', "Target path for loaded patch", Atom::STRING, Atom()) .add("queue-size", 'q', "Event queue size", Atom::INT, 1024) diff --git a/src/shared/OSCSender.cpp b/src/shared/OSCSender.cpp index 58b9ddae..6c07551b 100644 --- a/src/shared/OSCSender.cpp +++ b/src/shared/OSCSender.cpp @@ -15,10 +15,12 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include #include #include + #include "raul/log.hpp" + #include "OSCSender.hpp" #include "ingen-config.h" @@ -28,9 +30,10 @@ using namespace Raul; namespace Ingen { namespace Shared { -OSCSender::OSCSender() +OSCSender::OSCSender(size_t max_packet_size) : _bundle(NULL) , _address(NULL) + , _max_packet_size(max_packet_size) , _enabled(true) { } @@ -82,17 +85,13 @@ OSCSender::send(const char *path, const char *types, ...) void OSCSender::send_message(const char* path, lo_message msg) { - // FIXME: size? liblo doesn't export this. - // Don't want to exceed max UDP packet size (good default value?) - static const size_t MAX_BUNDLE_SIZE = 1024; - if (!_enabled) { lo_message_free(msg); return; } if (_bundle) { - if (lo_bundle_length(_bundle) + lo_message_length(msg, path) > MAX_BUNDLE_SIZE) { + if (lo_bundle_length(_bundle) + lo_message_length(msg, path) > _max_packet_size) { warn << "Maximum bundle size reached, bundle split" << endl; lo_send_bundle(_address, _bundle); lo_bundle_free_messages(_bundle); diff --git a/src/shared/OSCSender.hpp b/src/shared/OSCSender.hpp index 1085f2ae..34c5565a 100644 --- a/src/shared/OSCSender.hpp +++ b/src/shared/OSCSender.hpp @@ -18,7 +18,9 @@ #ifndef INGEN_SHARED_OSCSENDER_HPP #define INGEN_SHARED_OSCSENDER_HPP -#include +#include +#include + #include namespace Ingen { @@ -26,7 +28,7 @@ namespace Shared { class OSCSender { public: - OSCSender(); + OSCSender(size_t max_packet_size); virtual ~OSCSender() {} lo_address address() const { return _address; } @@ -40,6 +42,7 @@ protected: lo_bundle _bundle; lo_address _address; + size_t _max_packet_size; bool _enabled; }; -- cgit v1.2.1