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 # pick up the targets defined by the sub SConscripts
Import('lumiera plugins tools gui testsuite doxydoc') 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') env.Default('build')
# SCons default target # SCons default target

View file

@ -22,46 +22,26 @@
#include "backend/real-clock.hpp" #include "backend/real-clock.hpp"
#include "lib/time/timequant.hpp"
#include <ctime>
namespace backend { namespace backend {
#define MICRO_TICS_PER_NANOSECOND (1000*1000*1000 / GAVL_TIME_SCALE)
// 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 TimeValue
RealClock::readSystemTime() RealClock::_readSystemTime()
{ {
UNIMPLEMENTED ("access the system clock"); timespec now;
gavl_time_t ticksSince1970 = 1261440000000000L; 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)); ENSURE (ticksSince1970 == Time::limited (ticksSince1970));
return TimeValue::buildRaw_(ticksSince1970); // bypassing the limit check return TimeValue::buildRaw_(ticksSince1970); // bypassing the limit check

View file

@ -29,7 +29,9 @@
** @todo WIP-WIP-WIP 3/2012 ** @todo WIP-WIP-WIP 3/2012
** @todo this might be a good candidate also to provide some kind of ** @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 ** 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 ** @see lib/time/timevalue.hpp
*/ */
@ -42,7 +44,7 @@
#include "lib/error.hpp" #include "lib/error.hpp"
//#include "lib/handle.hpp" //#include "lib/handle.hpp"
#include "lib/time/timevalue.hpp" #include "lib/time/timevalue.hpp"
#include "lib/singleton.hpp" //#include "lib/singleton.hpp"
//#include "proc/engine/buffer-provider.hpp" //#include "proc/engine/buffer-provider.hpp"
//#include "lib/iter-source.hpp" //#include "lib/iter-source.hpp"
//#include "lib/sync.hpp" //#include "lib/sync.hpp"
@ -76,25 +78,18 @@ namespace backend {
class RealClock class RealClock
{ {
~RealClock ();
RealClock ();
friend class lib::singleton::StaticCreate<RealClock>;
static lib::Singleton<RealClock> _clock;
public: public:
static Time static Time
now() now()
{ {
return Time(_clock().readSystemTime()); return Time(_readSystemTime());
} }
private: private:
TimeValue readSystemTime(); static TimeValue _readSystemTime();
}; };

View file

@ -33,6 +33,22 @@ namespace engine {
Dispatcher::~Dispatcher() { } // emit VTable here.... 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& JobTicket&
Dispatcher::accessJobTicket (FrameCoord const& frameID) Dispatcher::accessJobTicket (FrameCoord const& frameID)

View file

@ -109,7 +109,9 @@ namespace engine {
build (play::Timings timings, int64_t startFrame) build (play::Timings timings, int64_t startFrame)
{ {
const boost::rational<uint> DEFAULT_LATENCY_FACTOR (1,3); 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); return TimeAnchor (timings,startDelay,startFrame);
} }

View file

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