diff options
author | David Robillard <d@drobilla.net> | 2012-08-10 20:36:36 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-08-10 20:36:36 +0000 |
commit | 762435ea92bbeed0b36afc5fa4303540f3e72ba1 (patch) | |
tree | bb503e6f6d7788f45c398ffb0f35b42f73390a40 | |
parent | 16d7c76a60f8bedd23f1b3fb1f5357b0d548dab2 (diff) | |
download | ingen-762435ea92bbeed0b36afc5fa4303540f3e72ba1.tar.gz ingen-762435ea92bbeed0b36afc5fa4303540f3e72ba1.tar.bz2 ingen-762435ea92bbeed0b36afc5fa4303540f3e72ba1.zip |
Fix various const violations.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4647 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/AtomReader.cpp | 10 | ||||
-rw-r--r-- | src/AtomWriter.cpp | 2 | ||||
-rw-r--r-- | src/client/PluginUI.cpp | 8 | ||||
-rw-r--r-- | src/gui/NodeMenu.cpp | 6 | ||||
-rw-r--r-- | src/gui/ingen_gui_lv2.cpp | 4 | ||||
-rw-r--r-- | src/serialisation/Parser.cpp | 12 | ||||
-rw-r--r-- | src/server/Buffer.hpp | 14 | ||||
-rw-r--r-- | src/server/ControlBindings.cpp | 5 | ||||
-rw-r--r-- | src/server/LV2Node.cpp | 4 | ||||
-rw-r--r-- | src/server/LV2Node.hpp | 2 | ||||
-rw-r--r-- | src/server/events/Get.cpp | 2 | ||||
-rw-r--r-- | src/server/mix.cpp | 6 | ||||
-rw-r--r-- | src/socket/SocketReader.cpp | 2 | ||||
-rw-r--r-- | src/socket/SocketWriter.cpp | 2 | ||||
-rw-r--r-- | wscript | 2 |
15 files changed, 47 insertions, 34 deletions
diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp index f27cd5a5..77c5629e 100644 --- a/src/AtomReader.cpp +++ b/src/AtomReader.cpp @@ -46,7 +46,7 @@ AtomReader::get_atom(const LV2_Atom* in, Raul::Atom& out) % urid->body); } } else { - out = _forge.alloc(in->size, in->type, LV2_ATOM_BODY(in)); + out = _forge.alloc(in->size, in->type, LV2_ATOM_BODY_CONST(in)); } } } @@ -71,9 +71,9 @@ const char* AtomReader::atom_to_uri(const LV2_Atom* atom) { if (atom && atom->type == _uris.atom_URI) { - return (const char*)LV2_ATOM_BODY(atom); + return (const char*)LV2_ATOM_BODY_CONST(atom); } else if (atom && atom->type == _uris.atom_URID) { - return _map.unmap_uri(((LV2_Atom_URID*)atom)->body); + return _map.unmap_uri(((const LV2_Atom_URID*)atom)->body); } else { return NULL; } @@ -259,8 +259,8 @@ AtomReader::write(const LV2_Atom* msg) Raul::warn << "Response message body is not integer" << std::endl; return false; } - _iface.response(((LV2_Atom_Int*)request)->body, - (Ingen::Status)((LV2_Atom_Int*)body)->body, + _iface.response(((const LV2_Atom_Int*)request)->body, + (Ingen::Status)((const LV2_Atom_Int*)body)->body, subject_uri ? subject_uri : ""); } else { Raul::warn << "Unknown object type <" diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp index f8156c89..e310b572 100644 --- a/src/AtomWriter.cpp +++ b/src/AtomWriter.cpp @@ -57,7 +57,7 @@ AtomWriter::AtomWriter(URIMap& map, URIs& uris, AtomSink& sink) void AtomWriter::finish_msg() { - _sink.write((LV2_Atom*)_out.buf); + _sink.write((const LV2_Atom*)_out.buf); _out.len = 0; } diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp index 0f61924a..c6c3d926 100644 --- a/src/client/PluginUI.cpp +++ b/src/client/PluginUI.cpp @@ -53,18 +53,18 @@ lv2_ui_write(SuilController controller, // float (special case, always 0) if (format == 0) { assert(buffer_size == 4); - if (*(float*)buffer == port->value().get_float()) + if (*(const float*)buffer == port->value().get_float()) return; // do nothing (handle stupid plugin UIs that feed back) ui->world()->interface()->set_property( port->path(), uris.ingen_value, - ui->world()->forge().make(*(float*)buffer)); + ui->world()->forge().make(*(const float*)buffer)); } else if (format == uris.atom_eventTransfer.id) { - LV2_Atom* atom = (LV2_Atom*)buffer; + const LV2_Atom* atom = (const LV2_Atom*)buffer; Raul::Atom val = ui->world()->forge().alloc( - atom->size, atom->type, LV2_ATOM_BODY(atom)); + atom->size, atom->type, LV2_ATOM_BODY_CONST(atom)); ui->world()->interface()->set_property(port->path(), uris.ingen_value, val); diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp index afa877b7..cb15342d 100644 --- a/src/gui/NodeMenu.cpp +++ b/src/gui/NodeMenu.cpp @@ -149,7 +149,7 @@ NodeMenu::on_menu_randomize() { _app->interface()->bundle_begin(); - const NodeModel* const nm = (NodeModel*)_object.get(); + const NodeModel* const nm = (const NodeModel*)_object.get(); for (NodeModel::Ports::const_iterator i = nm->ports().begin(); i != nm->ports().end(); ++i) { if ((*i)->is_input() && _app->can_control(i->get())) { float min = 0.0f, max = 1.0f; @@ -174,7 +174,7 @@ NodeMenu::on_menu_disconnect() void NodeMenu::on_preset_activated(const std::string& uri) { - const NodeModel* const node = (NodeModel*)_object.get(); + const NodeModel* const node = (const NodeModel*)_object.get(); const PluginModel* const plugin = dynamic_cast<const PluginModel*>(node->plugin()); LilvNode* port_pred = lilv_new_uri(plugin->lilv_world(), @@ -222,7 +222,7 @@ NodeMenu::on_preset_clicked(const std::string& uri, GdkEventButton* ev) bool NodeMenu::has_control_inputs() { - const NodeModel* const nm = (NodeModel*)_object.get(); + const NodeModel* const nm = (const NodeModel*)_object.get(); for (NodeModel::Ports::const_iterator i = nm->ports().begin(); i != nm->ports().end(); ++i) if ((*i)->is_input() && (*i)->is_numeric()) return true; diff --git a/src/gui/ingen_gui_lv2.cpp b/src/gui/ingen_gui_lv2.cpp index d1eeb6cd..9407a0c7 100644 --- a/src/gui/ingen_gui_lv2.cpp +++ b/src/gui/ingen_gui_lv2.cpp @@ -164,8 +164,8 @@ port_event(LV2UI_Handle handle, uint32_t format, const void* buffer) { - IngenLV2UI* ui = (IngenLV2UI*)handle; - LV2_Atom* atom = (LV2_Atom*)buffer; + IngenLV2UI* ui = (IngenLV2UI*)handle; + const LV2_Atom* atom = (const LV2_Atom*)buffer; ui->reader->write(atom); } diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index f124722c..363e9c15 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -25,10 +25,11 @@ #include <glibmm/ustring.h> #include "ingen/Interface.hpp" -#include "ingen/serialisation/Parser.hpp" #include "ingen/URIMap.hpp" #include "ingen/URIs.hpp" #include "ingen/World.hpp" +#include "ingen/serialisation/Parser.hpp" +#include "lv2/lv2plug.in/ns/ext/atom/atom.h" #include "raul/Atom.hpp" #include "raul/log.hpp" #include "serd/serd.h" @@ -114,15 +115,16 @@ get_properties(Ingen::World* world, out.len = 0; sratom_read(sratom, &forge, world->rdf_world()->c_obj(), model.c_obj(), i.get_object().c_obj()); - LV2_Atom* atom = (LV2_Atom*)out.buf; - Atom atomm; + const LV2_Atom* atom = (const LV2_Atom*)out.buf; + Atom atomm; // FIXME: Don't bloat out all URIs if (atom->type == forge.URID) { atomm = world->forge().alloc_uri( - unmap->unmap(unmap->handle, *(uint32_t*)LV2_ATOM_BODY(atom))); + unmap->unmap(unmap->handle, + ((const LV2_Atom_URID*)atom)->body)); } else { atomm = world->forge().alloc( - atom->size, atom->type, LV2_ATOM_BODY(atom)); + atom->size, atom->type, LV2_ATOM_BODY_CONST(atom)); } props.insert(make_pair(i.get_predicate().to_string(), atomm)); } diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp index d9c9b36f..cb07b09e 100644 --- a/src/server/Buffer.hpp +++ b/src/server/Buffer.hpp @@ -60,7 +60,17 @@ public: uint32_t capacity() const { return _capacity; } /// Audio buffers only - inline Sample* samples() const { + inline const Sample* samples() const { + if (is_control()) { + return (const Sample*)LV2_ATOM_BODY_CONST(atom()); + } else if (is_audio()) { + return (const Sample*)LV2_ATOM_CONTENTS_CONST(LV2_Atom_Vector, atom()); + } + return NULL; + } + + /// Audio buffers only + inline Sample* samples() { if (is_control()) { return (Sample*)LV2_ATOM_BODY(atom()); } else if (is_audio()) { @@ -80,7 +90,7 @@ public: } /// Audio buffers only - inline Sample& value_at(size_t offset) const { + inline const Sample& value_at(size_t offset) const { assert(offset < nframes()); return samples()[offset]; } diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 4a4e1a04..c42002ab 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -70,7 +70,8 @@ ControlBindings::binding_key(const Raul::Atom& binding) const Key key; LV2_Atom* num = NULL; if (binding.type() == uris.atom_Blank) { - LV2_Atom_Object_Body* obj = (LV2_Atom_Object_Body*)binding.get_body(); + const LV2_Atom_Object_Body* obj = (const LV2_Atom_Object_Body*) + binding.get_body(); if (obj->otype == uris.midi_Bender) { key = Key(MIDI_BENDER); } else if (obj->otype == uris.midi_ChannelPressure) { @@ -347,7 +348,7 @@ ControlBindings::bind(ProcessContext& context, Key key) context.notify(uris.ingen_controlBinding, context.start(), _learn_port, - atom->size, atom->type, LV2_ATOM_BODY(atom)); + atom->size, atom->type, LV2_ATOM_BODY_CONST(atom)); _learn_port = NULL; return true; diff --git a/src/server/LV2Node.cpp b/src/server/LV2Node.cpp index 5b2e2487..b3e65555 100644 --- a/src/server/LV2Node.cpp +++ b/src/server/LV2Node.cpp @@ -82,7 +82,7 @@ LV2Node::make_instance(URIs& uris, return SharedPtr<LilvInstance>(); } - LV2_Morph_Interface* morph_iface = (LV2_Morph_Interface*) + const LV2_Morph_Interface* morph_iface = (const LV2_Morph_Interface*) lilv_instance_get_extension_data(inst, LV2_MORPH__interface); for (uint32_t p = 0; p < num_ports(); ++p) { @@ -385,7 +385,7 @@ LV2Node::instantiate(BufferFactory& bufs) // FIXME: Polyphony + worker? if (lilv_plugin_has_feature(plug, info->work_schedule)) { - _worker_iface = (LV2_Worker_Interface*) + _worker_iface = (const LV2_Worker_Interface*) lilv_instance_get_extension_data(instance(0), LV2_WORKER__interface); } diff --git a/src/server/LV2Node.hpp b/src/server/LV2Node.hpp index f4d20658..104c64d9 100644 --- a/src/server/LV2Node.hpp +++ b/src/server/LV2Node.hpp @@ -106,7 +106,7 @@ protected: LV2Plugin* _lv2_plugin; Instances* _instances; Instances* _prepared_instances; - LV2_Worker_Interface* _worker_iface; + const LV2_Worker_Interface* _worker_iface; Responses _responses; SharedPtr<LV2Features::FeatureArray> _features; }; diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp index f2204e67..ae4174bb 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -86,7 +86,7 @@ send_node(Interface* client, const NodeImpl* node) { PluginImpl* const plugin = node->plugin_impl(); if (plugin->type() == Plugin::Patch) { - send_patch(client, (PatchImpl*)node); + send_patch(client, (const PatchImpl*)node); } else { client->put(node->path(), node->properties()); for (size_t j = 0; j < node->num_ports(); ++j) { diff --git a/src/server/mix.cpp b/src/server/mix.cpp index 56cb4326..c340a8a2 100644 --- a/src/server/mix.cpp +++ b/src/server/mix.cpp @@ -61,7 +61,7 @@ static inline bool is_end(const Buffer* buf, LV2_Atom_Event* ev) { return lv2_atom_sequence_is_end( - (LV2_Atom_Sequence_Body*)LV2_ATOM_BODY(buf->atom()), + (const LV2_Atom_Sequence_Body*)LV2_ATOM_BODY_CONST(buf->atom()), buf->atom()->size, ev); } @@ -90,7 +90,7 @@ mix(Context& context, for (uint32_t i = 0; i < num_srcs; ++i) { assert(srcs[i]->type() == uris.atom_Sequence); iters[i] = lv2_atom_sequence_begin( - (LV2_Atom_Sequence_Body*)LV2_ATOM_BODY(srcs[i]->atom())); + (const LV2_Atom_Sequence_Body*)LV2_ATOM_BODY_CONST(srcs[i]->atom())); if (is_end(srcs[i], iters[i])) { iters[i] = NULL; } @@ -110,7 +110,7 @@ mix(Context& context, if (first) { dst->append_event( first->time.frames, first->body.size, first->body.type, - (const uint8_t*)LV2_ATOM_BODY(&first->body)); + (const uint8_t*)LV2_ATOM_BODY_CONST(&first->body)); iters[first_i] = lv2_atom_sequence_next(first); if (is_end(srcs[first_i], iters[first_i])) { diff --git a/src/socket/SocketReader.cpp b/src/socket/SocketReader.cpp index 9d28b405..7599038e 100644 --- a/src/socket/SocketReader.cpp +++ b/src/socket/SocketReader.cpp @@ -168,7 +168,7 @@ SocketReader::_run() sratom_read(sratom, &forge, world->c_obj(), model, _msg_node); // Call _iface methods based on atom content - ar.write((LV2_Atom*)chunk.buf); + ar.write((const LV2_Atom*)chunk.buf); // Reset everything for the next iteration chunk.len = 0; diff --git a/src/socket/SocketWriter.cpp b/src/socket/SocketWriter.cpp index ae815aea..8fa5ee05 100644 --- a/src/socket/SocketWriter.cpp +++ b/src/socket/SocketWriter.cpp @@ -80,7 +80,7 @@ bool SocketWriter::write(const LV2_Atom* msg) { sratom_write(_sratom, &_map.urid_unmap_feature()->urid_unmap, 0, - NULL, NULL, msg->type, msg->size, LV2_ATOM_BODY(msg)); + NULL, NULL, msg->type, msg->size, LV2_ATOM_BODY_CONST(msg)); serd_writer_finish(_writer); return true; } @@ -99,7 +99,7 @@ def configure(conf): define_name='HAVE_POSIX_MEMALIGN', mandatory=False) - autowaf.check_pkg(conf, 'lv2', atleast_version='1.0.7', uselib_store='LV2') + autowaf.check_pkg(conf, 'lv2', atleast_version='1.0.9', uselib_store='LV2') autowaf.define(conf, 'INGEN_VERSION', INGEN_VERSION) |