From 7941865d5d2744282a04fb9a7d085e835343a732 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 19 Mar 2012 01:03:14 +0100 Subject: [PATCH] implement anchor against current system time using CLOCK_REALTIME for now --- SConstruct | 2 +- src/backend/real-clock.cpp | 40 +++++++++------------------------ src/backend/real-clock.hpp | 17 +++++--------- src/proc/engine/dispatcher.cpp | 16 +++++++++++++ src/proc/engine/time-anchor.hpp | 4 +++- src/proc/play/timings.cpp | 3 ++- 6 files changed, 38 insertions(+), 44 deletions(-) diff --git a/SConstruct b/SConstruct index 8fe12e998..16fda2d2f 100644 --- a/SConstruct +++ b/SConstruct @@ -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 diff --git a/src/backend/real-clock.cpp b/src/backend/real-clock.cpp index b651520f0..fc5fa5520 100644 --- a/src/backend/real-clock.cpp +++ b/src/backend/real-clock.cpp @@ -22,46 +22,26 @@ #include "backend/real-clock.hpp" -#include "lib/time/timequant.hpp" +#include 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::_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 diff --git a/src/backend/real-clock.hpp b/src/backend/real-clock.hpp index 3ce89342d..4d1ad49eb 100644 --- a/src/backend/real-clock.hpp +++ b/src/backend/real-clock.hpp @@ -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; - - - static lib::Singleton _clock; public: static Time now() { - return Time(_clock().readSystemTime()); + return Time(_readSystemTime()); } private: - TimeValue readSystemTime(); + static TimeValue _readSystemTime(); }; diff --git a/src/proc/engine/dispatcher.cpp b/src/proc/engine/dispatcher.cpp index 10307282b..12c51d981 100644 --- a/src/proc/engine/dispatcher.cpp +++ b/src/proc/engine/dispatcher.cpp @@ -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) diff --git a/src/proc/engine/time-anchor.hpp b/src/proc/engine/time-anchor.hpp index d5812adf2..b9184af2a 100644 --- a/src/proc/engine/time-anchor.hpp +++ b/src/proc/engine/time-anchor.hpp @@ -109,7 +109,9 @@ namespace engine { build (play::Timings timings, int64_t startFrame) { const boost::rational 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); } diff --git a/src/proc/play/timings.cpp b/src/proc/play/timings.cpp index 564f65d45..d5288b356 100644 --- a/src/proc/play/timings.cpp +++ b/src/proc/play/timings.cpp @@ -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)); }