summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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