Changed float QuicktimeImageStream::getCurrentTime() to double QuicktimeImageStream::getCurrentTime() to keep it consistent with

the type of the virtual function ImageStream::getCurrentTime(), and with this fixing a compile and runtime error.

Changed time variables all to use doubles rather than float to be consist with the change to getCurrentTime().
This commit is contained in:
Robert Osfield
2012-01-23 18:48:18 +00:00
parent fa5100cc2c
commit 76b1c8e20e
4 changed files with 35 additions and 34 deletions

View File

@@ -36,7 +36,7 @@ MovieData::~MovieData()
void MovieData::load(osg::Image* image, std::string afilename, float startTime)
void MovieData::load(osg::Image* image, std::string afilename, double startTime)
{
bool isUrl( osgDB::containsServerAddress(afilename) );
@@ -110,7 +110,7 @@ void MovieData::load(osg::Image* image, std::string afilename, float startTime)
_movieWidth = bounds.right;
_movieHeight = bounds.bottom;
_timescale = (float)GetMovieTimeScale(_movie);
_timescale = GetMovieTimeScale(_movie);
_initImage(image);
if (!_fError) _initGWorldStuff(image);
@@ -118,7 +118,7 @@ void MovieData::load(osg::Image* image, std::string afilename, float startTime)
if (!_fError) {
if ( startTime == 0.0f)
if ( startTime == 0.0)
GoToBeginningOfMovie(_movie);
else {
TimeValue t = (TimeValue) (startTime*_timescale);
@@ -126,7 +126,7 @@ void MovieData::load(osg::Image* image, std::string afilename, float startTime)
}
UpdateMovie(_movie);
SetMovieRate(_movie,0);
SetMovieRate(_movie,0.0);
SetMovieActive(_movie, true);
UpdateMovie(_movie);
MoviesTask(_movie,0);
@@ -219,8 +219,8 @@ void MovieData::_initGWorldStuff(osg::Image * image) {
}
void MovieData::setMovieTime(float atime) {
float time = (atime > getMovieDuration()) ? getMovieDuration() : atime;
void MovieData::setMovieTime(double atime) {
double time = (atime > getMovieDuration()) ? getMovieDuration() : atime;
TimeValue t = (TimeValue) (time * _timescale);
SetMovieTimeValue(_movie,t);
@@ -231,7 +231,7 @@ void MovieData::setMovieTime(float atime) {
}
void MovieData::setMovieRate(float rate) {
void MovieData::setMovieRate(double rate) {
// OSG_ALWAYS << "new movierate: " << rate << " current: " << getMovieRate() << std::endl;
_movieRate = rate;
if ((rate != 0) && (_preRolled == false)) {

View File

@@ -39,27 +39,27 @@
* @param fileName the movie to open
* @param startTime the starttime to begin with
*/
void load(osg::Image* image, std::string fileName, float startTime = 0.0f);
void load(osg::Image* image, std::string fileName, double startTime = 0.0);
/** @return the duration for this movie in seconds */
inline float getMovieDuration() { return GetMovieDuration(_movie)/(float)_timescale;}
inline double getMovieDuration() { return GetMovieDuration(_movie)/_timescale;}
/** @return the current position for this movie in seconds */
inline float getMovieTime() {return GetMovieTime(_movie,NULL)/(float)_timescale; }
inline double getMovieTime() {return GetMovieTime(_movie,NULL)/_timescale; }
/** stes the movietime */
void setMovieTime(float atime);
void setMovieTime(double atime);
/** @return the Movie-handle, to use it with other quicktime-calls */
inline Movie &getMovie() { return _movie; }
/** @return the current movieRate */
inline float getMovieRate() { return Fix2X(GetMovieRate(_movie)); }
inline double getMovieRate() { return Fix2X(GetMovieRate(_movie)); }
/** @return returns the cached movierate, may differ to the real movierate */
inline float getCachedMovieRate() { return _movieRate; }
inline double getCachedMovieRate() { return _movieRate; }
/** sets the MovieRate for this movie */
void setMovieRate(float rate);
void setMovieRate(double rate);
/** sets the volume for the soundtrack of this movie */
void setVolume(float volume) { SetMovieVolume(_movie,(short)(ceil(volume*255.0f)));}
@@ -103,9 +103,9 @@
GWorldPtr _gw;
unsigned int _movieWidth, _movieHeight, _textureWidth, _textureHeight;
float _timescale;
double _timescale;
bool _fError;
float _movieRate;
double _movieRate;
bool _preRolled;
bool _isLooping;

View File

@@ -78,7 +78,7 @@ QuicktimeImageStream::~QuicktimeImageStream()
// Set command
void QuicktimeImageStream::setCmd(ThreadCommand cmd, float rate)
void QuicktimeImageStream::setCmd(ThreadCommand cmd, double rate)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
@@ -112,7 +112,7 @@ void QuicktimeImageStream::load(std::string fileName)
_movieData->load(this, fileName);
_len = _movieData->getMovieDuration();
_current = 0;
_current = 0.0;
}
void QuicktimeImageStream::quit(bool wiatForThreadToExit)
@@ -160,7 +160,7 @@ void QuicktimeImageStream::run()
switch (cmd) {
case THREAD_START: // Start or continue stream
applyLoopingMode();
_movieData->setMovieRate(1.0f);
_movieData->setMovieRate(1.0);
playing = true;
break;
@@ -172,12 +172,12 @@ void QuicktimeImageStream::run()
break;
case THREAD_REWIND:
SetMovieRate(_movieData->getMovie(),0);
SetMovieRate(_movieData->getMovie(),0.0);
GoToBeginningOfMovie(_movieData->getMovie());
break;
case THREAD_FORWARD:
SetMovieRate(_movieData->getMovie(),0);
SetMovieRate(_movieData->getMovie(),0.0);
GoToEndOfMovie(_movieData->getMovie());
break;
@@ -188,15 +188,15 @@ void QuicktimeImageStream::run()
case THREAD_SETRATE:
_movieData->setMovieRate(_currentRate);
playing = (_currentRate != 0.0f);
playing = (_currentRate != 0.0);
break;
case THREAD_CLOSE:
_movieData->setMovieRate(0);
_movieData->setMovieRate(0.0);
break;
case THREAD_QUIT: // TODO
_movieData->setMovieRate(0);
_movieData->setMovieRate(0.0);
OSG_INFO << "QT-ImageStream: quit" << std::endl;
//playing = false;
done = true;

View File

@@ -93,12 +93,12 @@ public:
}
/// jumps to a specific position
void jumpTo(float pos) {
void jumpTo(double pos) {
setCmd(THREAD_SEEK, pos);
}
/// returns the current playing position
inline float getCurrentTime() const { return _current; }
virtual double getCurrentTime() const { return _current; }
/// @return the current moviedata-object
MovieData* getMovieData() { return _movieData; }
@@ -112,7 +112,7 @@ public:
/// Go to a specific position in the stream.
virtual void setReferenceTime(double time)
{
jumpTo(float(time));
jumpTo(time);
}
/// Return the current position in the stream.
virtual double getReferenceTime() const
@@ -124,8 +124,9 @@ public:
// slow down, or go normal speed.
virtual void setTimeMultiplier(double multiplier)
{
setMovieRate(float(multiplier));
setMovieRate(multiplier);
}
virtual double getTimeMultiplier()
{
return 0.0;
@@ -143,10 +144,10 @@ protected:
virtual ~QuicktimeImageStream();
private:
float _lastUpdate;
float _len;
float _current;
float _currentRate;
double _lastUpdate;
double _len;
double _current;
double _currentRate;
MovieData* _movieData;
@@ -162,13 +163,13 @@ private:
THREAD_QUIT
};
ThreadCommand _cmd[NUM_CMD_INDEX];
float _rates[NUM_CMD_INDEX];
double _rates[NUM_CMD_INDEX];
int _wrIndex, _rdIndex;
OpenThreads::Mutex _mutex;
/// Set command.
void setCmd(ThreadCommand cmd, float rate = 0.0f);
void setCmd(ThreadCommand cmd, double rate = 0.0);
/// Get command.
ThreadCommand getCmd();