summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-08-20 23:11:39 +0000
committerDavid Robillard <d@drobilla.net>2012-08-20 23:11:39 +0000
commit08b62fe47b81117c17cbd7b08210b0a91d104126 (patch)
tree2d21c4f250a6c160686a9ea4fa47ac1132391905 /src
parente7e8876464377e3c222e15783c39af7e411a44a3 (diff)
downloadingen-08b62fe47b81117c17cbd7b08210b0a91d104126.tar.gz
ingen-08b62fe47b81117c17cbd7b08210b0a91d104126.tar.bz2
ingen-08b62fe47b81117c17cbd7b08210b0a91d104126.zip
Replace several assertions with graceful error handling.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4731 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/server/Buffer.cpp2
-rw-r--r--src/server/Buffer.hpp9
-rw-r--r--src/server/BufferFactory.cpp10
-rw-r--r--src/server/InternalPlugin.cpp4
-rw-r--r--src/server/LV2Block.cpp2
-rw-r--r--src/server/LV2Info.cpp4
-rw-r--r--src/server/PreProcessor.cpp4
-rw-r--r--src/server/events/CreateGraph.cpp2
-rw-r--r--src/server/events/Disconnect.cpp9
-rw-r--r--src/server/events/DisconnectAll.cpp7
-rw-r--r--src/server/ingen_engine.cpp1
-rw-r--r--src/server/ingen_lv2.cpp7
-rw-r--r--src/server/internals/Trigger.cpp2
-rw-r--r--src/server/mix.cpp19
14 files changed, 34 insertions, 48 deletions
diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp
index 2c990c02..38a27fa8 100644
--- a/src/server/Buffer.cpp
+++ b/src/server/Buffer.cpp
@@ -16,7 +16,6 @@
#define __STDC_LIMIT_MACROS 1
-#include <assert.h>
#include <math.h>
#include <new>
#include <stdint.h>
@@ -128,7 +127,6 @@ Buffer::port_data(PortType port_type)
case PortType::CONTROL:
case PortType::CV:
case PortType::AUDIO:
- assert(_atom->type == _type);
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/Buffer.hpp b/src/server/Buffer.hpp
index 3a06c3fd..0f237e67 100644
--- a/src/server/Buffer.hpp
+++ b/src/server/Buffer.hpp
@@ -97,10 +97,11 @@ public:
}
/// Audio buffers only
- inline const Sample& value_at(SampleCount offset) const {
- assert(is_audio() || is_control());
- assert(offset < nframes());
- return samples()[offset];
+ inline Sample value_at(SampleCount offset) const {
+ if (is_audio() || is_control()) {
+ return samples()[offset];
+ }
+ return 0.0f;
}
inline void set_block(Sample val,
diff --git a/src/server/BufferFactory.cpp b/src/server/BufferFactory.cpp
index 69cba30b..da459705 100644
--- a/src/server/BufferFactory.cpp
+++ b/src/server/BufferFactory.cpp
@@ -111,7 +111,6 @@ BufferFactory::get(LV2_URID type,
if (!real_time) {
return create(type, capacity);
} else {
- assert(false);
_engine.world()->log().error("Failed to obtain buffer");
return BufferRef();
}
@@ -132,13 +131,12 @@ BufferFactory::create(LV2_URID type, uint32_t capacity)
{
if (capacity == 0) {
capacity = default_size(type);
+ } else if (type == _uris.atom_Float) {
+ capacity = std::max(capacity, (uint32_t)sizeof(LV2_Atom_Float));
+ } else if (type == _uris.atom_Sound) {
+ capacity = std::max(capacity, default_size(_uris.atom_Sound));
}
- assert(type != _uris.atom_Float ||
- capacity >= sizeof(LV2_Atom_Float));
- assert(type != _uris.atom_Sound ||
- capacity >= default_size(_uris.atom_Sound));
-
return BufferRef(new Buffer(*this, type, capacity));
}
diff --git a/src/server/InternalPlugin.cpp b/src/server/InternalPlugin.cpp
index 39e32580..60d3d1a7 100644
--- a/src/server/InternalPlugin.cpp
+++ b/src/server/InternalPlugin.cpp
@@ -14,8 +14,6 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <cassert>
-
#include "ingen/URIs.hpp"
#include "internals/Controller.hpp"
#include "internals/Delay.hpp"
@@ -49,8 +47,6 @@ InternalPlugin::instantiate(BufferFactory& bufs,
GraphImpl* parent,
Engine& engine)
{
- assert(_type == Internal);
-
const SampleCount srate = engine.driver()->sample_rate();
if (uri() == NS_INTERNALS "Controller") {
diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp
index e121f270..b7c1275e 100644
--- a/src/server/LV2Block.cpp
+++ b/src/server/LV2Block.cpp
@@ -54,7 +54,7 @@ LV2Block::LV2Block(LV2Plugin* plugin,
bool polyphonic,
GraphImpl* parent,
SampleRate srate)
-: BlockImpl(plugin, symbol, polyphonic, parent, srate)
+ : BlockImpl(plugin, symbol, polyphonic, parent, srate)
, _lv2_plugin(plugin)
, _instances(NULL)
, _prepared_instances(NULL)
diff --git a/src/server/LV2Info.cpp b/src/server/LV2Info.cpp
index 726dade8..744a30b2 100644
--- a/src/server/LV2Info.cpp
+++ b/src/server/LV2Info.cpp
@@ -16,8 +16,6 @@
#define __STDC_LIMIT_MACROS 1
-#include <assert.h>
-
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
#include "lv2/lv2plug.in/ns/ext/resize-port/resize-port.h"
@@ -51,8 +49,6 @@ LV2Info::LV2Info(Ingen::World* world)
, work_schedule(lilv_new_uri(world->lilv_world(), LV2_WORKER__schedule))
, _world(world)
{
- assert(world);
-
world->lv2_features().add_feature(
SharedPtr<LV2Features::Feature>(new ResizeFeature()));
}
diff --git a/src/server/PreProcessor.cpp b/src/server/PreProcessor.cpp
index dbc88d4f..08d7bb4d 100644
--- a/src/server/PreProcessor.cpp
+++ b/src/server/PreProcessor.cpp
@@ -100,11 +100,11 @@ PreProcessor::process(ProcessContext& context, PostProcessor& dest, bool limit)
if (num_events_processed > 0) {
Event* next = (Event*)last->next();
last->next(NULL);
- assert(!last->next());
dest.append(context, head, last);
_head = next;
- if (!next)
+ if (!next) {
_tail = NULL;
+ }
}
return num_events_processed;
diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp
index 5be9d19e..c16c120c 100644
--- a/src/server/events/CreateGraph.cpp
+++ b/src/server/events/CreateGraph.cpp
@@ -103,8 +103,6 @@ void
CreateGraph::execute(ProcessContext& context)
{
if (_graph) {
- assert(_parent);
- assert(!_path.is_root());
_engine.maid()->dispose(_parent->compiled_graph());
_parent->compiled_graph(_compiled_graph);
}
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index 914e3375..65c5b078 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -149,9 +149,9 @@ Disconnect::pre_process()
_graph = src_block->parent_graph();
}
- assert(_graph);
-
- if (!_graph->has_edge(tail, head)) {
+ if (!_graph) {
+ return Event::pre_process_done(INTERNAL_ERROR, _head_path);
+ } else if (!_graph->has_edge(tail, head)) {
return Event::pre_process_done(NOT_FOUND, _head_path);
}
@@ -192,9 +192,6 @@ Disconnect::Impl::execute(ProcessContext& context, bool set_dst_buffers)
_dst_input_port->recycle_buffers();
}
- assert(_edge);
- assert(port_edge == _edge.get());
-
return true;
}
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index 019193e6..1548c5e1 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -107,7 +107,9 @@ DisconnectAll::pre_process()
_block = dynamic_cast<BlockImpl*>(object);
_port = dynamic_cast<PortImpl*>(object);
- assert((_block || _port) && !(_block && _port));
+ if (!_block && !_port) {
+ return Event::pre_process_done(INTERNAL_ERROR, _path);
+ }
}
// Find set of edges to remove
@@ -120,8 +122,7 @@ DisconnectAll::pre_process()
|| c->head()->parent_block() == _block) {
to_remove.insert(c);
}
- } else {
- assert(_port);
+ } else if (_port) {
if (c->tail() == _port || c->head() == _port) {
to_remove.insert(c);
}
diff --git a/src/server/ingen_engine.cpp b/src/server/ingen_engine.cpp
index d0311cae..b020e28b 100644
--- a/src/server/ingen_engine.cpp
+++ b/src/server/ingen_engine.cpp
@@ -30,7 +30,6 @@ struct IngenEngineModule : public Ingen::Module {
if (!world->interface()) {
world->set_interface(SharedPtr<Interface>(engine->interface(), NullDeleter<Interface>));
}
- assert(world->engine() == engine);
}
};
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 26f239da..ece02cc8 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -295,7 +295,10 @@ public:
}
void flush_to_ui(ProcessContext& context) {
- assert(_ports.size() >= 2);
+ if (_ports.size() < 2) {
+ _engine.log().error("Standard control ports are not present\n");
+ return;
+ }
LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)_ports[1]->buffer();
if (!seq) {
@@ -586,8 +589,6 @@ ingen_connect_port(LV2_Handle instance, uint32_t port, void* data)
LV2Driver* driver = (LV2Driver*)engine->driver();
if (port < driver->ports().size()) {
driver->ports().at(port)->set_buffer(data);
- assert(driver->ports().at(port)->graph_port()->index() == port);
- assert(driver->ports().at(port)->buffer() == data);
} else {
engine->log().error(Raul::fmt("Connect to non-existent port %1%\n")
% port);
diff --git a/src/server/internals/Trigger.cpp b/src/server/internals/Trigger.cpp
index 2c353636..cdc09a98 100644
--- a/src/server/internals/Trigger.cpp
+++ b/src/server/internals/Trigger.cpp
@@ -137,7 +137,7 @@ TriggerNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity
_learning = false;
}
- Sample filter_note = _note_port->buffer(0)->value_at(0);
+ const Sample filter_note = _note_port->buffer(0)->value_at(0);
if (filter_note >= 0.0 && filter_note < 127.0 && (note_num == (uint8_t)filter_note)) {
_gate_port->set_control_value(context, time, 1.0f);
_trig_port->set_control_value(context, time, 1.0f);
diff --git a/src/server/mix.cpp b/src/server/mix.cpp
index c4fbbed5..7ca36557 100644
--- a/src/server/mix.cpp
+++ b/src/server/mix.cpp
@@ -59,22 +59,23 @@ mix(const Context& context,
for (SampleCount i = 0; i < end; ++i) {
out[i] += in[0];
}
- } else { // audio => audio
- assert(srcs[i]->is_audio());
+ } else if (srcs[i]->is_audio()) { // audio => audio
for (SampleCount i = 0; i < end; ++i) {
out[i] += in[i];
}
}
}
- } else {
- assert(dst->is_sequence());
+ } else if (dst->is_sequence()) {
LV2_Atom_Event* iters[num_srcs];
for (uint32_t i = 0; i < num_srcs; ++i) {
- assert(srcs[i]->is_sequence());
- iters[i] = lv2_atom_sequence_begin(
- (const LV2_Atom_Sequence_Body*)LV2_ATOM_BODY_CONST(srcs[i]->atom()));
- if (is_end(srcs[i], iters[i])) {
- iters[i] = NULL;
+ iters[i] = NULL;
+ if (srcs[i]->is_sequence()) {
+ iters[i] = lv2_atom_sequence_begin(
+ (const LV2_Atom_Sequence_Body*)LV2_ATOM_BODY_CONST(
+ srcs[i]->atom()));
+ if (is_end(srcs[i], iters[i])) {
+ iters[i] = NULL;
+ }
}
}