diff options
Diffstat (limited to 'src/server/events')
-rw-r--r-- | src/server/events/Delta.cpp | 43 | ||||
-rw-r--r-- | src/server/events/DisconnectAll.cpp | 23 |
2 files changed, 32 insertions, 34 deletions
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index ecc1830a..5ea00c9f 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -217,8 +217,6 @@ Delta::pre_process(PreProcessContext& ctx) _types.reserve(_properties.size()); - NodeImpl* obj = dynamic_cast<NodeImpl*>(_object); - // Remove any properties removed in delta for (const auto& r : _remove) { const Raul::URI& key = r.first; @@ -277,10 +275,9 @@ Delta::pre_process(PreProcessContext& ctx) const Raul::URI& key = p.first; const Property& value = p.second; SpecialType op = SpecialType::NONE; - if (obj) { - Resource& resource = *obj; + if (is_graph_object) { if (value != uris.patch_wildcard) { - if (resource.add_property(key, value, value.context())) { + if (_object->add_property(key, value, value.context())) { _added.emplace(key, value); } } @@ -375,22 +372,22 @@ Delta::pre_process(PreProcessContext& ctx) } if (!_create_event && key == uris.ingen_polyphonic) { - GraphImpl* parent = dynamic_cast<GraphImpl*>(obj->parent()); + GraphImpl* parent = dynamic_cast<GraphImpl*>( + _engine.store()->get(uri_to_path(_subject).parent())); if (!parent) { _status = Status::BAD_OBJECT_TYPE; } else if (value.type() != uris.forge.Bool) { _status = Status::BAD_VALUE_TYPE; } else { - op = SpecialType::POLYPHONIC; - obj->set_property(key, value, value.context()); - BlockImpl* block = dynamic_cast<BlockImpl*>(obj); - if (block) { - block->set_polyphonic(value.get<int32_t>()); - } - if (value.get<int32_t>()) { - obj->prepare_poly(*_engine.buffer_factory(), parent->internal_poly()); - } else { - obj->prepare_poly(*_engine.buffer_factory(), 1); + op = SpecialType::POLYPHONIC; + _object->set_property(key, value, value.context()); + const uint32_t poly = ( + value.get<int32_t>() ? parent->internal_poly() : 1); + if (BlockImpl* block = dynamic_cast<BlockImpl*>(_object)) { + block->set_polyphonic(poly); + block->prepare_poly(*_engine.buffer_factory(), poly); + } else if (PortImpl* port = dynamic_cast<PortImpl*>(_object)) { + port->prepare_poly(*_engine.buffer_factory(), poly); } } } @@ -455,7 +452,6 @@ Delta::execute(RunContext& context) _engine.control_bindings()->remove(context, _removed_bindings); } - NodeImpl* const object = dynamic_cast<NodeImpl*>(_object); BlockImpl* const block = dynamic_cast<BlockImpl*>(_object); PortImpl* const port = dynamic_cast<PortImpl*>(_object); @@ -484,11 +480,14 @@ Delta::execute(RunContext& context) } break; case SpecialType::POLYPHONIC: { - GraphImpl* parent = reinterpret_cast<GraphImpl*>(object->parent()); - if (value.get<int32_t>()) { - object->apply_poly(context, parent->internal_poly_process()); - } else { - object->apply_poly(context, 1); + GraphImpl* parent = reinterpret_cast<GraphImpl*>( + block ? block->parent() : port->parent()); + const uint32_t poly = ( + value.get<int32_t>() ? parent->internal_poly_process() : 1); + if (block) { + block->apply_poly(context, poly); + } else if (port) { + port->apply_poly(context, poly); } } break; case SpecialType::POLYPHONY: diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp index 45fec243..4d5a0958 100644 --- a/src/server/events/DisconnectAll.cpp +++ b/src/server/events/DisconnectAll.cpp @@ -88,23 +88,22 @@ DisconnectAll::pre_process(PreProcessContext& ctx) _parent_path); } - NodeImpl* const object = dynamic_cast<NodeImpl*>( - _engine.store()->get(_path)); - if (!object) { + Node* const node = _engine.store()->get(_path); + if (!node) { return Event::pre_process_done(Status::NOT_FOUND, _path); } - if (object->parent_graph() != _parent - && object->parent()->parent_graph() != _parent) { - return Event::pre_process_done(Status::INVALID_PARENT, _parent_path); + BlockImpl* parent = nullptr; + if ((_block = dynamic_cast<BlockImpl*>(node))) { + parent = _block->parent(); + } else if ((_port = dynamic_cast<PortImpl*>(node))) { + parent = _port->parent(); + } else { + return Event::pre_process_done(Status::INTERNAL_ERROR, _path); } - // Only one of these will succeed - _block = dynamic_cast<BlockImpl*>(object); - _port = dynamic_cast<PortImpl*>(object); - - if (!_block && !_port) { - return Event::pre_process_done(Status::INTERNAL_ERROR, _path); + if (parent != _parent && parent->parent() != _parent) { + return Event::pre_process_done(Status::INVALID_PARENT, _parent_path); } } |