summaryrefslogtreecommitdiffstats
path: root/src/server/BlockImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/BlockImpl.cpp')
-rw-r--r--src/server/BlockImpl.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp
index 26e83eb8..b4f407c3 100644
--- a/src/server/BlockImpl.cpp
+++ b/src/server/BlockImpl.cpp
@@ -20,20 +20,21 @@
#include "GraphImpl.hpp"
#include "PluginImpl.hpp"
#include "PortImpl.hpp"
+#include "PortType.hpp"
#include "RunContext.hpp"
#include "ThreadManager.hpp"
-#include "lv2/urid/urid.h"
-#include "raul/Array.hpp"
-#include "raul/Symbol.hpp"
+#include <lv2/urid/urid.h>
+#include <raul/Array.hpp>
+#include <raul/Symbol.hpp>
+#include <algorithm>
#include <cassert>
#include <cstdint>
#include <initializer_list>
#include <string>
-namespace ingen {
-namespace server {
+namespace ingen::server {
BlockImpl::BlockImpl(PluginImpl* plugin,
const raul::Symbol& symbol,
@@ -43,10 +44,7 @@ BlockImpl::BlockImpl(PluginImpl* plugin,
: NodeImpl(plugin->uris(), parent, symbol)
, _plugin(plugin)
, _polyphony((polyphonic && parent) ? parent->internal_poly() : 1)
- , _mark(Mark::UNVISITED)
, _polyphonic(polyphonic)
- , _activated(false)
- , _enabled(true)
{
assert(_plugin);
assert(_polyphony > 0);
@@ -204,13 +202,15 @@ BlockImpl::bypass(RunContext& ctx)
}
// Dumb bypass
- for (PortType t : { PortType::AUDIO, PortType::CV, PortType::ATOM }) {
+ for (const PortType t : { PortType::AUDIO, PortType::CV, PortType::ATOM }) {
for (uint32_t i = 0;; ++i) {
- PortImpl* in = nth_port_by_type(i, true, t);
- PortImpl* out = nth_port_by_type(i, false, t);
+ const PortImpl* in = nth_port_by_type(i, true, t);
+ const PortImpl* out = nth_port_by_type(i, false, t);
if (!out) {
- break; // Finished writing all outputs
- } else if (in) {
+ break; // Finished writing all outputs
+ }
+
+ if (in) {
// Copy corresponding input to output
for (uint32_t v = 0; v < _polyphony; ++v) {
out->buffer(v)->copy(ctx, in->buffer(v).get());
@@ -242,13 +242,11 @@ BlockImpl::process(RunContext& ctx)
// Find earliest offset of a value change
SampleCount chunk_end = ctx.nframes();
for (uint32_t i = 0; _ports && i < _ports->size(); ++i) {
- PortImpl* const port = _ports->at(i);
+ const PortImpl* const port = _ports->at(i);
if (port->type() == PortType::CONTROL && port->is_input()) {
const SampleCount o = port->next_value_offset(
offset, ctx.nframes());
- if (o < chunk_end) {
- chunk_end = o;
- }
+ chunk_end = std::min(o, chunk_end);
}
}
@@ -266,7 +264,7 @@ BlockImpl::process(RunContext& ctx)
// Emit control port outputs as events
for (uint32_t i = 0; _ports && i < _ports->size(); ++i) {
- PortImpl* const port = _ports->at(i);
+ const PortImpl* const port = _ports->at(i);
if (port->type() == PortType::CONTROL && port->is_output()) {
// TODO: Only emit events when value has actually changed?
for (uint32_t v = 0; v < _polyphony; ++v) {
@@ -298,5 +296,4 @@ BlockImpl::set_port_buffer(uint32_t, uint32_t, const BufferRef&, SampleCount)
<< " buffer " << buf << " offset " << offset << std::endl;*/
}
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server