diff options
author | David Robillard <d@drobilla.net> | 2013-01-11 04:47:21 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-01-11 04:47:21 +0000 |
commit | 10e9a3a800a35916872abf9e354be4c554338e4e (patch) | |
tree | d6be3ce7993f5d8efd525629fd321b32a6341633 /src/server | |
parent | 684eaf6b58e41f6758b160b882a6313faf0cff18 (diff) | |
download | ingen-10e9a3a800a35916872abf9e354be4c554338e4e.tar.gz ingen-10e9a3a800a35916872abf9e354be4c554338e4e.tar.bz2 ingen-10e9a3a800a35916872abf9e354be4c554338e4e.zip |
Use type safe enumerations.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4918 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server')
35 files changed, 260 insertions, 246 deletions
diff --git a/src/server/ArcImpl.cpp b/src/server/ArcImpl.cpp index debd2c1e..eea8ddcb 100644 --- a/src/server/ArcImpl.cpp +++ b/src/server/ArcImpl.cpp @@ -78,28 +78,28 @@ ArcImpl::can_connect(const OutputPort* src, const InputPort* dst) const Ingen::URIs& uris = src->bufs().uris(); return ( // (Audio | Control | CV) => (Audio | Control | CV) - ( (src->is_a(PortType::CONTROL) || - src->is_a(PortType::AUDIO) || - src->is_a(PortType::CV)) - && (dst->is_a(PortType::CONTROL) - || dst->is_a(PortType::AUDIO) - || dst->is_a(PortType::CV))) + ( (src->is_a(PortType::ID::CONTROL) || + src->is_a(PortType::ID::AUDIO) || + src->is_a(PortType::ID::CV)) + && (dst->is_a(PortType::ID::CONTROL) + || dst->is_a(PortType::ID::AUDIO) + || dst->is_a(PortType::ID::CV))) // Equal types || (src->type() == dst->type() && src->buffer_type() == dst->buffer_type()) // Control => atom:Float Value - || (src->is_a(PortType::CONTROL) && dst->supports(uris.atom_Float)) + || (src->is_a(PortType::ID::CONTROL) && dst->supports(uris.atom_Float)) // Audio => atom:Sound Value - || (src->is_a(PortType::AUDIO) && dst->supports(uris.atom_Sound)) + || (src->is_a(PortType::ID::AUDIO) && dst->supports(uris.atom_Sound)) // atom:Float Value => Control - || (src->supports(uris.atom_Float) && dst->is_a(PortType::CONTROL)) + || (src->supports(uris.atom_Float) && dst->is_a(PortType::ID::CONTROL)) // atom:Sound Value => Audio - || (src->supports(uris.atom_Sound) && dst->is_a(PortType::AUDIO))); + || (src->supports(uris.atom_Sound) && dst->is_a(PortType::ID::AUDIO))); } } // namespace Server diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp index 101c97e8..9f5b93d8 100644 --- a/src/server/BlockFactory.cpp +++ b/src/server/BlockFactory.cpp @@ -122,8 +122,8 @@ BlockFactory::load_lv2_plugins() // Build an array of port type nodes for checking compatibility typedef std::vector< SharedPtr<LilvNode> > Types; Types types; - for (unsigned t = PortType::AUDIO; t <= PortType::ATOM; ++t) { - const Raul::URI& uri(PortType((PortType::Symbol)t).uri()); + for (unsigned t = PortType::ID::AUDIO; t <= PortType::ID::ATOM; ++t) { + const Raul::URI& uri(PortType((PortType::ID)t).uri()); types.push_back(SharedPtr<LilvNode>( lilv_new_uri(_world->lilv_world(), uri.c_str()), lilv_node_free)); diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp index 6c09e9b7..072b4049 100644 --- a/src/server/BlockImpl.cpp +++ b/src/server/BlockImpl.cpp @@ -41,7 +41,7 @@ BlockImpl::BlockImpl(PluginImpl* plugin, : NodeImpl(plugin->uris(), parent, symbol) , _plugin(plugin) , _ports(NULL) - , _context(Context::AUDIO) + , _context(Context::ID::AUDIO) , _polyphony((polyphonic && parent) ? parent->internal_poly() : 1) , _polyphonic(polyphonic) , _activated(false) diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp index a94278b5..15d5a46e 100644 --- a/src/server/BlockImpl.hpp +++ b/src/server/BlockImpl.hpp @@ -66,7 +66,7 @@ public: virtual ~BlockImpl(); - virtual GraphType graph_type() const { return BLOCK; } + virtual GraphType graph_type() const { return GraphType::BLOCK; } /** Activate this Block. * diff --git a/src/server/Broadcaster.hpp b/src/server/Broadcaster.hpp index 157b07ea..78419991 100644 --- a/src/server/Broadcaster.hpp +++ b/src/server/Broadcaster.hpp @@ -83,7 +83,7 @@ public: void put(const Raul::URI& uri, const Resource::Properties& properties, - Resource::Graph ctx=Resource::DEFAULT) { + Resource::Graph ctx=Resource::Graph::DEFAULT) { BROADCAST(put, uri, properties); } diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp index 38a27fa8..270d95aa 100644 --- a/src/server/Buffer.cpp +++ b/src/server/Buffer.cpp @@ -123,10 +123,10 @@ Buffer::resize(uint32_t capacity) void* Buffer::port_data(PortType port_type) { - switch (port_type.symbol()) { - case PortType::CONTROL: - case PortType::CV: - case PortType::AUDIO: + switch (port_type.id()) { + case PortType::ID::CONTROL: + case PortType::ID::CV: + case PortType::ID::AUDIO: if (_atom->type == _factory.uris().atom_Float) { return (float*)LV2_ATOM_BODY(_atom); } else if (_atom->type == _factory.uris().atom_Sound) { diff --git a/src/server/Context.hpp b/src/server/Context.hpp index 5343b817..028ee126 100644 --- a/src/server/Context.hpp +++ b/src/server/Context.hpp @@ -44,7 +44,7 @@ class PortImpl; class Context { public: - enum ID { + enum class ID { AUDIO, MESSAGE }; diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index e8f595fa..25d49265 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -72,9 +72,9 @@ ControlBindings::binding_key(const Raul::Atom& binding) const const LV2_Atom_Object_Body* obj = (const LV2_Atom_Object_Body*) binding.get_body(); if (obj->otype == uris.midi_Bender) { - key = Key(MIDI_BENDER); + key = Key(Type::MIDI_BENDER); } else if (obj->otype == uris.midi_ChannelPressure) { - key = Key(MIDI_CHANNEL_PRESSURE); + key = Key(Type::MIDI_CHANNEL_PRESSURE); } else if (obj->otype == uris.midi_Controller) { lv2_atom_object_body_get( binding.size(), obj, (LV2_URID)uris.midi_controllerNumber, &num, NULL); @@ -83,7 +83,7 @@ ControlBindings::binding_key(const Raul::Atom& binding) const } else if (num->type != uris.atom_Int) { _engine.log().error("Controller number not an integer\n"); } else { - key = Key(MIDI_CC, ((LV2_Atom_Int*)num)->body); + key = Key(Type::MIDI_CC, ((LV2_Atom_Int*)num)->body); } } else if (obj->otype == uris.midi_NoteOn) { lv2_atom_object_body_get( @@ -93,7 +93,7 @@ ControlBindings::binding_key(const Raul::Atom& binding) const } else if (num->type != uris.atom_Int) { _engine.log().error("Note number not an integer\n"); } else { - key = Key(MIDI_NOTE, ((LV2_Atom_Int*)num)->body); + key = Key(Type::MIDI_NOTE, ((LV2_Atom_Int*)num)->body); } } } else if (binding.type()) { @@ -108,16 +108,16 @@ ControlBindings::midi_event_key(uint16_t size, const uint8_t* buf, uint16_t& val switch (lv2_midi_message_type(buf)) { case LV2_MIDI_MSG_CONTROLLER: value = static_cast<const int8_t>(buf[2]); - return Key(MIDI_CC, static_cast<const int8_t>(buf[1])); + return Key(Type::MIDI_CC, static_cast<const int8_t>(buf[1])); case LV2_MIDI_MSG_BENDER: value = (static_cast<int8_t>(buf[2]) << 7) + static_cast<int8_t>(buf[1]); - return Key(MIDI_BENDER); + return Key(Type::MIDI_BENDER); case LV2_MIDI_MSG_CHANNEL_PRESSURE: value = static_cast<const int8_t>(buf[1]); - return Key(MIDI_CHANNEL_PRESSURE); + return Key(Type::MIDI_CHANNEL_PRESSURE); case LV2_MIDI_MSG_NOTE_ON: value = 1.0f; - return Key(MIDI_NOTE, static_cast<const int8_t>(buf[1])); + return Key(Type::MIDI_NOTE, static_cast<const int8_t>(buf[1])); default: return Key(); } @@ -148,24 +148,24 @@ ControlBindings::port_value_changed(ProcessContext& context, uint16_t size = 0; uint8_t buf[4]; switch (key.type) { - case MIDI_CC: + case Type::MIDI_CC: size = 3; buf[0] = LV2_MIDI_MSG_CONTROLLER; buf[1] = key.num; buf[2] = static_cast<int8_t>(value); break; - case MIDI_CHANNEL_PRESSURE: + case Type::MIDI_CHANNEL_PRESSURE: size = 2; buf[0] = LV2_MIDI_MSG_CHANNEL_PRESSURE; buf[1] = static_cast<int8_t>(value); break; - case MIDI_BENDER: + case Type::MIDI_BENDER: size = 3; buf[0] = LV2_MIDI_MSG_BENDER; buf[1] = (value & 0x007F); buf[2] = (value & 0x7F00) >> 7; break; - case MIDI_NOTE: + case Type::MIDI_NOTE: size = 3; if (value == 1) { buf[0] = LV2_MIDI_MSG_NOTE_ON; @@ -210,14 +210,14 @@ ControlBindings::control_to_port_value(ProcessContext& context, { float normal = 0.0f; switch (type) { - case MIDI_CC: - case MIDI_CHANNEL_PRESSURE: + case Type::MIDI_CC: + case Type::MIDI_CHANNEL_PRESSURE: normal = (float)value / 127.0f; break; - case MIDI_BENDER: + case Type::MIDI_BENDER: normal = (float)value / 16383.0f; break; - case MIDI_NOTE: + case Type::MIDI_NOTE: normal = (value == 0.0f) ? 0.0f : 1.0f; break; default: @@ -262,12 +262,12 @@ ControlBindings::port_value_to_control(ProcessContext& context, } switch (type) { - case MIDI_CC: - case MIDI_CHANNEL_PRESSURE: + case Type::MIDI_CC: + case Type::MIDI_CHANNEL_PRESSURE: return lrintf(normal * 127.0f); - case MIDI_BENDER: + case Type::MIDI_BENDER: return lrintf(normal * 16383.0f); - case MIDI_NOTE: + case Type::MIDI_NOTE: return (value > 0.0f) ? 1 : 0; default: return 0; @@ -282,25 +282,25 @@ forge_binding(const URIs& uris, { LV2_Atom_Forge_Frame frame; switch (binding_type) { - case ControlBindings::MIDI_CC: + case ControlBindings::Type::MIDI_CC: lv2_atom_forge_blank(forge, &frame, 0, uris.midi_Controller); lv2_atom_forge_property_head(forge, uris.midi_controllerNumber, 0); lv2_atom_forge_int(forge, value); break; - case ControlBindings::MIDI_BENDER: + case ControlBindings::Type::MIDI_BENDER: lv2_atom_forge_blank(forge, &frame, 0, uris.midi_Bender); break; - case ControlBindings::MIDI_CHANNEL_PRESSURE: + case ControlBindings::Type::MIDI_CHANNEL_PRESSURE: lv2_atom_forge_blank(forge, &frame, 0, uris.midi_ChannelPressure); break; - case ControlBindings::MIDI_NOTE: + case ControlBindings::Type::MIDI_NOTE: lv2_atom_forge_blank(forge, &frame, 0, uris.midi_NoteOn); lv2_atom_forge_property_head(forge, uris.midi_noteNumber, 0); lv2_atom_forge_int(forge, value); break; - case ControlBindings::MIDI_RPN: // TODO - case ControlBindings::MIDI_NRPN: // TODO - case ControlBindings::NULL_CONTROL: + case ControlBindings::Type::MIDI_RPN: // TODO + case ControlBindings::Type::MIDI_NRPN: // TODO + case ControlBindings::Type::NULL_CONTROL: break; } } @@ -330,7 +330,7 @@ ControlBindings::bind(ProcessContext& context, Key key) { const Ingen::URIs& uris = context.engine().world()->uris(); assert(_learn_port); - if (key.type == MIDI_NOTE) { + if (key.type == Type::MIDI_NOTE) { if (!_learn_port->is_toggled()) return false; } diff --git a/src/server/ControlBindings.hpp b/src/server/ControlBindings.hpp index 286dde15..630ec18a 100644 --- a/src/server/ControlBindings.hpp +++ b/src/server/ControlBindings.hpp @@ -36,7 +36,7 @@ class PortImpl; class ControlBindings { public: - enum Type { + enum class Type { NULL_CONTROL, MIDI_BENDER, MIDI_CC, @@ -47,11 +47,11 @@ public: }; struct Key { - Key(Type t=NULL_CONTROL, int16_t n=0) : type(t), num(n) {} + Key(Type t=Type::NULL_CONTROL, int16_t n=0) : type(t), num(n) {} inline bool operator<(const Key& other) const { return (type == other.type) ? (num < other.num) : (type < other.type); } - inline operator bool() const { return type != NULL_CONTROL; } + inline operator bool() const { return type != Type::NULL_CONTROL; } Type type; int16_t num; }; diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index faac9514..ce84de4d 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -201,11 +201,11 @@ Engine::activate() *this, Raul::Symbol("root"), 1, NULL, _driver->sample_rate(), 1); _root_graph->set_property( uris.rdf_type, - Resource::Property(uris.ingen_Graph, Resource::INTERNAL)); + Resource::Property(uris.ingen_Graph, Resource::Graph::INTERNAL)); _root_graph->set_property( uris.ingen_polyphony, Resource::Property(_world->forge().make(int32_t(1)), - Resource::INTERNAL)); + Resource::Graph::INTERNAL)); _root_graph->activate(*_buffer_factory); _world->store()->add(_root_graph); _root_graph->set_compiled_graph(_root_graph->compile()); @@ -233,10 +233,12 @@ Engine::activate() Resource::Property(uris.lv2_connectionOptional))); in_properties.insert( make_pair(uris.ingen_canvasX, - Resource::Property(forge.make(32.0f), Resource::EXTERNAL))); + Resource::Property(forge.make(32.0f), + Resource::Graph::EXTERNAL))); in_properties.insert( make_pair(uris.ingen_canvasY, - Resource::Property(forge.make(32.0f), Resource::EXTERNAL))); + Resource::Property(forge.make(32.0f), + Resource::Graph::EXTERNAL))); SharedPtr<Interface> respondee; execute_and_delete_event( @@ -255,10 +257,12 @@ Engine::activate() Resource::Property(uris.lv2_connectionOptional))); out_properties.insert( make_pair(uris.ingen_canvasX, - Resource::Property(forge.make(128.0f), Resource::EXTERNAL))); + Resource::Property(forge.make(128.0f), + Resource::Graph::EXTERNAL))); out_properties.insert( make_pair(uris.ingen_canvasY, - Resource::Property(forge.make(32.0f), Resource::EXTERNAL))); + Resource::Property(forge.make(32.0f), + Resource::Graph::EXTERNAL))); execute_and_delete_event( context, new Events::CreatePort( diff --git a/src/server/Event.hpp b/src/server/Event.hpp index 171e7cc9..e2000d09 100644 --- a/src/server/Event.hpp +++ b/src/server/Event.hpp @@ -63,7 +63,7 @@ public: virtual void post_process() = 0; /** Return true iff this event has been pre-processed. */ - inline bool is_prepared() const { return _status != NOT_PREPARED; } + inline bool is_prepared() const { return _status != Status::NOT_PREPARED; } /** Return the time stamp of this event. */ inline SampleCount time() const { return _time; } @@ -87,7 +87,7 @@ protected: , _request_client(client) , _request_id(id) , _time(time) - , _status(NOT_PREPARED) + , _status(Status::NOT_PREPARED) {} /** Constructor for internal events only */ @@ -96,18 +96,18 @@ protected: , _next(NULL) , _request_id(-1) , _time(0) - , _status(NOT_PREPARED) + , _status(Status::NOT_PREPARED) {} inline bool pre_process_done(Status st) { _status = st; - return !st; + return st == Status::SUCCESS; } inline bool pre_process_done(Status st, const Raul::URI& subject) { _status = st; _err_subject = subject; - return !st; + return st == Status::SUCCESS; } inline bool pre_process_done(Status st, const Raul::Path& subject) { diff --git a/src/server/EventWriter.cpp b/src/server/EventWriter.cpp index a169e389..0c27bc5f 100644 --- a/src/server/EventWriter.cpp +++ b/src/server/EventWriter.cpp @@ -64,7 +64,7 @@ EventWriter::delta(const Raul::URI& uri, { _engine.enqueue_event( new Events::Delta(_engine, _respondee, _request_id, now(), - false, Resource::DEFAULT, uri, add, remove)); + false, Resource::Graph::DEFAULT, uri, add, remove)); } void @@ -124,7 +124,7 @@ EventWriter::set_property(const Raul::URI& uri, add.insert(make_pair(predicate, value)); _engine.enqueue_event( new Events::Delta(_engine, _respondee, _request_id, now(), - false, Resource::DEFAULT, uri, add, remove)); + false, Resource::Graph::DEFAULT, uri, add, remove)); } void diff --git a/src/server/EventWriter.hpp b/src/server/EventWriter.hpp index c2fc0b81..68f93cbd 100644 --- a/src/server/EventWriter.hpp +++ b/src/server/EventWriter.hpp @@ -58,7 +58,7 @@ public: virtual void put(const Raul::URI& path, const Resource::Properties& properties, - const Resource::Graph g=Resource::DEFAULT); + const Resource::Graph g=Resource::Graph::DEFAULT); virtual void delta(const Raul::URI& path, const Resource::Properties& remove, diff --git a/src/server/GraphImpl.hpp b/src/server/GraphImpl.hpp index 2e534ca7..450318ba 100644 --- a/src/server/GraphImpl.hpp +++ b/src/server/GraphImpl.hpp @@ -58,7 +58,7 @@ public: virtual ~GraphImpl(); - virtual GraphType graph_type() const { return GRAPH; } + virtual GraphType graph_type() const { return GraphType::GRAPH; } void activate(BufferFactory& bufs); void deactivate(); diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp index 9ab3cbfe..fe534eb0 100644 --- a/src/server/InputPort.cpp +++ b/src/server/InputPort.cpp @@ -50,7 +50,7 @@ InputPort::InputPort(BufferFactory& bufs, { const Ingen::URIs& uris = bufs.uris(); - if (parent->graph_type() != Node::GRAPH) { + if (parent->graph_type() != Node::GraphType::GRAPH) { add_property(uris.rdf_type, uris.lv2_InputPort); } diff --git a/src/server/LV2ResizeFeature.hpp b/src/server/LV2ResizeFeature.hpp index 8edd7868..aeabe47a 100644 --- a/src/server/LV2ResizeFeature.hpp +++ b/src/server/LV2ResizeFeature.hpp @@ -34,7 +34,7 @@ struct ResizeFeature : public Ingen::LV2Features::Feature { size_t size) { BlockImpl* block = (BlockImpl*)data; PortImpl* port = block->port_impl(index); - if (block->context() == Context::MESSAGE) { + if (block->context() == Context::ID::MESSAGE) { port->buffer(0)->resize(size); port->connect_buffers(); return LV2_RESIZE_PORT_SUCCESS; diff --git a/src/server/OutputPort.cpp b/src/server/OutputPort.cpp index 4596c68f..94e166bd 100644 --- a/src/server/OutputPort.cpp +++ b/src/server/OutputPort.cpp @@ -38,7 +38,7 @@ OutputPort::OutputPort(BufferFactory& bufs, size_t buffer_size) : PortImpl(bufs, parent, symbol, index, poly, type, buffer_type, value, buffer_size) { - if (parent->graph_type() != Node::GRAPH) { + if (parent->graph_type() != Node::GraphType::GRAPH) { add_property(bufs.uris().rdf_type, bufs.uris().lv2_OutputPort); } diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 61fd7be9..ed7a7084 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -79,7 +79,7 @@ PortImpl::PortImpl(BufferFactory& bufs, if (type == PortType::ATOM) { add_property(uris.atom_bufferType, bufs.forge().make_urid(buffer_type)); - if (block->graph_type() == Ingen::Node::GRAPH) { + if (block->graph_type() == Ingen::Node::GraphType::GRAPH) { add_property(uris.atom_supports, bufs.forge().make_urid(uris.midi_MidiEvent)); add_property(uris.atom_supports, @@ -100,7 +100,7 @@ PortImpl::set_type(PortType port_type, LV2_URID buffer_type) _type = port_type; _buffer_type = buffer_type; if (!_buffer_type) { - switch (_type.symbol()) { + switch (_type.id()) { case PortType::CONTROL: _buffer_type = _bufs.uris().atom_Float; break; @@ -163,10 +163,10 @@ PortImpl::set_voice_value(const Context& context, FrameTime time, Sample value) { - switch (_type.symbol()) { + switch (_type.id()) { case PortType::CONTROL: buffer(voice)->samples()[0] = value; - _set_states->at(voice).state = SetState::SET; + _set_states->at(voice).state = SetState::State::SET; break; case PortType::AUDIO: case PortType::CV: { @@ -183,7 +183,9 @@ PortImpl::set_voice_value(const Context& context, frame of a block (set nframes-1 to 1, then nframes to 0). */ SetState& state = _set_states->at(voice); - state.state = (offset == 0) ? SetState::SET : SetState::HALF_SET_CYCLE_1; + state.state = (offset == 0) + ? SetState::State::SET + : SetState::State::HALF_SET_CYCLE_1; state.time = time; state.value = value; } @@ -197,15 +199,14 @@ PortImpl::update_set_state(Context& context, uint32_t voice) { SetState& state = _set_states->at(voice); switch (state.state) { - case SetState::HALF_SET_CYCLE_1: - state.state = SetState::HALF_SET_CYCLE_2; + case SetState::State::SET: break; - case SetState::HALF_SET_CYCLE_2: { - buffer(voice)->set_block(state.value, 0, context.nframes()); - state.state = SetState::SET; + case SetState::State::HALF_SET_CYCLE_1: + state.state = SetState::State::HALF_SET_CYCLE_2; break; - } - default: + case SetState::State::HALF_SET_CYCLE_2: + buffer(voice)->set_block(state.value, 0, context.nframes()); + state.state = SetState::State::SET; break; } } @@ -316,7 +317,7 @@ PortImpl::recycle_buffers() void PortImpl::clear_buffers() { - switch (_type.symbol()) { + switch (_type.id()) { case PortType::AUDIO: case PortType::CONTROL: case PortType::CV: @@ -324,7 +325,7 @@ PortImpl::clear_buffers() Buffer* buf = buffer(v).get(); buf->set_block(_value.get_float(), 0, buf->nframes()); SetState& state = _set_states->at(v); - state.state = SetState::SET; + state.state = SetState::State::SET; state.value = _value.get_float(); state.time = 0; } @@ -343,7 +344,7 @@ PortImpl::broadcast_value(Context& context, bool force) URIs& uris = context.engine().world()->uris(); LV2_URID key = 0; Raul::Atom val; - switch (_type.symbol()) { + switch (_type.id()) { case PortType::UNKNOWN: break; case PortType::AUDIO: diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp index 428a628b..4aed4458 100644 --- a/src/server/PortImpl.hpp +++ b/src/server/PortImpl.hpp @@ -45,7 +45,7 @@ class PortImpl : public NodeImpl public: ~PortImpl(); - virtual GraphType graph_type() const { return PORT; } + virtual GraphType graph_type() const { return GraphType::PORT; } /** A port's parent is always a block, so static cast should be safe */ BlockImpl* parent_block() const { return (BlockImpl*)_parent; } @@ -181,9 +181,9 @@ protected: size_t buffer_size); struct SetState { - enum State { SET, HALF_SET_CYCLE_1, HALF_SET_CYCLE_2 }; + enum class State { SET, HALF_SET_CYCLE_1, HALF_SET_CYCLE_2 }; - SetState() : state(SET), value(0), time(0) {} + SetState() : state(State::SET), value(0), time(0) {} State state; ///< State of buffer for setting control value Sample value; ///< Value currently being set diff --git a/src/server/PortType.hpp b/src/server/PortType.hpp index 883b352f..5445d907 100644 --- a/src/server/PortType.hpp +++ b/src/server/PortType.hpp @@ -34,7 +34,7 @@ namespace Ingen { */ class PortType { public: - enum Symbol { + enum ID { UNKNOWN = 0, AUDIO = 1, CONTROL = 2, @@ -43,40 +43,40 @@ public: }; explicit PortType(const Raul::URI& uri) - : _symbol(UNKNOWN) + : _id(UNKNOWN) { if (uri == type_uri(AUDIO)) { - _symbol = AUDIO; + _id = AUDIO; } else if (uri == type_uri(CONTROL)) { - _symbol = CONTROL; + _id = CONTROL; } else if (uri == type_uri(CV)) { - _symbol = CV; + _id = CV; } else if (uri == type_uri(ATOM)) { - _symbol = ATOM; + _id = ATOM; } } - PortType(Symbol symbol) - : _symbol(symbol) + PortType(ID id) + : _id(id) {} - inline const Raul::URI& uri() const { return type_uri(_symbol); } - inline Symbol symbol() const { return _symbol; } + inline const Raul::URI& uri() const { return type_uri(_id); } + inline ID id() const { return _id; } - inline bool operator==(const Symbol& symbol) const { return (_symbol == symbol); } - inline bool operator!=(const Symbol& symbol) const { return (_symbol != symbol); } - inline bool operator==(const PortType& type) const { return (_symbol == type._symbol); } - inline bool operator!=(const PortType& type) const { return (_symbol != type._symbol); } - inline bool operator<(const PortType& type) const { return (_symbol < type._symbol); } + inline bool operator==(const ID& id) const { return (_id == id); } + inline bool operator!=(const ID& id) const { return (_id != id); } + inline bool operator==(const PortType& type) const { return (_id == type._id); } + inline bool operator!=(const PortType& type) const { return (_id != type._id); } + inline bool operator<(const PortType& type) const { return (_id < type._id); } - inline bool is_audio() { return _symbol == AUDIO; } - inline bool is_control() { return _symbol == CONTROL; } - inline bool is_cv() { return _symbol == CV; } - inline bool is_atom() { return _symbol == ATOM; } + inline bool is_audio() { return _id == AUDIO; } + inline bool is_control() { return _id == CONTROL; } + inline bool is_cv() { return _id == CV; } + inline bool is_atom() { return _id == ATOM; } private: - static inline const Raul::URI& type_uri(unsigned symbol_num) { - assert(symbol_num <= ATOM); + static inline const Raul::URI& type_uri(unsigned id_num) { + assert(id_num <= ATOM); static const Raul::URI uris[] = { Raul::URI("http://drobilla.net/ns/ingen#nil"), Raul::URI(LV2_CORE__AudioPort), @@ -84,10 +84,10 @@ private: Raul::URI(LV2_CORE__CVPort), Raul::URI(LV2_ATOM__AtomPort) }; - return uris[symbol_num]; + return uris[id_num]; } - Symbol _symbol; + ID _id; }; } // namespace Ingen diff --git a/src/server/ProcessContext.hpp b/src/server/ProcessContext.hpp index 75fdcb83..ca98babf 100644 --- a/src/server/ProcessContext.hpp +++ b/src/server/ProcessContext.hpp @@ -33,7 +33,7 @@ class ProcessContext : public Context { public: ProcessContext(Engine& engine) - : Context(engine, AUDIO) + : Context(engine, ID::AUDIO) {} }; diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp index 0559ec39..16792a11 100644 --- a/src/server/events/Connect.cpp +++ b/src/server/events/Connect.cpp @@ -56,34 +56,34 @@ Connect::pre_process() Node* tail = _engine.store()->get(_tail_path); if (!tail) { - return Event::pre_process_done(NOT_FOUND, _tail_path); + return Event::pre_process_done(Status::NOT_FOUND, _tail_path); } Node* head = _engine.store()->get(_head_path); if (!head) { - return Event::pre_process_done(NOT_FOUND, _head_path); + return Event::pre_process_done(Status::NOT_FOUND, _head_path); } OutputPort* tail_output = dynamic_cast<OutputPort*>(tail); _head = dynamic_cast<InputPort*>(head); if (!tail_output || !_head) { - return Event::pre_process_done(BAD_REQUEST, _head_path); + return Event::pre_process_done(Status::BAD_REQUEST, _head_path); } BlockImpl* const tail_block = tail_output->parent_block(); BlockImpl* const head_block = _head->parent_block(); if (!tail_block || !head_block) { - return Event::pre_process_done(PARENT_NOT_FOUND, _head_path); + return Event::pre_process_done(Status::PARENT_NOT_FOUND, _head_path); } if (tail_block->parent() != head_block->parent() && tail_block != head_block->parent() && tail_block->parent() != head_block) { - return Event::pre_process_done(PARENT_DIFFERS, _head_path); + return Event::pre_process_done(Status::PARENT_DIFFERS, _head_path); } if (!ArcImpl::can_connect(tail_output, _head)) { - return Event::pre_process_done(TYPE_MISMATCH, _head_path); + return Event::pre_process_done(Status::TYPE_MISMATCH, _head_path); } if (tail_block->parent_graph() != head_block->parent_graph()) { @@ -103,7 +103,7 @@ Connect::pre_process() } if (_graph->has_arc(tail_output, _head)) { - return Event::pre_process_done(EXISTS, _head_path); + return Event::pre_process_done(Status::EXISTS, _head_path); } _arc = SharedPtr<ArcImpl>(new ArcImpl(tail_output, _head)); @@ -136,13 +136,13 @@ Connect::pre_process() _compiled_graph = _graph->compile(); } - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void Connect::execute(ProcessContext& context) { - if (!_status) { + if (_status != Status::SUCCESS) { _head->add_arc(context, _arc.get()); _engine.maid()->dispose(_head->set_buffers(context, _buffers)); _head->connect_buffers(); @@ -154,7 +154,7 @@ void Connect::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { _engine.broadcaster()->connect(_tail_path, _head_path); } } diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp index b75dbf1e..65e24bfd 100644 --- a/src/server/events/CreateBlock.cpp +++ b/src/server/events/CreateBlock.cpp @@ -59,7 +59,7 @@ CreateBlock::pre_process() typedef Resource::Properties::const_iterator iterator; if (_path.is_root()) { - return Event::pre_process_done(BAD_URI, _path); + return Event::pre_process_done(Status::BAD_URI, _path); } std::string plugin_uri_str; @@ -67,22 +67,23 @@ CreateBlock::pre_process() if (t != _properties.end() && t->second.type() == uris.forge.URI) { plugin_uri_str = t->second.get_uri(); } else { - return Event::pre_process_done(BAD_REQUEST); + return Event::pre_process_done(Status::BAD_REQUEST); } if (_engine.store()->get(_path)) { - return Event::pre_process_done(EXISTS, _path); + return Event::pre_process_done(Status::EXISTS, _path); } _graph = dynamic_cast<GraphImpl*>(_engine.store()->get(_path.parent())); if (!_graph) { - return Event::pre_process_done(PARENT_NOT_FOUND, _path.parent()); + return Event::pre_process_done(Status::PARENT_NOT_FOUND, _path.parent()); } const Raul::URI plugin_uri(plugin_uri_str); PluginImpl* plugin = _engine.block_factory()->plugin(plugin_uri); if (!plugin) { - return Event::pre_process_done(PLUGIN_NOT_FOUND, Raul::URI(plugin_uri)); + return Event::pre_process_done(Status::PLUGIN_NOT_FOUND, + Raul::URI(plugin_uri)); } const iterator p = _properties.find(uris.ingen_polyphonic); @@ -96,7 +97,7 @@ CreateBlock::pre_process() polyphonic, _graph, _engine))) { - return Event::pre_process_done(CREATION_FAILED, _path); + return Event::pre_process_done(Status::CREATION_FAILED, _path); } _block->properties().insert(_properties.begin(), _properties.end()); @@ -122,7 +123,7 @@ CreateBlock::pre_process() _update.push_back(std::make_pair(port->uri(), pprops)); } - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void @@ -138,7 +139,7 @@ void CreateBlock::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { for (Update::const_iterator i = _update.begin(); i != _update.end(); ++i) { _engine.broadcaster()->put(i->first, i->second); } diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp index 23c6ef14..f2131246 100644 --- a/src/server/events/CreateGraph.cpp +++ b/src/server/events/CreateGraph.cpp @@ -48,12 +48,12 @@ bool CreateGraph::pre_process() { if (_path.is_root() || _engine.store()->get(_path)) { - return Event::pre_process_done(EXISTS, _path); + return Event::pre_process_done(Status::EXISTS, _path); } _parent = dynamic_cast<GraphImpl*>(_engine.store()->get(_path.parent())); if (!_parent) { - return Event::pre_process_done(PARENT_NOT_FOUND, _path.parent()); + return Event::pre_process_done(Status::PARENT_NOT_FOUND, _path.parent()); } const Ingen::URIs& uris = _engine.world()->uris(); @@ -68,7 +68,7 @@ CreateGraph::pre_process() } if (int_poly < 1 || int_poly > 128) { - return Event::pre_process_done(INVALID_POLY, _path); + return Event::pre_process_done(Status::INVALID_POLY, _path); } if (int_poly == _parent->internal_poly()) { @@ -81,7 +81,8 @@ CreateGraph::pre_process() _graph->properties().insert(_properties.begin(), _properties.end()); _graph->add_property(uris.rdf_type, uris.ingen_Graph); _graph->add_property(uris.rdf_type, - Resource::Property(uris.ingen_Block, Resource::EXTERNAL)); + Resource::Property(uris.ingen_Block, + Resource::Graph::EXTERNAL)); _parent->add_block(*_graph); if (_parent->enabled()) { @@ -96,7 +97,7 @@ CreateGraph::pre_process() _update = _graph->properties(); - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void @@ -111,7 +112,7 @@ void CreateGraph::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { _engine.broadcaster()->put(Node::path_to_uri(_path), _update); } } diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index 03cc2bd8..818b0438 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -86,11 +86,11 @@ bool CreatePort::pre_process() { if (_port_type == PortType::UNKNOWN) { - return Event::pre_process_done(UNKNOWN_TYPE, _path); + return Event::pre_process_done(Status::UNKNOWN_TYPE, _path); } if (_path.is_root()) { - return Event::pre_process_done(BAD_URI, _path); + return Event::pre_process_done(Status::BAD_URI, _path); } if (_engine.store()->get(_path)) { @@ -99,11 +99,13 @@ CreatePort::pre_process() Node* parent = _engine.store()->get(_path.parent()); if (!parent) { - return Event::pre_process_done(PARENT_NOT_FOUND, _path.parent()); + return Event::pre_process_done(Status::PARENT_NOT_FOUND, + _path.parent()); } if (!(_graph = dynamic_cast<GraphImpl*>(parent))) { - return Event::pre_process_done(INVALID_PARENT_PATH, _path.parent()); + return Event::pre_process_done(Status::INVALID_PARENT_PATH, + _path.parent()); } const URIs& uris = _engine.world()->uris(); @@ -122,7 +124,7 @@ CreatePort::pre_process() _engine.world()->forge().make(old_n_ports))); } else if (index_i->second.type() != uris.forge.Int || index_i->second.get_int32() != old_n_ports) { - return Event::pre_process_done(BAD_INDEX, _path); + return Event::pre_process_done(Status::BAD_INDEX, _path); } const PropIter poly_i = _properties.find(uris.ingen_polyphonic); @@ -133,7 +135,7 @@ CreatePort::pre_process() if (!(_graph_port = _graph->create_port( *_engine.buffer_factory(), Raul::Symbol(_path.symbol()), _port_type, _buf_type, buf_size, _is_output, polyphonic))) { - return Event::pre_process_done(CREATION_FAILED, _path); + return Event::pre_process_done(Status::CREATION_FAILED, _path); } _graph_port->properties().insert(_properties.begin(), _properties.end()); @@ -158,13 +160,13 @@ CreatePort::pre_process() assert(_graph_port->index() == (uint32_t)old_n_ports); assert(_ports_array->size() == _graph->num_ports_non_rt()); assert(_graph_port->index() < _ports_array->size()); - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void CreatePort::execute(ProcessContext& context) { - if (!_status) { + if (_status == Status::SUCCESS) { _old_ports_array = _graph->external_ports(); if (_old_ports_array) { for (uint32_t i = 0; i < _old_ports_array->size(); ++i) { @@ -185,7 +187,7 @@ void CreatePort::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { _engine.broadcaster()->put(Node::path_to_uri(_path), _update); } diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp index 77dd9003..bcfb209a 100644 --- a/src/server/events/Delete.cpp +++ b/src/server/events/Delete.cpp @@ -61,7 +61,7 @@ bool Delete::pre_process() { if (_path.is_root() || _path == "/control_in" || _path == "/control_out") { - return Event::pre_process_done(NOT_DELETABLE, _path); + return Event::pre_process_done(Status::NOT_DELETABLE, _path); } _lock.acquire(); @@ -70,7 +70,7 @@ Delete::pre_process() Store::iterator iter = _engine.store()->find(_path); if (iter == _engine.store()->end()) { - return Event::pre_process_done(NOT_FOUND, _path); + return Event::pre_process_done(Status::NOT_FOUND, _path); } if (!(_block = PtrCast<BlockImpl>(iter->second))) { @@ -78,12 +78,12 @@ Delete::pre_process() } if (!_block && !_port) { - return Event::pre_process_done(NOT_DELETABLE, _path); + return Event::pre_process_done(Status::NOT_DELETABLE, _path); } GraphImpl* parent = _block ? _block->parent_graph() : _port->parent_graph(); if (!parent) { - return Event::pre_process_done(INTERNAL_ERROR, _path); + return Event::pre_process_done(Status::INTERNAL_ERROR, _path); } _engine.store()->remove(iter, _removed_objects); @@ -112,7 +112,7 @@ Delete::pre_process() } } - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void @@ -145,7 +145,7 @@ Delete::post_process() _removed_bindings.reset(); Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond() && (_block || _port)) { + if (respond() == Status::SUCCESS && (_block || _port)) { if (_block) { _block->deactivate(); } diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index c7a2fb10..0f854096 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -64,7 +64,7 @@ Delta::Delta(Engine& engine, , _context(context) , _create(create) { - if (context != Resource::DEFAULT) { + if (context != Resource::Graph::DEFAULT) { for (Properties::iterator i = _properties.begin(); i != _properties.end(); ++i) { @@ -115,7 +115,7 @@ Delta::pre_process() : static_cast<Ingen::Resource*>(_engine.block_factory()->plugin(_subject)); if (!_object && (!is_graph_object || !_create)) { - return Event::pre_process_done(NOT_FOUND, _subject); + return Event::pre_process_done(Status::NOT_FOUND, _subject); } const Ingen::URIs& uris = _engine.world()->uris(); @@ -141,7 +141,7 @@ Delta::pre_process() // Grab the object for applying properties, if the create-event succeeded _object = _engine.store()->get(path); } else { - return Event::pre_process_done(BAD_OBJECT_TYPE, _subject); + return Event::pre_process_done(Status::BAD_OBJECT_TYPE, _subject); } } @@ -163,7 +163,7 @@ Delta::pre_process() for (Properties::const_iterator p = _properties.begin(); p != _properties.end(); ++p) { const Raul::URI& key = p->first; const Resource::Property& value = p->second; - SpecialType op = NONE; + SpecialType op = SpecialType::NONE; if (obj) { Resource& resource = *obj; if (value != uris.wildcard) { @@ -175,9 +175,9 @@ Delta::pre_process() if (port) { if (key == uris.ingen_broadcast) { if (value.type() == uris.forge.Bool) { - op = ENABLE_BROADCAST; + op = SpecialType::ENABLE_BROADCAST; } else { - _status = BAD_VALUE_TYPE; + _status = Status::BAD_VALUE_TYPE; } } else if (key == uris.ingen_value) { SetPortValue* ev = new SetPortValue( @@ -189,46 +189,46 @@ Delta::pre_process() if (value == uris.wildcard) { _engine.control_bindings()->learn(port); } else if (value.type() == uris.atom_Blank) { - op = CONTROL_BINDING; + op = SpecialType::CONTROL_BINDING; } else { - _status = BAD_VALUE_TYPE; + _status = Status::BAD_VALUE_TYPE; } } else { - _status = BAD_OBJECT_TYPE; + _status = Status::BAD_OBJECT_TYPE; } } } else if ((block = dynamic_cast<BlockImpl*>(_object))) { if (key == uris.ingen_controlBinding && value == uris.wildcard) { - op = CONTROL_BINDING; // Internal block learn + op = SpecialType::CONTROL_BINDING; // Internal block learn } } else if ((_graph = dynamic_cast<GraphImpl*>(_object))) { if (key == uris.ingen_enabled) { if (value.type() == uris.forge.Bool) { - op = ENABLE; + op = SpecialType::ENABLE; // FIXME: defer this until all other metadata has been processed if (value.get_bool() && !_graph->enabled()) _compiled_graph = _graph->compile(); } else { - _status = BAD_VALUE_TYPE; + _status = Status::BAD_VALUE_TYPE; } } else if (key == uris.ingen_polyphony) { if (value.type() == uris.forge.Int) { if (value.get_int32() < 1 || value.get_int32() > 128) { - _status = INVALID_POLY; + _status = Status::INVALID_POLY; } else { - op = POLYPHONY; + op = SpecialType::POLYPHONY; _graph->prepare_internal_poly( *_engine.buffer_factory(), value.get_int32()); } } else { - _status = BAD_VALUE_TYPE; + _status = Status::BAD_VALUE_TYPE; } } } else if (key == uris.ingen_polyphonic) { GraphImpl* parent = dynamic_cast<GraphImpl*>(obj->parent()); if (parent) { if (value.type() == uris.forge.Bool) { - op = POLYPHONIC; + op = SpecialType::POLYPHONIC; obj->set_property(key, value, value.context()); BlockImpl* block = dynamic_cast<BlockImpl*>(obj); if (block) @@ -239,29 +239,30 @@ Delta::pre_process() obj->prepare_poly(*_engine.buffer_factory(), 1); } } else { - _status = BAD_VALUE_TYPE; + _status = Status::BAD_VALUE_TYPE; } } else { - _status = BAD_OBJECT_TYPE; + _status = Status::BAD_OBJECT_TYPE; } } } - if (_status != NOT_PREPARED) { + if (_status != Status::NOT_PREPARED) { break; } _types.push_back(op); } - return Event::pre_process_done(_status == NOT_PREPARED ? SUCCESS : _status, - _subject); + return Event::pre_process_done( + _status == Status::NOT_PREPARED ? Status::SUCCESS : _status, + _subject); } void Delta::execute(ProcessContext& context) { - if (_status) { + if (_status != Status::SUCCESS) { return; } @@ -286,12 +287,12 @@ Delta::execute(ProcessContext& context) const Raul::URI& key = p->first; const Raul::Atom& value = p->second; switch (*t) { - case ENABLE_BROADCAST: + case SpecialType::ENABLE_BROADCAST: if (port) { port->broadcast(value.get_bool()); } break; - case ENABLE: + case SpecialType::ENABLE: if (value.get_bool()) { if (_compiled_graph) { _graph->set_compiled_graph(_compiled_graph); @@ -301,7 +302,7 @@ Delta::execute(ProcessContext& context) _graph->disable(context); } break; - case POLYPHONIC: { + case SpecialType::POLYPHONIC: { GraphImpl* parent = reinterpret_cast<GraphImpl*>(object->parent()); if (value.get_bool()) { object->apply_poly( @@ -310,15 +311,15 @@ Delta::execute(ProcessContext& context) object->apply_poly(context, *_engine.maid(), 1); } } break; - case POLYPHONY: + case SpecialType::POLYPHONY: if (!_graph->apply_internal_poly(context, *_engine.buffer_factory(), *_engine.maid(), value.get_int32())) { - _status = INTERNAL_ERROR; + _status = Status::INTERNAL_ERROR; } break; - case CONTROL_BINDING: + case SpecialType::CONTROL_BINDING: if (port) { _engine.control_bindings()->port_binding_changed(context, port, value); } else if (block) { @@ -327,7 +328,7 @@ Delta::execute(ProcessContext& context) } } break; - case NONE: + case SpecialType::NONE: if (port) { if (key == uris.lv2_minimum) { port->set_minimum(value); @@ -348,7 +349,7 @@ Delta::post_process() for (SetEvents::iterator i = _set_events.begin(); i != _set_events.end(); ++i) (*i)->post_process(); - if (!_status) { + if (_status == Status::SUCCESS) { if (_create_event) { _create_event->post_process(); } else { diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp index c3a28fbb..34319591 100644 --- a/src/server/events/Delta.hpp +++ b/src/server/events/Delta.hpp @@ -86,7 +86,7 @@ public: void post_process(); private: - enum SpecialType { + enum class SpecialType { NONE, ENABLE, ENABLE_BROADCAST, diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index 829500f5..4a961d9e 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -117,17 +117,17 @@ Disconnect::pre_process() if (_tail_path.parent().parent() != _head_path.parent().parent() && _tail_path.parent() != _head_path.parent().parent() && _tail_path.parent().parent() != _head_path.parent()) { - return Event::pre_process_done(PARENT_DIFFERS, _head_path); + return Event::pre_process_done(Status::PARENT_DIFFERS, _head_path); } PortImpl* tail = dynamic_cast<PortImpl*>(_engine.store()->get(_tail_path)); if (!tail) { - return Event::pre_process_done(PORT_NOT_FOUND, _tail_path); + return Event::pre_process_done(Status::PORT_NOT_FOUND, _tail_path); } PortImpl* head = dynamic_cast<PortImpl*>(_engine.store()->get(_head_path)); if (!head) { - return Event::pre_process_done(PORT_NOT_FOUND, _head_path); + return Event::pre_process_done(Status::PORT_NOT_FOUND, _head_path); } BlockImpl* const src_block = tail->parent_block(); @@ -150,13 +150,13 @@ Disconnect::pre_process() } if (!_graph) { - return Event::pre_process_done(INTERNAL_ERROR, _head_path); + return Event::pre_process_done(Status::INTERNAL_ERROR, _head_path); } else if (!_graph->has_arc(tail, head)) { - return Event::pre_process_done(NOT_FOUND, _head_path); + return Event::pre_process_done(Status::NOT_FOUND, _head_path); } if (src_block == NULL || dst_block == NULL) { - return Event::pre_process_done(PARENT_NOT_FOUND, _head_path); + return Event::pre_process_done(Status::PARENT_NOT_FOUND, _head_path); } _impl = new Impl(_engine, @@ -167,7 +167,7 @@ Disconnect::pre_process() if (_graph->enabled()) _compiled_graph = _graph->compile(); - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } bool @@ -198,9 +198,9 @@ Disconnect::Impl::execute(ProcessContext& context, bool set_dst_buffers) void Disconnect::execute(ProcessContext& context) { - if (_status == SUCCESS) { + if (_status == Status::SUCCESS) { if (!_impl->execute(context, true)) { - _status = NOT_FOUND; + _status = Status::NOT_FOUND; return; } @@ -212,7 +212,7 @@ void Disconnect::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { _engine.broadcaster()->disconnect(_tail_path, _head_path); } diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp index c2475b45..a6022410 100644 --- a/src/server/events/DisconnectAll.cpp +++ b/src/server/events/DisconnectAll.cpp @@ -89,18 +89,20 @@ DisconnectAll::pre_process() _parent = dynamic_cast<GraphImpl*>(_engine.store()->get(_parent_path)); if (!_parent) { - return Event::pre_process_done(PARENT_NOT_FOUND, _parent_path); + return Event::pre_process_done(Status::PARENT_NOT_FOUND, + _parent_path); } NodeImpl* const object = dynamic_cast<NodeImpl*>( _engine.store()->get(_path)); if (!object) { - return Event::pre_process_done(NOT_FOUND, _path); + return Event::pre_process_done(Status::NOT_FOUND, _path); } if (object->parent_graph() != _parent && object->parent()->parent_graph() != _parent) { - return Event::pre_process_done(INVALID_PARENT_PATH, _parent_path); + return Event::pre_process_done(Status::INVALID_PARENT_PATH, + _parent_path); } // Only one of these will succeed @@ -108,7 +110,7 @@ DisconnectAll::pre_process() _port = dynamic_cast<PortImpl*>(object); if (!_block && !_port) { - return Event::pre_process_done(INTERNAL_ERROR, _path); + return Event::pre_process_done(Status::INTERNAL_ERROR, _path); } } @@ -141,13 +143,13 @@ DisconnectAll::pre_process() if (!_deleting && _parent->enabled()) _compiled_graph = _parent->compile(); - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void DisconnectAll::execute(ProcessContext& context) { - if (_status == SUCCESS) { + if (_status == Status::SUCCESS) { for (Impls::iterator i = _impls.begin(); i != _impls.end(); ++i) { (*i)->execute(context, !_deleting || ((*i)->head()->parent_block() != _block)); @@ -161,7 +163,7 @@ void DisconnectAll::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { _engine.broadcaster()->disconnect_all(_parent_path, _path); } } diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp index 93af8bf2..67b68de9 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -57,15 +57,17 @@ Get::pre_process() if (_uri == "ingen:/plugins") { _plugins = _engine.block_factory()->plugins(); - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } else if (_uri == "ingen:/engine") { - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } else if (Node::uri_is_path(_uri)) { _object = _engine.store()->get(Node::uri_to_path(_uri)); - return Event::pre_process_done(_object ? SUCCESS : NOT_FOUND, _uri); + return Event::pre_process_done( + _object ? Status::SUCCESS : Status::NOT_FOUND, _uri); } else { _plugin = _engine.block_factory()->plugin(_uri); - return Event::pre_process_done(_plugin ? SUCCESS : NOT_FOUND, _uri); + return Event::pre_process_done( + _plugin ? Status::SUCCESS : Status::NOT_FOUND, _uri); } } @@ -101,12 +103,12 @@ static void send_graph(Interface* client, const GraphImpl* graph) { client->put(graph->uri(), - graph->properties(Resource::INTERNAL), - Resource::INTERNAL); + graph->properties(Resource::Graph::INTERNAL), + Resource::Graph::INTERNAL); client->put(graph->uri(), - graph->properties(Resource::EXTERNAL), - Resource::EXTERNAL); + graph->properties(Resource::Graph::EXTERNAL), + Resource::Graph::EXTERNAL); // Send blocks for (GraphImpl::Blocks::const_iterator j = graph->blocks().begin(); @@ -130,7 +132,7 @@ void Get::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond() && _request_client) { + if (respond() == Status::SUCCESS && _request_client) { if (_uri == "ingen:/plugins") { _engine.broadcaster()->send_plugins_to(_request_client.get(), _plugins); } else if (_uri == "ingen:/engine") { diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp index 08eea56a..700d5814 100644 --- a/src/server/events/Move.cpp +++ b/src/server/events/Move.cpp @@ -53,16 +53,16 @@ Move::pre_process() Glib::RWLock::WriterLock lock(_engine.store()->lock()); if (!_old_path.parent().is_parent_of(_new_path)) { - return Event::pre_process_done(PARENT_DIFFERS, _new_path); + return Event::pre_process_done(Status::PARENT_DIFFERS, _new_path); } const Store::iterator i = _engine.store()->find(_old_path); if (i == _engine.store()->end()) { - return Event::pre_process_done(NOT_FOUND, _old_path); + return Event::pre_process_done(Status::NOT_FOUND, _old_path); } if (_engine.store()->find(_new_path) != _engine.store()->end()) { - return Event::pre_process_done(EXISTS, _new_path); + return Event::pre_process_done(Status::EXISTS, _new_path); } EnginePort* eport = _engine.driver()->get_port(_old_path); @@ -72,7 +72,7 @@ Move::pre_process() _engine.store()->rename(i, _new_path); - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void @@ -84,7 +84,7 @@ void Move::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { _engine.broadcaster()->move(_old_path, _new_path); } } diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index b3481861..f2399d8e 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -54,7 +54,7 @@ bool SetPortValue::pre_process() { if (_port->is_output()) { - return Event::pre_process_done(DIRECTION_MISMATCH, _port->path()); + return Event::pre_process_done(Status::DIRECTION_MISMATCH, _port->path()); } // Set value metadata (does not affect buffers) @@ -63,7 +63,7 @@ SetPortValue::pre_process() _binding = _engine.control_bindings()->port_binding(_port); - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void @@ -71,7 +71,7 @@ SetPortValue::execute(ProcessContext& context) { assert(_time >= context.start() && _time <= context.end()); - if (_port->parent_block()->context() == Context::MESSAGE) + if (_port->parent_block()->context() == Context::ID::MESSAGE) return; apply(context); @@ -81,7 +81,7 @@ SetPortValue::execute(ProcessContext& context) void SetPortValue::apply(Context& context) { - if (_status) { + if (_status != Status::SUCCESS) { return; } @@ -92,7 +92,7 @@ SetPortValue::apply(Context& context) if (_value.type() == uris.forge.Float) { _port->set_control_value(context, _time, _value.get_float()); } else { - _status = TYPE_MISMATCH; + _status = Status::TYPE_MISMATCH; } } else if (buf->type() == uris.atom_Sequence) { buf->prepare_write(context); // FIXME: incorrect @@ -102,12 +102,12 @@ SetPortValue::apply(Context& context) (const uint8_t*)_value.get_body())) { _port->raise_set_by_user_flag(); } else { - _status = NO_SPACE; + _status = Status::NO_SPACE; } } else if (buf->type() == uris.atom_URID) { ((LV2_Atom_URID*)buf->atom())->body = _value.get_int32(); } else { - _status = BAD_VALUE_TYPE; + _status = Status::BAD_VALUE_TYPE; } } @@ -115,7 +115,7 @@ void SetPortValue::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { _engine.broadcaster()->set_property( _port->uri(), _engine.world()->uris().ingen_value, diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp index 19d2126b..37cebd7e 100644 --- a/src/server/internals/Note.cpp +++ b/src/server/internals/Note.cpp @@ -201,13 +201,13 @@ NoteNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity, F Voice* voice = NULL; uint32_t voice_num = 0; - if (key->state != Key::OFF) { + if (key->state != Key::State::OFF) { return; } // Look for free voices for (uint32_t i=0; i < _polyphony; ++i) { - if ((*_voices)[i].state == Voice::Voice::FREE) { + if ((*_voices)[i].state == Voice::State::FREE) { voice = &(*_voices)[i]; voice_num = i; break; @@ -231,23 +231,23 @@ NoteNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity, F assert(voice == &(*_voices)[voice_num]); // Update stolen key, if applicable - if (voice->state == Voice::Voice::ACTIVE) { - assert(_keys[voice->note].state == Key::ON_ASSIGNED); + if (voice->state == Voice::State::ACTIVE) { + assert(_keys[voice->note].state == Key::State::ON_ASSIGNED); assert(_keys[voice->note].voice == voice_num); - _keys[voice->note].state = Key::Key::ON_UNASSIGNED; + _keys[voice->note].state = Key::State::ON_UNASSIGNED; } // Store key information for later reallocation on note off - key->state = Key::Key::ON_ASSIGNED; + key->state = Key::State::ON_ASSIGNED; key->voice = voice_num; key->time = time; // Trigger voice - voice->state = Voice::Voice::ACTIVE; + voice->state = Voice::State::ACTIVE; voice->note = note_num; voice->time = time; - assert(_keys[voice->note].state == Key::Key::ON_ASSIGNED); + assert(_keys[voice->note].state == Key::State::ON_ASSIGNED); assert(_keys[voice->note].voice == voice_num); _freq_port->set_voice_value(context, voice_num, time, note_to_freq(note_num)); @@ -257,8 +257,8 @@ NoteNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity, F _trig_port->set_voice_value(context, voice_num, time, 1.0f); _trig_port->set_voice_value(context, voice_num, time + 1, 0.0f); - assert(key->state == Key::Key::ON_ASSIGNED); - assert(voice->state == Voice::Voice::ACTIVE); + assert(key->state == Key::State::ON_ASSIGNED); + assert(voice->state == Voice::State::ACTIVE); assert(key->voice == voice_num); assert((*_voices)[key->voice].note == note_num); } @@ -270,19 +270,19 @@ NoteNode::note_off(ProcessContext& context, uint8_t note_num, FrameTime time) Key* key = &_keys[note_num]; - if (key->state == Key::ON_ASSIGNED) { + if (key->state == Key::State::ON_ASSIGNED) { // Assigned key, turn off voice and key - if ((*_voices)[key->voice].state == Voice::ACTIVE) { + if ((*_voices)[key->voice].state == Voice::State::ACTIVE) { assert((*_voices)[key->voice].note == note_num); if ( ! _sustain) { free_voice(context, key->voice, time); } else { - (*_voices)[key->voice].state = Voice::HOLDING; + (*_voices)[key->voice].state = Voice::State::HOLDING; } } } - key->state = Key::OFF; + key->state = Key::State::OFF; } void @@ -295,7 +295,7 @@ NoteNode::free_voice(ProcessContext& context, uint32_t voice, FrameTime time) uint8_t replace_key_num = 0; for (uint8_t i = 0; i <= 127; ++i) { - if (_keys[i].state == Key::ON_UNASSIGNED) { + if (_keys[i].state == Key::State::ON_UNASSIGNED) { if (replace_key == NULL || _keys[i].time > replace_key->time) { replace_key = &_keys[i]; replace_key_num = i; @@ -305,21 +305,21 @@ NoteNode::free_voice(ProcessContext& context, uint32_t voice, FrameTime time) if (replace_key != NULL) { // Found a key to assign to freed voice assert(&_keys[replace_key_num] == replace_key); - assert(replace_key->state == Key::ON_UNASSIGNED); + assert(replace_key->state == Key::State::ON_UNASSIGNED); // Change the freq but leave the gate high and don't retrigger _freq_port->set_voice_value(context, voice, time, note_to_freq(replace_key_num)); _num_port->set_voice_value(context, voice, time, replace_key_num); - replace_key->state = Key::ON_ASSIGNED; + replace_key->state = Key::State::ON_ASSIGNED; replace_key->voice = voice; - _keys[(*_voices)[voice].note].state = Key::ON_UNASSIGNED; + _keys[(*_voices)[voice].note].state = Key::State::ON_UNASSIGNED; (*_voices)[voice].note = replace_key_num; - (*_voices)[voice].state = Voice::ACTIVE; + (*_voices)[voice].state = Voice::State::ACTIVE; } else { // No new note for voice, deactivate (set gate low) _gate_port->set_voice_value(context, voice, time, 0.0f); - (*_voices)[voice].state = Voice::FREE; + (*_voices)[voice].state = Voice::State::FREE; } } @@ -332,7 +332,7 @@ NoteNode::all_notes_off(ProcessContext& context, FrameTime time) for (uint32_t i = 0; i < _polyphony; ++i) { _gate_port->set_voice_value(context, i, time, 0.0f); - (*_voices)[i].state = Voice::FREE; + (*_voices)[i].state = Voice::State::FREE; } } @@ -350,7 +350,7 @@ NoteNode::sustain_off(ProcessContext& context, FrameTime time) _sustain = false; for (uint32_t i=0; i < _polyphony; ++i) - if ((*_voices)[i].state == Voice::HOLDING) + if ((*_voices)[i].state == Voice::State::HOLDING) free_voice(context, i, time); } diff --git a/src/server/internals/Note.hpp b/src/server/internals/Note.hpp index e8964c31..027912b6 100644 --- a/src/server/internals/Note.hpp +++ b/src/server/internals/Note.hpp @@ -64,8 +64,8 @@ public: private: /** Key, one for each key on the keyboard */ struct Key { - enum State { OFF, ON_ASSIGNED, ON_UNASSIGNED }; - Key() : state(OFF), voice(0), time(0) {} + enum class State { OFF, ON_ASSIGNED, ON_UNASSIGNED }; + Key() : state(State::OFF), voice(0), time(0) {} State state; uint32_t voice; SampleCount time; @@ -73,8 +73,8 @@ private: /** Voice, one of these always exists for each voice */ struct Voice { - enum State { FREE, ACTIVE, HOLDING }; - Voice() : state(FREE), note(0), time(0) {} + enum class State { FREE, ACTIVE, HOLDING }; + Voice() : state(State::FREE), note(0), time(0) {} State state; uint8_t note; SampleCount time; |