diff options
Diffstat (limited to 'src/server/RunContext.hpp')
-rw-r--r-- | src/server/RunContext.hpp | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/src/server/RunContext.hpp b/src/server/RunContext.hpp index bc09f7c3..a91a3e17 100644 --- a/src/server/RunContext.hpp +++ b/src/server/RunContext.hpp @@ -26,8 +26,7 @@ #include <memory> #include <thread> -namespace ingen { -namespace server { +namespace ingen::server { class Engine; class PortImpl; @@ -57,7 +56,7 @@ public: * a thread and execute tasks as they become available. */ RunContext(Engine& engine, - Raul::RingBuffer* event_sink, + raul::RingBuffer* event_sink, unsigned id, bool threaded); @@ -103,17 +102,17 @@ public: * cycle (other than the fact that it must be processed in significantly * less time to avoid a dropout when running in real time). */ - inline uint64_t duration() const { + uint64_t duration() const { return static_cast<uint64_t>(_nframes) * 1e6 / _rate; } - inline void locate(FrameTime s, SampleCount nframes) { + void locate(FrameTime s, SampleCount nframes) { _start = s; _end = s + nframes; _nframes = nframes; } - inline void slice(SampleCount offset, SampleCount nframes) { + void slice(SampleCount offset, SampleCount nframes) { _offset = offset; _nframes = nframes; } @@ -129,35 +128,34 @@ public: void join(); - inline Engine& engine() const { return _engine; } - inline Task* task() const { return _task; } - inline unsigned id() const { return _id; } - 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 SampleCount rate() const { return _rate; } - inline bool realtime() const { return _realtime; } + Engine& engine() const { return _engine; } + Task* task() const { return _task; } + unsigned id() const { return _id; } + FrameTime start() const { return _start; } + FrameTime time() const { return _start + _offset; } + FrameTime end() const { return _end; } + SampleCount offset() const { return _offset; } + SampleCount nframes() const { return _nframes; } + SampleCount rate() const { return _rate; } + bool realtime() const { return _realtime; } protected: void run(); - Engine& _engine; ///< Engine we're running in - Raul::RingBuffer* _event_sink; ///< Updates from process context - Task* _task; ///< Currently executing task - std::unique_ptr<std::thread> _thread; ///< Thread (or null for main) - unsigned _id; ///< Context ID - - 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 - SampleCount _rate; ///< Sample rate in Hz - bool _realtime; ///< True iff context is hard realtime + Engine& _engine; ///< Engine we're running in + raul::RingBuffer* _event_sink; ///< Updates from notify() + Task* _task{nullptr}; ///< Currently executing task + std::unique_ptr<std::thread> _thread; ///< Thread (or null for main) + unsigned _id; ///< Context ID + + FrameTime _start{0}; ///< Start frame of this cycle (timeline) + FrameTime _end{0}; ///< End frame of this cycle (timeline) + SampleCount _offset{0}; ///< Offset into data buffers + SampleCount _nframes{0}; ///< Number of frames past offset to process + SampleCount _rate{0}; ///< Sample rate in Hz + bool _realtime{true}; ///< True iff context is hard realtime }; -} // namespace server -} // namespace ingen +} // namespace ingen::server #endif // INGEN_ENGINE_RUNCONTEXT_HPP |