From 13c6e78272e025503feb14dc30e9d4550144bfd8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 14 Aug 2008 03:19:16 +0000 Subject: Tolerate illegal voice numbers from client for set_port_value. git-svn-id: http://svn.drobilla.net/lad/ingen@1365 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/events/SetPortValueEvent.cpp | 18 ++++++++++++++---- src/libs/engine/events/SetPortValueEvent.hpp | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp index 4152bb7b..9ab6349d 100644 --- a/src/libs/engine/events/SetPortValueEvent.cpp +++ b/src/libs/engine/events/SetPortValueEvent.cpp @@ -71,6 +71,7 @@ SetPortValueEvent::SetPortValueEvent(Engine& engine, , _queued(queued) , _omni(false) , _voice_num(voice_num) + , _port_path(port_path) , _data_type(data_type) , _data_size(data_size) , _data(malloc(data_size)) @@ -128,12 +129,16 @@ SetPortValueEvent::execute(ProcessContext& context) Buffer* const buf = _port->buffer(0); AudioBuffer* const abuf = dynamic_cast(buf); if (abuf) { - if (_omni) + if (_omni) { for (uint32_t i=0; i < _port->poly(); ++i) ((AudioBuffer*)_port->buffer(i))->set_value(*(float*)_data, context.start(), _time); - else - ((AudioBuffer*)_port->buffer(_voice_num))->set_value(*(float*)_data, context.start(), _time); - + } else { + if (_voice_num < _port->poly()) + ((AudioBuffer*)_port->buffer(_voice_num))->set_value( + *(float*)_data, context.start(), _time); + else + _error = ILLEGAL_VOICE; + } return; } @@ -171,6 +176,11 @@ SetPortValueEvent::post_process() string msg = "Illegal port path \""; msg.append(_port_path).append("\""); _responder->respond_error(msg); + + } else if (_error == ILLEGAL_VOICE) { + std::ostringstream ss; + ss << "Illegal voice number " << _voice_num; + _responder->respond_error(ss.str()); } else if (_error == PORT_NOT_FOUND) { string msg = "Unable to find port "; diff --git a/src/libs/engine/events/SetPortValueEvent.hpp b/src/libs/engine/events/SetPortValueEvent.hpp index 5c952a61..a509af33 100644 --- a/src/libs/engine/events/SetPortValueEvent.hpp +++ b/src/libs/engine/events/SetPortValueEvent.hpp @@ -66,7 +66,7 @@ public: void post_process(); private: - enum ErrorType { NO_ERROR, PORT_NOT_FOUND, NO_SPACE, ILLEGAL_PATH }; + enum ErrorType { NO_ERROR, PORT_NOT_FOUND, NO_SPACE, ILLEGAL_PATH, ILLEGAL_VOICE }; bool _queued; bool _omni; -- cgit v1.2.1