summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-01-04 01:37:26 +0000
committerDavid Robillard <d@drobilla.net>2014-01-04 01:37:26 +0000
commit4efec8317113579075fb79d2043df234eb4bff38 (patch)
tree1798fbda3b0de89779d2d7cda1610c49bfe1b6c4 /src/server
parent79c6624d7b26c2a1d5c2c244e1f05128aa4063e1 (diff)
downloadingen-4efec8317113579075fb79d2043df234eb4bff38.tar.gz
ingen-4efec8317113579075fb79d2043df234eb4bff38.tar.bz2
ingen-4efec8317113579075fb79d2043df234eb4bff38.zip
Fix port monitor period logic.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5252 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server')
-rw-r--r--src/server/Context.cpp2
-rw-r--r--src/server/PortImpl.cpp21
2 files changed, 14 insertions, 9 deletions
diff --git a/src/server/Context.cpp b/src/server/Context.cpp
index 90e3e184..67a247e1 100644
--- a/src/server/Context.cpp
+++ b/src/server/Context.cpp
@@ -57,7 +57,7 @@ Context::Context(Engine& engine, ID id)
bool
Context::must_notify(const PortImpl* port) const
{
- return port->is_monitored() || _engine.broadcaster()->must_broadcast();
+ return (port->is_monitored() || _engine.broadcaster()->must_broadcast());
}
bool
diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp
index e5a91b32..ca893cc7 100644
--- a/src/server/PortImpl.cpp
+++ b/src/server/PortImpl.cpp
@@ -383,11 +383,18 @@ PortImpl::monitor(Context& context, bool send_now)
return;
}
- Forge& forge = context.engine().world()->forge();
- URIs& uris = context.engine().world()->uris();
+ const uint32_t period = monitor_period(context.engine());
+ _frames_since_monitor += context.nframes();
- LV2_URID key = 0;
- float val = 0.0f;
+ const bool time_to_send = send_now || _frames_since_monitor >= period;
+ if (!time_to_send) {
+ return;
+ }
+
+ Forge& forge = context.engine().world()->forge();
+ URIs& uris = context.engine().world()->uris();
+ LV2_URID key = 0;
+ float val = 0.0f;
switch (_type.id()) {
case PortType::UNKNOWN:
break;
@@ -426,9 +433,8 @@ PortImpl::monitor(Context& context, bool send_now)
}
}
- const uint32_t period = monitor_period(context.engine());
- const bool time_to_send = send_now || _frames_since_monitor >= period;
- if (time_to_send && key && val != _monitor_value) {
+ _frames_since_monitor = _frames_since_monitor % period;
+ if (key && val != _monitor_value) {
if (context.notify(key, context.start(), this,
sizeof(float), forge.Float, &val)) {
/* Update frames since last update to conceptually zero, but keep
@@ -440,7 +446,6 @@ PortImpl::monitor(Context& context, bool send_now)
// Otherwise failure, leave old value and try again next time
}
- _frames_since_monitor += context.nframes();
}
} // namespace Server