implement anchor against current system time

using CLOCK_REALTIME for now
This commit is contained in:
Fischlurch 2012-03-19 01:03:14 +01:00
parent 9aec2a9806
commit 7941865d5d
6 changed files with 38 additions and 44 deletions

View file

@ -70,7 +70,7 @@ env.Clean ('build', [ 'src/pre.gch' ])
# pick up the targets defined by the sub SConscripts
Import('lumiera plugins tools gui testsuite doxydoc')
build = env.Alias('build', lumiera + plugins + tools +gui)
build = env.Alias('build', lumiera + plugins + tools + gui)
env.Default('build')
# SCons default target

View file

@ -22,46 +22,26 @@
#include "backend/real-clock.hpp"
#include "lib/time/timequant.hpp"
#include <ctime>
namespace backend {
// using lib::time::PQuant;
// using lib::time::Time;
namespace { // hidden local details of the service implementation....
} // (End) hidden service impl details
#define MICRO_TICS_PER_NANOSECOND (1000*1000*1000 / GAVL_TIME_SCALE)
/** 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()
RealClock::_readSystemTime()
{
UNIMPLEMENTED ("access the system clock");
gavl_time_t ticksSince1970 = 1261440000000000L;
timespec now;
clock_gettime(CLOCK_REALTIME, &now);
////////////////////////////////////////////TODO shouldn't that be CLOCK_MONOTONIC ?
////////////////////////////////////////////TODO (what happens on ntp adjustments?)
gavl_time_t ticksSince1970 = now.tv_sec * GAVL_TIME_SCALE
+ now.tv_nsec / MICRO_TICS_PER_NANOSECOND;
ENSURE (ticksSince1970 == Time::limited (ticksSince1970));
return TimeValue::buildRaw_(ticksSince1970); // bypassing the limit check

View file

@ -29,7 +29,9 @@
** @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
** with actual running wall clock time.
** @todo not clear if this becomes some kind of central service (singleton)
** or just a bunch of library routines
**
** @see lib/time/timevalue.hpp
*/
@ -42,7 +44,7 @@
#include "lib/error.hpp"
//#include "lib/handle.hpp"
#include "lib/time/timevalue.hpp"
#include "lib/singleton.hpp"
//#include "lib/singleton.hpp"
//#include "proc/engine/buffer-provider.hpp"
//#include "lib/iter-source.hpp"
//#include "lib/sync.hpp"
@ -76,25 +78,18 @@ namespace backend {
class RealClock
{
~RealClock ();
RealClock ();
friend class lib::singleton::StaticCreate<RealClock>;
static lib::Singleton<RealClock> _clock;
public:
static Time
now()
{
return Time(_clock().readSystemTime());
return Time(_readSystemTime());
}
private:
TimeValue readSystemTime();
static TimeValue _readSystemTime();
};

View file

@ -33,6 +33,22 @@ namespace engine {
Dispatcher::~Dispatcher() { } // emit VTable here....
/** */
Dispatcher::CoordBuilder
Dispatcher::onCalcStream (ModelPort modelPort, uint channel)
{
UNIMPLEMENTED ("build coordinates of frame to render");
}
/** */
FrameCoord
Dispatcher::CoordBuilder::relativeFrameLocation (TimeAnchor refPoint, uint frameCountOffset)
{
UNIMPLEMENTED ("build coordinates of frame to render");
}
/** */
JobTicket&
Dispatcher::accessJobTicket (FrameCoord const& frameID)

View file

@ -109,7 +109,9 @@ namespace engine {
build (play::Timings timings, int64_t startFrame)
{
const boost::rational<uint> DEFAULT_LATENCY_FACTOR (1,3);
Offset startDelay = timings.getFrameDurationAt(startFrame) * DEFAULT_LATENCY_FACTOR;
Offset startDelay(timings.outputLatency
+ timings.getFrameDurationAt(startFrame) * DEFAULT_LATENCY_FACTOR
);
return TimeAnchor (timings,startDelay,startFrame);
}

View file

@ -59,6 +59,7 @@ namespace play {
Timings::Timings (FrameRate fps)
: grid_(buildStandardGridForFramerate(fps))
, playbackUrgency (ASAP)
, outputLatency (Duration::NIL)
{
ENSURE (grid_);
}
@ -90,7 +91,7 @@ namespace play {
Duration
Timings::getFrameDurationAt (int64_t refFrameNr) const
{
return Offset (grid_->timeOf(frameNr), grid_->timeOf(frameNr+1));
return Offset (grid_->timeOf(refFrameNr), grid_->timeOf(refFrameNr + 1));
}