1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 10:23:56 +00:00

Add a method to get the time offset from sounds

This commit is contained in:
Chris Robinson 2012-12-12 16:50:35 -08:00
parent 7fd9e1d212
commit 34e36fb852
2 changed files with 18 additions and 0 deletions

View file

@ -95,6 +95,7 @@ public:
virtual void stop();
virtual bool isPlaying();
virtual double getTimeOffset();
virtual void update();
void play();
@ -259,6 +260,11 @@ bool OpenAL_SoundStream::isPlaying()
return !mIsFinished;
}
double OpenAL_SoundStream::getTimeOffset()
{
return 0.0;
}
void OpenAL_SoundStream::update()
{
ALfloat gain = mVolume*mBaseVolume;
@ -348,6 +354,7 @@ public:
virtual void stop();
virtual bool isPlaying();
virtual double getTimeOffset();
virtual void update();
};
@ -396,6 +403,16 @@ bool OpenAL_Sound::isPlaying()
return state==AL_PLAYING || state==AL_PAUSED;
}
double OpenAL_Sound::getTimeOffset()
{
ALfloat t;
alGetSourcef(mSource, AL_SEC_OFFSET, &t);
throwALerror();
return t;
}
void OpenAL_Sound::update()
{
ALfloat gain = mVolume*mBaseVolume;

View file

@ -26,6 +26,7 @@ namespace MWSound
public:
virtual void stop() = 0;
virtual bool isPlaying() = 0;
virtual double getTimeOffset() = 0;
void setPosition(const Ogre::Vector3 &pos) { mPos = pos; }
void setVolume(float volume) { mVolume = volume; }