introduce a render engine configuration facade

This commit is contained in:
Fischlurch 2013-01-12 11:17:29 +01:00
parent 18605b0c19
commit e40f3fe97f
4 changed files with 205 additions and 1 deletions

View file

@ -0,0 +1,94 @@
/*
EngineConfig - access point to any kind of engine configuration parameters
Copyright (C) Lumiera.org
2013, Hermann Vosseler <Ichthyostega@web.de>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *****************************************************/
#include "backend/engine/engine-config.h"
#include "lib/time/timevalue.hpp"
#include <boost/rational.hpp>
using boost::rational;
using lib::time::FrameRate;
namespace backend{
namespace engine {
namespace { // Hard wired placeholder settings...
const rational<uint> ONE_THIRD(1,3);
const rational<uint> EIGHTY_PERCENT(8,10);
const Duration DEFAULT_ENGINE_LATENCY = EIGHTY_PERCENT * Duration(1, FrameRate::PAL);
}//(End)hard wired settings
EngineConfig::~EngineConfig() { }
/** storage for the Singleton accessor */
lib::Singleton<EngineConfig> EngineConfig::get;
/** build up a new engine configuration set,
* based on reasonable default values
*
* @warning using hard wired values as of 1/2013
*/
EngineConfig::EngineConfig()
{ }
Duration
EngineConfig::currentEngineLatency() const
{
return DEFAULT_ENGINE_LATENCY;
}
}} // namespace backend::engine
namespace {
using backend::engine::EngineConfig;
// any C adapter functions go here...
}
extern "C" { /* ==== implementation C interface for engine configuration ======= */
gavl_time_t
lumiera_engine_get_latency ()
{
return _raw (EngineConfig::get().currentEngineLatency());
}
}//extern "C"

View file

@ -0,0 +1,108 @@
/*
ENGINE-CONFIG.h - access point to any kind of engine configuration parameters
Copyright (C) Lumiera.org
2013, Hermann Vosseler <Ichthyostega@web.de>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef BACKEND_ENGINE_ENGINE_CONFIG_H
#define BACKEND_ENGINE_ENGINE_CONFIG_H
#include "lib/time.h"
#ifdef __cplusplus /* ============== C++ Interface ================= */
#include "lib/time/timevalue.hpp"
#include "lib/singleton.hpp"
namespace backend{
namespace engine {
using lib::time::Duration;
/**
* Point of access for any kind of engine configuration, setup and performance tweaks.
* Most of these parameters are derived from static system configuration or more focused
* configuration settings within the session, but some values will be updated \em live
* as a result of engine self monitoring. The user of this interface remains unaware
* of this distinction. There is a sub interface (TODO planned 1/2013) for publishing
* statistics changes and monitoring information.
*
* @note while this interface \em exposes configuration, it is decoupled from
* any concerns regarding session and configuration representation.
*
* @todo WIP-WIP as of 1/2013
* @todo anything regarding configuration and session storage
* @todo find out about the degree of locking required. Right now (1/13), there
* is no locking and all values are hard coded. It is conceivable to implement
* the \em access in a lock-free manner (by loosening any guarantee regarding
* the actual time point when a changed setting becomes visible)
*/
class EngineConfig
{
EngineConfig();
~EngineConfig();
friend class lib::singleton::StaticCreate<EngineConfig>;
public:
/** access point to the Engine Interface.
* @internal this is an facade interface for internal use
* by the player. Client code should use the Player.
*/
static lib::Singleton<EngineConfig> get;
//////////////////////////////////////////////////////////////////// TODO: find out about required configuration and tweaking values
/** reasonable guess of the current engine working delay.
* This is the latency to expect when requesting the calculation
* of a typical and average data frame, based on self observation
* in the recent past
* @todo hard wired value as of 1/2013
*/
Duration currentEngineLatency() const;
};
}} // namespace backend::engine
extern "C" {
#endif /* =========================== CL Interface ===================== */
/** guess of the current effective engine calculation delay */
gavl_time_t lumiera_engine_get_latency ();
#ifdef __cplusplus
}
#endif
#endif/*BACKEND_ENGINE_ENGINE_CONFIG_H*/

View file

@ -45,7 +45,7 @@ namespace engine {
public:
///// TODO: find out about the public operations
// note: the play controller lives in the proc-layer,
// but is a subsystem separate of the sesison.
// but is a subsystem separate of the session.
private:

View file

@ -41,6 +41,8 @@
** @see EngineInterface_test
** @see CalcStream_test
** @see proc::play::PlayerService
** @see backend::engine::EngineConfig
**
*/