From 9ca5b78d1ad13a54f2649a7ed4287435c6727de6 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 9 Oct 2008 06:06:11 +0000 Subject: BGE bug fix: fix several bugs and inconsistencies in sound actuator: - support stopping of loop sound - support stopping by python - keep state of actuator in sync with audio device. The lack of state sync was causing several other problems: - actuator stop playing the sound - sound chopped before the end - not possible to pause sound --- intern/SoundSystem/intern/SND_Scene.cpp | 13 ++++++++++--- intern/SoundSystem/intern/SND_SoundObject.cpp | 9 ++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'intern') diff --git a/intern/SoundSystem/intern/SND_Scene.cpp b/intern/SoundSystem/intern/SND_Scene.cpp index bbf971ddc87..9d050a81161 100644 --- a/intern/SoundSystem/intern/SND_Scene.cpp +++ b/intern/SoundSystem/intern/SND_Scene.cpp @@ -388,11 +388,18 @@ void SND_Scene::UpdateActiveObects() #endif #ifdef USE_OPENAL // ok, properties Set. now see if it must play - if (pObject->GetPlaystate() == SND_MUST_PLAY) - { + switch (pObject->GetPlaystate()){ + case SND_MUST_PLAY: m_audiodevice->PlayObject(id); pObject->SetPlaystate(SND_PLAYING); - //break; + break; + case SND_MUST_STOP: + RemoveActiveObject(pObject); + break; + case SND_MUST_PAUSE: + m_audiodevice->PauseObject(id); + pObject->SetPlaystate(SND_PAUSED); + break; } #endif diff --git a/intern/SoundSystem/intern/SND_SoundObject.cpp b/intern/SoundSystem/intern/SND_SoundObject.cpp index e514a186e5e..7a244b5090d 100644 --- a/intern/SoundSystem/intern/SND_SoundObject.cpp +++ b/intern/SoundSystem/intern/SND_SoundObject.cpp @@ -91,21 +91,24 @@ SND_SoundObject::~SND_SoundObject() void SND_SoundObject::StartSound() { - m_playstate = SND_MUST_PLAY; + if (m_id >= 0) + m_playstate = SND_MUST_PLAY; } void SND_SoundObject::StopSound() { - m_playstate = SND_MUST_STOP; + if (m_id >= 0) + m_playstate = SND_MUST_STOP; } void SND_SoundObject::PauseSound() { - m_playstate = SND_MUST_PAUSE; + if (m_id >= 0) + m_playstate = SND_MUST_PAUSE; } -- cgit v1.2.3