summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-08-14 03:19:16 +0000
committerDavid Robillard <d@drobilla.net>2008-08-14 03:19:16 +0000
commit13c6e78272e025503feb14dc30e9d4550144bfd8 (patch)
treeccf0fecbf88461f9a34e4a0da17dad61f7586224
parent239583b0ef7e37dca95a3bf9f3c16648e6aa140d (diff)
downloadingen-13c6e78272e025503feb14dc30e9d4550144bfd8.tar.gz
ingen-13c6e78272e025503feb14dc30e9d4550144bfd8.tar.bz2
ingen-13c6e78272e025503feb14dc30e9d4550144bfd8.zip
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
-rw-r--r--src/libs/engine/events/SetPortValueEvent.cpp18
-rw-r--r--src/libs/engine/events/SetPortValueEvent.hpp2
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<AudioBuffer*>(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;