summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/events
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/engine/events')
-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;