diff options
author | David Robillard <d@drobilla.net> | 2012-03-12 02:28:21 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-03-12 02:28:21 +0000 |
commit | e9d9569271ee962c09ab66c6babed1ca5655a6c6 (patch) | |
tree | f77142b08c2bf2488eb382e993da1477c0b94307 /src/server/events/SetPortValue.cpp | |
parent | 7835b3d8c9b5b4a6f4959f56083d62826e6f7b8e (diff) | |
download | ingen-e9d9569271ee962c09ab66c6babed1ca5655a6c6.tar.gz ingen-e9d9569271ee962c09ab66c6babed1ca5655a6c6.tar.bz2 ingen-e9d9569271ee962c09ab66c6babed1ca5655a6c6.zip |
Unify event response mechanism and make it more appropriate for wire transmission.
The downside being more cryptic error messages until the client side error reporting stuff gets more fancy, but the important part is that belongs client side.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4053 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/events/SetPortValue.cpp')
-rw-r--r-- | src/server/events/SetPortValue.cpp | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index f96649b9..bc4cd9bf 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -84,7 +84,7 @@ SetPortValue::pre_process() if (_port == NULL) _port = _engine.engine_store()->find_port(_port_path); if (_port == NULL) - _error = PORT_NOT_FOUND; + _status = PORT_NOT_FOUND; } // Port is a message context port, set its value and @@ -123,20 +123,20 @@ void SetPortValue::apply(Context& context) { uint32_t start = context.start(); - if (_error == NO_ERROR && !_port) + if (_status == SUCCESS && !_port) _port = _engine.engine_store()->find_port(_port_path); if (!_port) { - if (_error == NO_ERROR) - _error = PORT_NOT_FOUND; + if (_status == SUCCESS) + _status = PORT_NOT_FOUND; /*} else if (_port->buffer(0)->capacity() < _data_size) { - _error = NO_SPACE;*/ + _status = NO_SPACE;*/ } else { Buffer* const buf = _port->buffer(0).get(); AudioBuffer* const abuf = dynamic_cast<AudioBuffer*>(buf); if (abuf) { if (_value.type() != Atom::FLOAT) { - _error = TYPE_MISMATCH; + _status = TYPE_MISMATCH; return; } @@ -192,31 +192,12 @@ SetPortValue::apply(Context& context) void SetPortValue::post_process() { - string msg; - std::ostringstream ss; - switch (_error) { - case NO_ERROR: - assert(_port != NULL); - respond_ok(); - _engine.broadcaster()->set_property(_port_path, - _engine.world()->uris()->ingen_value, _value); - break; - case TYPE_MISMATCH: - ss << "Illegal value type " << _value.type() - << " for port " << _port_path << endl; - respond_error(ss.str()); - break; - case PORT_NOT_FOUND: - msg = "Unable to find port "; - msg.append(_port_path.str()).append(" to set value"); - respond_error(msg); - break; - case NO_SPACE: - ss << "Attempt to write " << _value.data_size() << " bytes to " - << _port_path.str() << ", with capacity " - << _port->buffer_size() << endl; - respond_error(ss.str()); - break; + respond(_status); + if (!_status) { + _engine.broadcaster()->set_property( + _port_path, + _engine.world()->uris()->ingen_value, + _value); } } |