summaryrefslogtreecommitdiffstats
path: root/src/server/RunContext.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-09-11 15:21:25 +0200
committerDavid Robillard <d@drobilla.net>2016-09-11 15:21:25 +0200
commitf3546d49dbd2d673138387a87bc523c26dcece68 (patch)
treeede285a773fc565205f82a2b0a62ebba6ea552e0 /src/server/RunContext.hpp
parentfb2744d4265d26fb98b19689b50d127f32c66eab (diff)
downloadingen-f3546d49dbd2d673138387a87bc523c26dcece68.tar.gz
ingen-f3546d49dbd2d673138387a87bc523c26dcece68.tar.bz2
ingen-f3546d49dbd2d673138387a87bc523c26dcece68.zip
Remove last vestiges of multiple run contexts
Diffstat (limited to 'src/server/RunContext.hpp')
-rw-r--r--src/server/RunContext.hpp119
1 files changed, 119 insertions, 0 deletions
diff --git a/src/server/RunContext.hpp b/src/server/RunContext.hpp
new file mode 100644
index 00000000..803d7829
--- /dev/null
+++ b/src/server/RunContext.hpp
@@ -0,0 +1,119 @@
+/*
+ This file is part of Ingen.
+ Copyright 2007-2016 David Robillard <http://drobilla.net/>
+
+ Ingen is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or any later version.
+
+ Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Ingen. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef INGEN_ENGINE_RUNCONTEXT_HPP
+#define INGEN_ENGINE_RUNCONTEXT_HPP
+
+#include "ingen/Atom.hpp"
+#include "ingen/World.hpp"
+#include "raul/RingBuffer.hpp"
+
+#include "types.hpp"
+
+namespace Ingen {
+namespace Server {
+
+class Engine;
+class PortImpl;
+
+/** Graph execution context.
+ *
+ * This is used to pass whatever information a Node might need to process; such
+ * as the current time, a sink for generated events, etc.
+ *
+ * Note the logical distinction between nframes (jack relative) and start/end
+ * (timeline relative). If transport speed != 1.0, then end-start != nframes
+ * (though currently this is never the case, it may be if ingen incorporates
+ * tempo and varispeed).
+ *
+ * \ingroup engine
+ */
+class RunContext
+{
+public:
+ RunContext(Engine& engine);
+ RunContext(const RunContext& copy);
+
+ virtual ~RunContext();
+
+ /** Return true iff the given port should broadcast its value.
+ *
+ * Whether or not broadcasting is actually done is a per-client property,
+ * this is for use in the audio thread to quickly determine if the
+ * necessary calculations need to be done at all.
+ */
+ bool must_notify(const PortImpl* port) const;
+
+ /** Send a notification from this run context.
+ * @return false on failure (ring is full)
+ */
+ bool notify(LV2_URID key = 0,
+ FrameTime time = 0,
+ PortImpl* port = 0,
+ uint32_t size = 0,
+ LV2_URID type = 0,
+ const void* body = NULL);
+
+ /** Emit pending notifications in some other non-realtime thread. */
+ void emit_notifications(FrameTime end);
+
+ /** Return true iff any notifications are pending. */
+ bool pending_notifications() const { return _event_sink->read_space(); }
+
+ inline void locate(FrameTime s, SampleCount nframes) {
+ _start = s;
+ _end = s + nframes;
+ _nframes = nframes;
+ }
+
+ inline void locate(const RunContext& other) {
+ _start = other._start;
+ _end = other._end;
+ _nframes = other._nframes;
+ }
+
+ inline void slice(SampleCount offset, SampleCount nframes) {
+ _offset = offset;
+ _nframes = nframes;
+ }
+
+ inline Engine& engine() const { return _engine; }
+ inline FrameTime start() const { return _start; }
+ inline FrameTime time() const { return _start + _offset; }
+ inline FrameTime end() const { return _end; }
+ inline SampleCount offset() const { return _offset; }
+ inline SampleCount nframes() const { return _nframes; }
+ inline bool realtime() const { return _realtime; }
+
+protected:
+ const RunContext& operator=(const RunContext& copy) = delete;
+
+ Engine& _engine; ///< Engine we're running in
+
+ Raul::RingBuffer* _event_sink; ///< Port updates from process context
+
+ FrameTime _start; ///< Start frame of this cycle, timeline relative
+ FrameTime _end; ///< End frame of this cycle, timeline relative
+ SampleCount _offset; ///< Offset into data buffers
+ SampleCount _nframes; ///< Number of frames past offset to process
+ bool _realtime; ///< True iff context is hard realtime
+ bool _copy; ///< True iff this is a copy (shared event_sink)
+};
+
+} // namespace Server
+} // namespace Ingen
+
+#endif // INGEN_ENGINE_RUNCONTEXT_HPP