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.
*/
virtual void
start(void) throw () = 0;
start(Ptr<time_duration>::Ref offset) throw () = 0;
/**
* The length of the event.

View File

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

View File

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

View File

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