summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-03-19 18:05:17 +0100
committerDavid Robillard <d@drobilla.net>2017-03-20 02:58:56 +0100
commite1439953c837b2d3d70a3481ba061bf1ba51f286 (patch)
tree6a792f91492b51c4d949b343f3c721cc26d2b939 /src/server
parentef733c3dc0ea9d1c210fce86103fedea73e4dd4a (diff)
downloadingen-e1439953c837b2d3d70a3481ba061bf1ba51f286.tar.gz
ingen-e1439953c837b2d3d70a3481ba061bf1ba51f286.tar.bz2
ingen-e1439953c837b2d3d70a3481ba061bf1ba51f286.zip
Cleanup: Factor out bypass method
Diffstat (limited to 'src/server')
-rw-r--r--src/server/BlockImpl.cpp61
-rw-r--r--src/server/BlockImpl.hpp3
2 files changed, 39 insertions, 25 deletions
diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp
index bdcf1500..3b051fd4 100644
--- a/src/server/BlockImpl.cpp
+++ b/src/server/BlockImpl.cpp
@@ -185,37 +185,48 @@ BlockImpl::pre_process(RunContext& context)
}
void
-BlockImpl::process(RunContext& context)
+BlockImpl::bypass(RunContext& context)
{
- pre_process(context);
+ if (!_ports) {
+ return;
+ }
- if (!_enabled) {
- // Prepare port buffers for reading, converting/mixing if necessary
- for (uint32_t i = 0; _ports && i < _ports->size(); ++i) {
- _ports->at(i)->connect_buffers();
- _ports->at(i)->pre_run(context);
- }
+ // Prepare port buffers for reading, converting/mixing if necessary
+ for (uint32_t i = 0; i < _ports->size(); ++i) {
+ _ports->at(i)->connect_buffers();
+ _ports->at(i)->pre_run(context);
+ }
- // Dumb bypass
- for (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);
- if (!out) {
- break; // Finished writing all outputs
- } else if (in) {
- // Copy corresponding input to output
- for (uint32_t v = 0; v < _polyphony; ++v) {
- out->buffer(v)->copy(context, in->buffer(v).get());
- }
- } else {
- // Output but no corresponding input, clear
- for (uint32_t v = 0; v < _polyphony; ++v) {
- out->buffer(v)->clear();
- }
+ // Dumb bypass
+ for (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);
+ if (!out) {
+ break; // Finished writing all outputs
+ } else if (in) {
+ // Copy corresponding input to output
+ for (uint32_t v = 0; v < _polyphony; ++v) {
+ out->buffer(v)->copy(context, in->buffer(v).get());
+ }
+ } else {
+ // Output but no corresponding input, clear
+ for (uint32_t v = 0; v < _polyphony; ++v) {
+ out->buffer(v)->clear();
}
}
}
+ }
+ post_process(context);
+}
+
+void
+BlockImpl::process(RunContext& context)
+{
+ pre_process(context);
+
+ if (!_enabled) {
+ bypass(context);
post_process(context);
return;
}
diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp
index 2e3e5fcd..701e2188 100644
--- a/src/server/BlockImpl.hpp
+++ b/src/server/BlockImpl.hpp
@@ -121,6 +121,9 @@ public:
/** Run block for an entire process cycle (calls run()). */
virtual void process(RunContext& context);
+ /** Bypass block for an entire process cycle (called from process()). */
+ virtual void bypass(RunContext& context);
+
/** Run block for a portion of process cycle (called from process()). */
virtual void run(RunContext& context) = 0;