Replaces sfx->getStatus with isPlaying() functi n which is faster
(for #1511).
This commit is contained in:
parent
6dc18a3557
commit
61068c7278
@ -48,7 +48,7 @@ public:
|
||||
virtual SFXManager::SFXStatus getStatus() { return SFXManager::SFX_STOPPED; }
|
||||
virtual void onSoundEnabledBack() {}
|
||||
virtual void setRolloff(float rolloff) {}
|
||||
|
||||
virtual bool isPlaying() { return false; }
|
||||
virtual const SFXBuffer* getBuffer() const { return NULL; }
|
||||
|
||||
}; // DummySFX
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
virtual bool init() = 0;
|
||||
virtual void position(const Vec3 &position) = 0;
|
||||
virtual void setLoop(bool status) = 0;
|
||||
virtual bool isPlaying() = 0;
|
||||
virtual void play() = 0;
|
||||
virtual void reallyPlayNow() = 0;
|
||||
virtual void stop() = 0;
|
||||
|
@ -43,6 +43,7 @@ SFXOpenAL::SFXOpenAL(SFXBuffer* buffer, bool positional, float gain, bool ownsBu
|
||||
m_soundBuffer = buffer;
|
||||
m_soundSource = 0;
|
||||
m_ok = false;
|
||||
m_is_playing = false;
|
||||
m_positional = positional;
|
||||
m_defaultGain = gain;
|
||||
m_loop = false;
|
||||
@ -187,7 +188,8 @@ void SFXOpenAL::stop()
|
||||
{
|
||||
if(!m_ok) return;
|
||||
|
||||
m_loop = false;
|
||||
m_is_playing = false;
|
||||
m_loop = false;
|
||||
alSourcei(m_soundSource, AL_LOOPING, AL_FALSE);
|
||||
alSourceStop(m_soundSource);
|
||||
SFXManager::checkError("stoping");
|
||||
@ -228,6 +230,10 @@ void SFXOpenAL::resume()
|
||||
*/
|
||||
void SFXOpenAL::play()
|
||||
{
|
||||
// Technically the sfx is only playing after the sfx thread starts it,
|
||||
// but for STK this is correct since we don't want to start the same
|
||||
// sfx twice.
|
||||
m_is_playing = true;
|
||||
SFXManager::get()->queue(this);
|
||||
} // play
|
||||
|
||||
@ -250,6 +256,14 @@ void SFXOpenAL::reallyPlayNow()
|
||||
SFXManager::checkError("playing");
|
||||
} // reallyPlayNow
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Returns true if the sound effect is currently playing.
|
||||
*/
|
||||
bool SFXOpenAL::isPlaying()
|
||||
{
|
||||
return m_is_playing;
|
||||
} // isPlaying
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets the position where this sound effects is played.
|
||||
* \param position Position of the sound effect.
|
||||
|
@ -55,6 +55,9 @@ private:
|
||||
the sound source won't be created and we'll be left with no clue when enabling
|
||||
sounds later. */
|
||||
float m_gain;
|
||||
|
||||
/** True when the sfx is currently playing. */
|
||||
bool m_is_playing;
|
||||
|
||||
/** The master gain set in user preferences */
|
||||
float m_master_gain;
|
||||
@ -72,6 +75,7 @@ public:
|
||||
virtual void play();
|
||||
virtual void reallyPlayNow();
|
||||
virtual void setLoop(bool status);
|
||||
virtual bool isPlaying();
|
||||
virtual void stop();
|
||||
virtual void pause();
|
||||
virtual void resume();
|
||||
|
@ -2018,10 +2018,10 @@ void Kart::updatePhysics(float dt)
|
||||
m_skidding->getSkidState() == Skidding::SKID_ACCUMULATE_RIGHT ) &&
|
||||
m_skidding->getGraphicalJumpOffset()==0)
|
||||
{
|
||||
if(m_skid_sound->getStatus() != SFXManager::SFX_PLAYING &&!isWheeless())
|
||||
if(!m_skid_sound->isPlaying() && !isWheeless())
|
||||
m_skid_sound->play();
|
||||
}
|
||||
else if(m_skid_sound->getStatus() == SFXManager::SFX_PLAYING)
|
||||
else if(m_skid_sound->isPlaying())
|
||||
{
|
||||
m_skid_sound->stop();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user