Skip to content

Commit

Permalink
PEGASUS: Fix startFaderSync
Browse files Browse the repository at this point in the history
Since we're not running in multiple threads anymore, we cannot have the fader hold the main thread to itself.
  • Loading branch information
Matthew Hoops committed Sep 25, 2011
1 parent 647c83b commit 4aed723
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
25 changes: 16 additions & 9 deletions engines/pegasus/fader.cpp
Expand Up @@ -31,6 +31,7 @@ namespace Pegasus {
Fader::Fader() {
_currentValue = 0;
_currentFaderMove._numKnots = 0;
_syncMode = false;
}

void Fader::setFaderValue(const uint32 newValue) {
Expand Down Expand Up @@ -85,19 +86,13 @@ void Fader::startFader(const FaderMoveSpec &spec) {

void Fader::startFaderSync(const FaderMoveSpec &spec) {
if (initFaderMove(spec)) {
_syncMode = true;

setFlags(0);
setScale(spec._faderScale);
setSegment(spec._knots[0].knotTime, spec._knots[spec._numKnots - 1].knotTime);
setTime(spec._knots[0].knotTime);
start();

while (isFading())
useIdleTime();

// Once more, for good measure, to make sure that there are no boundary
// condition problems.
useIdleTime();
stopFader();
start();
}
}

Expand Down Expand Up @@ -144,6 +139,18 @@ void Fader::timeChanged(const TimeValue newTime) {
}
}

void Fader::checkCallBacks() {
IdlerTimeBase::checkCallBacks();

if (_syncMode && !isRunning()) {
// Once more, for good measure, to make sure that there are no boundary
// condition problems.
useIdleTime();
stopFader();
_syncMode = false;
}
}

void FaderMoveSpec::makeOneKnotFaderSpec(const uint32 knotValue) {
_numKnots = 1;
_knots[0].knotTime = 0;
Expand Down
3 changes: 3 additions & 0 deletions engines/pegasus/fader.h
Expand Up @@ -89,12 +89,15 @@ class Fader : public IdlerTimeBase {

void getCurrentFaderMove(FaderMoveSpec &spec) { spec = _currentFaderMove; }

virtual void checkCallBacks();

protected:
bool initFaderMove(const FaderMoveSpec &);
virtual void timeChanged(const TimeValue);

uint32 _currentValue;
FaderMoveSpec _currentFaderMove;
bool _syncMode;
};

class FaderAnimation : public DisplayElement, public Fader {
Expand Down

0 comments on commit 4aed723

Please sign in to comment.