started work on offset propagation

This commit is contained in:
nebojsa 2009-11-05 03:05:36 +00:00
parent a4ee67e5ae
commit 405dffb98b
4 changed files with 21 additions and 11 deletions

View file

@ -134,7 +134,7 @@ class ScheduledEventInterface
* a separate thread, and return immediately. * a separate thread, and return immediately.
*/ */
virtual void virtual void
start(void) throw () = 0; start(Ptr<time_duration>::Ref offset) throw () = 0;
/** /**
* The length of the event. * The length of the event.

View file

@ -105,8 +105,9 @@ SchedulerThread :: getCurrentEvent() throw ()
nextEvent = eventContainer->getCurrentEvent(); nextEvent = eventContainer->getCurrentEvent();
if (nextEvent.get()) { if (nextEvent.get()) {
nextEventTime = TimeConversion::now(); //fake these events here so we can preload
nextInitTime.reset(new ptime(*nextEventTime)); nextInitTime.reset(new ptime(*TimeConversion::now() + *granularity));
nextEventTime.reset(new ptime(*nextInitTime + *nextEvent->maxTimeToInitialize()));
nextEventEnd.reset(new ptime(*nextEvent->getScheduledTime() nextEventEnd.reset(new ptime(*nextEvent->getScheduledTime()
+ *nextEvent->eventLength())); + *nextEvent->eventLength()));
debug() << "::getCurrentEvent() - nextInitTime: " debug() << "::getCurrentEvent() - nextInitTime: "
@ -144,12 +145,21 @@ SchedulerThread :: nextStep(Ptr<ptime>::Ref now) throw ()
<< std::endl; << std::endl;
} }
} else if (imminent(now, nextEventTime)) { } else if (imminent(now, nextEventTime)) {
Ptr<time_duration>::Ref timeLeft(new time_duration(*nextEventTime Ptr<time_duration>::Ref timePassed(new time_duration(*now
- *now)); - *nextEvent->getScheduledTime()));
TimeConversion::sleep(timeLeft); Ptr<time_duration>::Ref timeNull(new time_duration(0, 0, 0, 0));
debug() << "::nextStep() - Start [" << *TimeConversion::now() if(*timePassed > *timeNull) {
<< "]" << endl; debug() << "::nextStep() with offset - Start [" << *TimeConversion::now()
nextEvent->start(); << "]" << endl;
nextEvent->start(timePassed);
} else {
Ptr<time_duration>::Ref timeLeft(new time_duration(*nextEventTime
- *now));
TimeConversion::sleep(timeLeft);
debug() << "::nextStep() - Start [" << *TimeConversion::now()
<< "]" << endl;
nextEvent->start(timeNull);
}
currentEvent = nextEvent; currentEvent = nextEvent;
currentEventEnd = nextEventEnd; currentEventEnd = nextEventEnd;
getNextEvent(TimeConversion::now()); getNextEvent(TimeConversion::now());

View file

@ -149,7 +149,7 @@ PlaylistEvent :: deInitialize(void) throw ()
* Initialize the event object. * Initialize the event object.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
PlaylistEvent :: start(void) throw () PlaylistEvent :: start(Ptr<time_duration>::Ref offset) throw ()
{ {
DEBUG_BLOCK DEBUG_BLOCK

View file

@ -207,7 +207,7 @@ class PlaylistEvent : public virtual ScheduledEventInterface
* a separate thread, and return immediately. * a separate thread, and return immediately.
*/ */
virtual void virtual void
start(void) throw (); start(Ptr<time_duration>::Ref offset) throw ();
/** /**
* The length of the event. * The length of the event.