define stubs for accessing the wall clock time (->Backend)
This commit is contained in:
parent
aa01813f52
commit
882bcf07ae
5 changed files with 224 additions and 15 deletions
72
src/backend/real-clock.cpp
Normal file
72
src/backend/real-clock.cpp
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
Timings - timing specifications for a frame quantised data stream
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2012, 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/real-clock.hpp"
|
||||
#include "lib/time/timequant.hpp"
|
||||
|
||||
|
||||
|
||||
namespace backend {
|
||||
|
||||
|
||||
// using lib::time::PQuant;
|
||||
// using lib::time::Time;
|
||||
|
||||
namespace { // hidden local details of the service implementation....
|
||||
|
||||
|
||||
} // (End) hidden service impl details
|
||||
|
||||
|
||||
/** storage for the singleton accessor, holding
|
||||
* an instance of the RealClock service */
|
||||
lib::Singleton<RealClock> RealClock::_clock;
|
||||
|
||||
|
||||
/** Initialise a service to retrieve system time with sufficient precision
|
||||
*/
|
||||
RealClock::RealClock ()
|
||||
{
|
||||
UNIMPLEMENTED ("system clock service");
|
||||
}
|
||||
|
||||
RealClock::~RealClock ()
|
||||
{
|
||||
UNIMPLEMENTED ("disconnect the system clock service");
|
||||
}
|
||||
|
||||
|
||||
|
||||
TimeValue
|
||||
RealClock::readSystemTime()
|
||||
{
|
||||
UNIMPLEMENTED ("access the system clock");
|
||||
gavl_time_t ticksSince1970 = 1261440000000000L;
|
||||
|
||||
ENSURE (ticksSince1970 == Time::limited (ticksSince1970));
|
||||
return TimeValue::buildRaw_(ticksSince1970); // bypassing the limit check
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace backend
|
||||
103
src/backend/real-clock.hpp
Normal file
103
src/backend/real-clock.hpp
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
REAL-CLOCK.hpp - convenience front-end to access the system clock
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2012, 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.
|
||||
|
||||
*/
|
||||
|
||||
/** @file real-clock.hpp
|
||||
** Front-end for simplified access to the current wall clock time.
|
||||
** The implementation relies on Lumiera backend functions to access the
|
||||
** system clock with a sufficient level of precision. The result is
|
||||
** delivered in lumiera's internal \link lib::time::Time time format \endlink
|
||||
**
|
||||
** @todo WIP-WIP-WIP 3/2012
|
||||
** @todo this might be a good candidate also to provide some kind of
|
||||
** translation service, i.e. a grid to anchor a logical time value
|
||||
** with actual running wall clock time
|
||||
**
|
||||
** @see lib/time/timevalue.hpp
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BACKEND_REAL_CLOCK_H
|
||||
#define BACKEND_REAL_CLOCK_H
|
||||
|
||||
|
||||
#include "lib/error.hpp"
|
||||
//#include "lib/handle.hpp"
|
||||
#include "lib/time/timevalue.hpp"
|
||||
#include "lib/singleton.hpp"
|
||||
//#include "proc/engine/buffer-provider.hpp"
|
||||
//#include "lib/iter-source.hpp"
|
||||
//#include "lib/sync.hpp"
|
||||
|
||||
//#include <boost/noncopyable.hpp>
|
||||
//#include <string>
|
||||
//#include <vector>
|
||||
//#include <tr1/memory>
|
||||
//#include <boost/scoped_ptr.hpp>
|
||||
|
||||
//namespace lib {
|
||||
//namespace time{
|
||||
// class Quantiser;
|
||||
// typedef std::tr1::shared_ptr<const Quantiser> PQuant;
|
||||
//}}
|
||||
|
||||
namespace backend {
|
||||
|
||||
using lib::time::Time;
|
||||
using lib::time::TimeValue;
|
||||
//using std::string;
|
||||
|
||||
//using std::vector;
|
||||
//using std::tr1::shared_ptr;
|
||||
//using boost::scoped_ptr;
|
||||
|
||||
|
||||
/**
|
||||
* Convenience frontend to access the current wall clock time
|
||||
*/
|
||||
class RealClock
|
||||
{
|
||||
|
||||
~RealClock ();
|
||||
RealClock ();
|
||||
|
||||
friend class lib::singleton::StaticCreate<RealClock>;
|
||||
|
||||
|
||||
static lib::Singleton<RealClock> _clock;
|
||||
|
||||
public:
|
||||
|
||||
static Time
|
||||
now()
|
||||
{
|
||||
return Time(_clock().readSystemTime());
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
TimeValue readSystemTime();
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace backend
|
||||
#endif
|
||||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "proc/common.hpp"
|
||||
//#include "proc/state.hpp"
|
||||
#include "backend/real-clock.hpp"
|
||||
#include "lib/time/timevalue.hpp"
|
||||
#include "proc/play/timings.hpp"
|
||||
|
||||
|
|
@ -36,11 +37,12 @@
|
|||
namespace proc {
|
||||
namespace engine {
|
||||
|
||||
using backend::RealClock;
|
||||
// using lib::time::TimeSpan;
|
||||
using lib::time::Offset;
|
||||
// using lib::time::FSecs;
|
||||
using lib::time::TimeVar;
|
||||
using lib::time::Time;
|
||||
//
|
||||
// class ExitNode;
|
||||
|
||||
/**
|
||||
|
|
@ -62,7 +64,7 @@ namespace engine {
|
|||
class TimeAnchor
|
||||
{
|
||||
play::Timings timings_;
|
||||
uint64_t anchorPoint_;
|
||||
int64_t anchorPoint_;
|
||||
Time relatedRealTime_;
|
||||
|
||||
Time
|
||||
|
|
@ -80,13 +82,13 @@ namespace engine {
|
|||
deadline = timings.getTimeDue() - engineLatency;
|
||||
break;
|
||||
}
|
||||
return deadline - timings.getOutputLatency();
|
||||
return deadline - timings.outputLatency;
|
||||
}
|
||||
|
||||
|
||||
TimeAnchor (play::Timings timings, Offset engineLatency, uint64_t startFrame)
|
||||
TimeAnchor (play::Timings timings, Offset engineLatency, int64_t startFrame)
|
||||
: timings_(timings)
|
||||
, anchorPoint(startFrame)
|
||||
, anchorPoint_(startFrame)
|
||||
, relatedRealTime_(expectedTimeofArival(timings, engineLatency))
|
||||
{ }
|
||||
|
||||
|
|
@ -104,7 +106,7 @@ namespace engine {
|
|||
* start delay from internals of the engine in this case.
|
||||
*/
|
||||
static TimeAnchor
|
||||
build (play::Timings timings, uint64_t startFrame)
|
||||
build (play::Timings timings, int64_t startFrame)
|
||||
{
|
||||
const boost::rational<uint> DEFAULT_LATENCY_FACTOR (1,3);
|
||||
Offset startDelay = timings.getFrameDurationAt(startFrame) * DEFAULT_LATENCY_FACTOR;
|
||||
|
|
|
|||
|
|
@ -83,8 +83,16 @@ namespace play {
|
|||
Timings::getFrameDurationAt (TimeValue refPoint) const
|
||||
{
|
||||
int64_t frameNr = grid_->gridPoint (refPoint);
|
||||
return getFrameDurationAt(frameNr);
|
||||
}
|
||||
|
||||
|
||||
Duration
|
||||
Timings::getFrameDurationAt (int64_t refFrameNr) const
|
||||
{
|
||||
return Offset (grid_->timeOf(frameNr), grid_->timeOf(frameNr+1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** @remarks the purpose of this function is to support scheduling
|
||||
|
|
@ -98,9 +106,26 @@ namespace play {
|
|||
{
|
||||
return Duration (Time::ANYTIME);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Time
|
||||
Timings::getTimeDue() const
|
||||
{
|
||||
if (TIMEBOUND == playbackUrgency)
|
||||
{
|
||||
UNIMPLEMENTED ("scheduled delivery spec");
|
||||
}
|
||||
else
|
||||
return Time::NEVER;
|
||||
}
|
||||
|
||||
|
||||
Timings
|
||||
Timings::constrainedBy (Timings additionalConditions)
|
||||
{
|
||||
UNIMPLEMENTED ("how to combine timing constraints");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}} // namespace proc::play
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ namespace play {
|
|||
using lib::time::TimeValue;
|
||||
using lib::time::Duration;
|
||||
using lib::time::Offset;
|
||||
using lib::time::Time;
|
||||
//using std::string;
|
||||
|
||||
//using std::vector;
|
||||
|
|
@ -98,6 +99,7 @@ namespace play {
|
|||
|
||||
public:
|
||||
PlaybackUrgency playbackUrgency;
|
||||
Duration outputLatency;
|
||||
|
||||
Timings (FrameRate fps);
|
||||
|
||||
|
|
@ -107,6 +109,7 @@ namespace play {
|
|||
|
||||
Offset getFrameOffsetAt (TimeValue refPoint) const;
|
||||
Duration getFrameDurationAt (TimeValue refPoint) const;
|
||||
Duration getFrameDurationAt (int64_t refFrameNr) const;
|
||||
|
||||
/** the frame spacing and duration remains constant for some time...
|
||||
* @param startPoint looking from that time point into future
|
||||
|
|
@ -114,14 +117,18 @@ namespace play {
|
|||
* to assume unaltered frame dimensions */
|
||||
Duration constantFrameTimingsInterval (TimeValue startPoint) const;
|
||||
|
||||
/** for scheduled time of delivery, which is signalled
|
||||
* by \code playbackUrgency == TIMEBOUND \endcode
|
||||
* @return wall clock time to expect delivery of data corresponding
|
||||
* to \link #getOrigin time axis origin \endlink
|
||||
* @note for other playback urgencies \c Time::NEVER
|
||||
*/
|
||||
Time getTimeDue() const;
|
||||
|
||||
//////////////TODO further accessor functions here
|
||||
|
||||
Timings
|
||||
constrainedBy (Timings additionalConditions)
|
||||
{
|
||||
UNIMPLEMENTED ("how to combine timing constraints");
|
||||
}
|
||||
Timings constrainedBy (Timings additionalConditions);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue