From 667e633e829760b5a1e9591227ec5437cac1995d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 18 Feb 2017 19:29:15 +0100 Subject: Improve parallel analysis and execution algorithms --- ingen/Clock.hpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ingen/EngineBase.hpp | 7 ++++++- ingen/World.hpp | 14 ++++++------- 3 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 ingen/Clock.hpp (limited to 'ingen') diff --git a/ingen/Clock.hpp b/ingen/Clock.hpp new file mode 100644 index 00000000..8071ee1f --- /dev/null +++ b/ingen/Clock.hpp @@ -0,0 +1,58 @@ +/* + This file is part of Ingen. + Copyright 2016-2017 David Robillard + + 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 . +*/ + +#ifndef INGEN_ENGINE_CLOCK_HPP +#define INGEN_ENGINE_CLOCK_HPP + +#ifdef __MACH__ +# include +# include +#endif + +namespace Ingen { + +class Clock { +public: +#ifdef __MACH__ + + Clock() { mach_timebase_info(&_timebase); } + + inline uint64_t now_microseconds() const { + const uint64_t now = mach_absolute_time(); + return now * _timebase.numer / _timebase.denom / 1e3; + } + +private: + mach_timebase_info_data_t _timebase; + +#else + + inline uint64_t now_microseconds() const { + struct timespec time; +# if defined(CLOCK_MONOTONIC_RAW) + clock_gettime(CLOCK_MONOTONIC_RAW, &time); +# else + clock_gettime(CLOCK_MONOTONIC, &time); +# endif + return (uint64_t)time.tv_sec * 1e6 + (uint64_t)time.tv_nsec / 1e3; + } + +#endif +}; + +} // namespace Ingen + +#endif // INGEN_ENGINE_CLOCK_HPP diff --git a/ingen/EngineBase.hpp b/ingen/EngineBase.hpp index a0a20cd9..a57743fe 100644 --- a/ingen/EngineBase.hpp +++ b/ingen/EngineBase.hpp @@ -79,7 +79,12 @@ public: virtual void flush_events(const std::chrono::milliseconds& sleep_ms) = 0; /** - Locate to a given cycle. + Advance audio time by the given number of frames. + */ + virtual void advance(uint32_t nframes) = 0; + + /** + Locate to a given audio position. */ virtual void locate(uint32_t start, uint32_t sample_count) = 0; diff --git a/ingen/World.hpp b/ingen/World.hpp index fc77593a..b0e09b34 100644 --- a/ingen/World.hpp +++ b/ingen/World.hpp @@ -64,20 +64,20 @@ class URIs; class INGEN_API World : public Raul::Noncopyable { public: /** Construct a new Ingen world. - * @param argc Argument count (as in C main()) - * @param argv Argument vector (as in C main()) * @param map LV2 URID map implementation, or NULL to use internal. * @param unmap LV2 URID unmap implementation, or NULL to use internal. * @param log LV2 log implementation, or NULL to use internal. */ - World(int& argc, - char**& argv, - LV2_URID_Map* map, - LV2_URID_Unmap* unmap, - LV2_Log_Log* log); + World(LV2_URID_Map* map, LV2_URID_Unmap* unmap, LV2_Log_Log* log); virtual ~World(); + /** Load configuration from files and command line. + * @param argc Argument count (as in C main()) + * @param argv Argument vector (as in C main()) + */ + virtual void load_configuration(int& argc, char**& argv); + /** Load an Ingen module by name (e.g. "server", "gui", etc.) * @return True on success. */ -- cgit v1.2.1