diff --git a/ChangeLog.txt b/ChangeLog.txt index 77e451f..a000e4a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,12 @@ +* version 1.26 (Potentially unstable multi-threaded version) + + * Added patches to fix a number of multi-threaded issues discovered by shenjoku: + * http://www.ogre3d.org/addonforums/viewtopic.php?f=19&t=30239&p=102725#p102725 + * http://www.ogre3d.org/addonforums/viewtopic.php?f=19&t=30243 + * http://www.ogre3d.org/addonforums/viewtopic.php?f=19&t=30240 + * http://www.ogre3d.org/addonforums/viewtopic.php?f=19&t=30246 + * http://www.ogre3d.org/addonforums/viewtopic.php?f=19&t=30244 + * version 1.25 * Added patches from shenjoku: http://www.ogre3d.org/addonforums/viewtopic.php?f=19&t=30226 diff --git a/OgreOggSoundLib_vc10.suo b/OgreOggSoundLib_vc10.suo index d5d0c77..8332675 100644 Binary files a/OgreOggSoundLib_vc10.suo and b/OgreOggSoundLib_vc10.suo differ diff --git a/include/OgreOggISound.h b/include/OgreOggISound.h index cdd023f..6d4c2a0 100644 --- a/include/OgreOggISound.h +++ b/include/OgreOggISound.h @@ -1,7 +1,7 @@ /** * @file OgreOggISound.h * @author Ian Stangoe -* @version 1.24 +* @version 1.26 * * @section LICENSE * @@ -108,7 +108,8 @@ namespace OgreOggSound SS_NONE, SS_PLAYING, SS_PAUSED, - SS_STOPPED + SS_STOPPED, + SS_DESTROYED }; //!Structure describing an ogg stream @@ -128,10 +129,7 @@ namespace OgreOggSound { public: - - typedef std::vector BufferList; // A list of the IDs of all OpenAL buffers being used by a sound. This is a vector so that it can be passed around as an array to the various OpenAL functions. - typedef Ogre::SharedPtr BufferListPtr; // An Ogre::SharedPtr to the list of buffer IDs. This makes it easier to pass the values to multiple OgreOggISound instances without having - + //! Listener callback /** provides hooks into various sound states. */ @@ -526,10 +524,10 @@ namespace OgreOggSound /** Sets properties of a shared resource. @remarks Sets a number of properties relating to audio of a shared resource. - @param s - OgreOggISound pointer of parent sound. + @param buffer + Pointer to the shared buffer to copy the properties from. */ - void _setSharedProperties(OgreOggISound* s); + void _setSharedProperties(sharedAudioBuffer* buffer); /** Gets properties of a shared resource. @remarks diff --git a/include/OgreOggListener.h b/include/OgreOggListener.h index bf66230..8a00e39 100644 --- a/include/OgreOggListener.h +++ b/include/OgreOggListener.h @@ -1,7 +1,7 @@ /** * @file OgreOggSoundListener.h * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * @@ -81,7 +81,7 @@ namespace OgreOggSound void setPosition(const Ogre::Vector3 &pos); /** Gets the position of the listener. */ - const Ogre::Vector3& getPosition() { return mPosition; } + Ogre::Vector3 getPosition() const; /** Sets the orientation of the listener. @remarks Sets the 3D orientation of the listener. This is a manual method, @@ -104,7 +104,7 @@ namespace OgreOggSound void setOrientation(const Ogre::Quaternion &q); /** Gets the orientation of the listener. */ - Ogre::Vector3 getOrientation() { return Ogre::Vector3(mOrientation[0],mOrientation[1],mOrientation[2]); } + Ogre::Vector3 getOrientation() const; /** Sets sounds velocity. @param vel 3D x/y/z velocity @@ -169,6 +169,14 @@ namespace OgreOggSound private: +#if OGGSOUND_THREADED +# if POCO_THREAD + static Poco::Mutex mMutex; +# else + static boost::recursive_mutex mMutex; +# endif +#endif + /** * Positional variables */ diff --git a/include/OgreOggSound.h b/include/OgreOggSound.h index 3517efe..aee9d34 100644 --- a/include/OgreOggSound.h +++ b/include/OgreOggSound.h @@ -1,7 +1,7 @@ /** * @file OgreOggSound.h * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * diff --git a/include/OgreOggSoundCallback.h b/include/OgreOggSoundCallback.h index ade19bc..ecc7611 100644 --- a/include/OgreOggSoundCallback.h +++ b/include/OgreOggSoundCallback.h @@ -1,7 +1,7 @@ /** * @file OgreOggSoundCallback.h * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * diff --git a/include/OgreOggSoundFactory.h b/include/OgreOggSoundFactory.h index 9bca561..80c7d56 100644 --- a/include/OgreOggSoundFactory.h +++ b/include/OgreOggSoundFactory.h @@ -1,7 +1,7 @@ /** * @file OgreOggSoundFactory.h * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * diff --git a/include/OgreOggSoundManager.h b/include/OgreOggSoundManager.h index 3e70d14..c1d428b 100644 --- a/include/OgreOggSoundManager.h +++ b/include/OgreOggSoundManager.h @@ -1,7 +1,7 @@ /** * @file OgreOggSoundManager.h * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * @@ -627,6 +627,7 @@ namespace OgreOggSound static Poco::Mutex mMutex; # else static boost::recursive_mutex mMutex; + static boost::recursive_mutex mSoundMutex; # endif /** Pushes a sound action request onto the queue @@ -891,6 +892,10 @@ namespace OgreOggSound */ void _destroyListener(); + /** Calculates the distance a sound is from the specified listener position. + */ + static Ogre::Real _calculateDistanceToListener(OgreOggISound * sound, const Ogre::Vector3 & listenerPos); + /** * OpenAL device objects */ diff --git a/include/OgreOggSoundPlugin.h b/include/OgreOggSoundPlugin.h index 6009d86..9f563b3 100644 --- a/include/OgreOggSoundPlugin.h +++ b/include/OgreOggSoundPlugin.h @@ -1,7 +1,7 @@ /** * @file OgreOggSoundPlugin.h * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * diff --git a/include/OgreOggSoundPrereqs.h b/include/OgreOggSoundPrereqs.h index 94d4c7a..a32bf54 100644 --- a/include/OgreOggSoundPrereqs.h +++ b/include/OgreOggSoundPrereqs.h @@ -1,7 +1,7 @@ /** * @file OgreOggSoundPrereqs.h * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * @@ -91,14 +91,25 @@ namespace OgreOggSound { - class OgreOggISound; + typedef std::vector BufferList; // A list of the IDs of all OpenAL buffers being used by a sound. This is a vector so that it can be passed around as an array to the various OpenAL functions. + typedef Ogre::SharedPtr BufferListPtr; // An Ogre::SharedPtr to the list of buffer IDs. This makes it easier to pass the values to multiple OgreOggISound instances without having to manage memory. //! Holds information about a static shared audio buffer. struct sharedAudioBuffer { - ALuint mAudioBuffer; /// OpenAL buffer - unsigned int mRefCount; /// Reference counter - OgreOggISound* mParent; /// Parent OgreOggISound ptr for shared properties + sharedAudioBuffer() : + mAudioBuffer(AL_NONE) + ,mRefCount(0) + ,mBuffers() + ,mPlayTime(0.0) + ,mFormat(AL_NONE) + { } + + ALuint mAudioBuffer; /// OpenAL buffer + unsigned int mRefCount; /// Reference counter + BufferListPtr mBuffers; /// The cached common buffers to use between all sounds using this shared audio buffer. + float mPlayTime; /// The cached play time of the audio buffer. + ALenum mFormat; /// The cached format of the audio buffer. }; typedef std::map SharedBufferList; diff --git a/include/OgreOggSoundRecord.h b/include/OgreOggSoundRecord.h index 1c44a7b..b3f00e3 100644 --- a/include/OgreOggSoundRecord.h +++ b/include/OgreOggSoundRecord.h @@ -1,7 +1,7 @@ /** * @file OgreOggSoundRecord.h * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * diff --git a/include/OgreOggStaticSound.h b/include/OgreOggStaticSound.h index 9d54146..c1f1876 100644 --- a/include/OgreOggStaticSound.h +++ b/include/OgreOggStaticSound.h @@ -1,7 +1,7 @@ /** * @file OgreOggStaticSound.h * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * diff --git a/include/OgreOggStaticWavSound.h b/include/OgreOggStaticWavSound.h index 92e8d13..066a4bf 100644 --- a/include/OgreOggStaticWavSound.h +++ b/include/OgreOggStaticWavSound.h @@ -1,7 +1,7 @@ /** * @file OgreOggStaticWavSound.h * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * diff --git a/include/OgreOggStreamSound.h b/include/OgreOggStreamSound.h index e1f69d3..5700c4c 100644 --- a/include/OgreOggStreamSound.h +++ b/include/OgreOggStreamSound.h @@ -1,7 +1,7 @@ /** * @file OgreOggStreamSound.h * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * diff --git a/include/OgreOggStreamWavSound.h b/include/OgreOggStreamWavSound.h index e9d1ed7..87059ea 100644 --- a/include/OgreOggStreamWavSound.h +++ b/include/OgreOggStreamWavSound.h @@ -1,7 +1,7 @@ /** * @file OgreOggStreamWavSound.h * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * diff --git a/include/apimainpage.txt b/include/apimainpage.txt index df8f5d0..5f1d681 100644 --- a/include/apimainpage.txt +++ b/include/apimainpage.txt @@ -18,7 +18,7 @@ condenses the functionality down to a clean and simple OGRE-fied interface. Its current development status is stable and actively maintained. Current version - is 1.24 (Stable) + is 1.26 So, thanks for checking out the library and I hope it serves as a useful addition to your development tool collection. diff --git a/src/OgreOggISound.cpp b/src/OgreOggISound.cpp index 8dc97f2..bebb44c 100644 --- a/src/OgreOggISound.cpp +++ b/src/OgreOggISound.cpp @@ -1,7 +1,7 @@ /** * @file OgreOggISound.cpp * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * @@ -137,13 +137,17 @@ namespace OgreOggSound format = mFormat; } /*/////////////////////////////////////////////////////////////////*/ - void OgreOggISound::_setSharedProperties(OgreOggISound* s) + void OgreOggISound::_setSharedProperties(sharedAudioBuffer* buffer) { - s->_getSharedProperties(mBuffers, mPlayTime, mFormat); + mBuffers = buffer->mBuffers; + mPlayTime = buffer->mPlayTime; + mFormat = buffer->mFormat; } /*/////////////////////////////////////////////////////////////////*/ void OgreOggISound::play(bool immediate) { + assert(mState != SS_DESTROYED); + #if OGGSOUND_THREADED SoundAction action; action.mSound = mName; @@ -158,6 +162,8 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggISound::stop(bool immediate) { + assert(mState != SS_DESTROYED); + #if OGGSOUND_THREADED SoundAction action; action.mSound = mName; @@ -172,6 +178,8 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggISound::pause(bool immediate) { + assert(mState != SS_DESTROYED); + #if OGGSOUND_THREADED SoundAction action; action.mSound = mName; diff --git a/src/OgreOggListener.cpp b/src/OgreOggListener.cpp index 4ac43ce..4b6558a 100644 --- a/src/OgreOggListener.cpp +++ b/src/OgreOggListener.cpp @@ -1,7 +1,7 @@ /** * @file OgreOggListener.cpp * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * @@ -36,9 +36,24 @@ namespace OgreOggSound { +#if OGGSOUND_THREADED +# ifdef POCO_THREAD + Poco::Mutex OgreOggSound::OgreOggListener::mMutex; +# else + boost::recursive_mutex OgreOggSound::OgreOggListener::mMutex; +# endif +#endif + /*/////////////////////////////////////////////////////////////////*/ void OgreOggListener::setPosition(ALfloat x, ALfloat y, ALfloat z) { +#if OGGSOUND_THREADED +# ifdef POCO_THREAD + Poco::Mutex::ScopedLock l(mMutex); +# else + boost::recursive_mutex::scoped_lock lock(mMutex); +# endif +#endif mPosition.x = x; mPosition.y = y; mPosition.z = z; @@ -47,10 +62,30 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggListener::setPosition(const Ogre::Vector3 &pos) { +#if OGGSOUND_THREADED +# ifdef POCO_THREAD + Poco::Mutex::ScopedLock l(mMutex); +# else + boost::recursive_mutex::scoped_lock lock(mMutex); +# endif +#endif mPosition = pos; alListener3f(AL_POSITION,pos.x,pos.y,pos.z); } /*/////////////////////////////////////////////////////////////////*/ + Ogre::Vector3 OgreOggListener::getPosition() const + { + Ogre::Vector3 result; +#if OGGSOUND_THREADED + mMutex.lock(); +#endif + result = mPosition; +#if OGGSOUND_THREADED + mMutex.unlock(); +#endif + return result; + } + /*/////////////////////////////////////////////////////////////////*/ void OgreOggListener::setVelocity(float velx, float vely, float velz) { mVelocity.x = velx; @@ -67,6 +102,13 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggListener::setOrientation(ALfloat x,ALfloat y,ALfloat z,ALfloat upx,ALfloat upy,ALfloat upz) { +#if OGGSOUND_THREADED +# ifdef POCO_THREAD + Poco::Mutex::ScopedLock l(mMutex); +# else + boost::recursive_mutex::scoped_lock lock(mMutex); +# endif +#endif mOrientation[0] = x; mOrientation[1] = y; mOrientation[2] = z; @@ -78,6 +120,13 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggListener::setOrientation(const Ogre::Quaternion &q) { +#if OGGSOUND_THREADED +# ifdef POCO_THREAD + Poco::Mutex::ScopedLock l(mMutex); +# else + boost::recursive_mutex::scoped_lock lock(mMutex); +# endif +#endif Ogre::Vector3 vDirection = q.zAxis(); Ogre::Vector3 vUp = q.yAxis(); @@ -90,6 +139,20 @@ namespace OgreOggSound alListenerfv(AL_ORIENTATION,mOrientation); } /*/////////////////////////////////////////////////////////////////*/ + Ogre::Vector3 OgreOggListener::getOrientation() const + { + Ogre::Vector3 result; +#if OGGSOUND_THREADED + mMutex.lock(); +#endif + result = Ogre::Vector3(mOrientation[0],mOrientation[1],mOrientation[2]); +#if OGGSOUND_THREADED + mMutex.unlock(); +#endif + + return result; + } + /*/////////////////////////////////////////////////////////////////*/ void OgreOggListener::update() { if(mLocalTransformDirty) diff --git a/src/OgreOggSoundFactory.cpp b/src/OgreOggSoundFactory.cpp index 839e6d8..3ef8ef2 100644 --- a/src/OgreOggSoundFactory.cpp +++ b/src/OgreOggSoundFactory.cpp @@ -1,7 +1,7 @@ /** * @file OgreOggSoundFactory.cpp * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * diff --git a/src/OgreOggSoundManager.cpp b/src/OgreOggSoundManager.cpp index 553b35a..aaac94a 100644 --- a/src/OgreOggSoundManager.cpp +++ b/src/OgreOggSoundManager.cpp @@ -1,7 +1,7 @@ /** * @file OgreOggSoundManager.cpp * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * @@ -57,7 +57,7 @@ namespace OgreOggSound { using namespace Ogre; - const Ogre::String OgreOggSoundManager::OGREOGGSOUND_VERSION_STRING = "OgreOggSound v1.25"; + const Ogre::String OgreOggSoundManager::OGREOGGSOUND_VERSION_STRING = "OgreOggSound v1.26"; /*/////////////////////////////////////////////////////////////////*/ OgreOggSoundManager::OgreOggSoundManager() : @@ -870,8 +870,16 @@ namespace OgreOggSound if (!mSoundsToDestroy->empty() ) { OgreOggISound* s=0; - if ( mSoundsToDestroy->pop(s) ) - _destroySoundImpl(s); + int count=0; + do + { + if ( mSoundsToDestroy->pop(s) ) + { + _destroySoundImpl(s); + count++; + } + } + while(!mSoundsToDestroy->empty() && count<5); } } } @@ -1050,9 +1058,9 @@ namespace OgreOggSound d1 = snd1->getPosition().distance(mListener->getPosition()); if ( sound->isRelativeToListener() ) - d1 = sound->getPosition().length(); + d2 = sound->getPosition().length(); else - d1 = sound->getPosition().distance(mListener->getPosition()); + d2 = sound->getPosition().distance(mListener->getPosition()); // Needs swapping? if ( d1>d2 ) @@ -2143,6 +2151,9 @@ namespace OgreOggSound { // Use shared buffer if available sound->_openImpl(file, buffer); + + // Increment the reference count since this buffer is now being used for another sound. + ++buffer->mRefCount; } // If requested to preBuffer - grab free source and init @@ -2359,6 +2370,14 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggSoundManager::_releaseAll() { + // Clear all of the various containers of sounds. This will make releasing MUCH faster since each sound won't have to + // bother searching for and manually removing themselves from the lists, which really doesn't matter when everything is + // being destroyed. + mSoundsToReactivate.clear(); + mPausedSounds.clear(); + mWaitingSounds.clear(); + mActiveSounds.clear(); + stopAllSounds(); _destroyAllSoundsImpl(); @@ -2526,7 +2545,7 @@ namespace OgreOggSound alDeleteBuffers(1, &f->second->mAudioBuffer); // Delete struct - OGRE_FREE(f->second, Ogre::MEMCATEGORY_GENERAL); + OGRE_DELETE_T(f->second, sharedAudioBuffer, Ogre::MEMCATEGORY_GENERAL); // Remove from list mSharedBuffers.erase(f); @@ -2545,7 +2564,7 @@ namespace OgreOggSound if ( ( f = mSharedBuffers.find(sName) ) == mSharedBuffers.end() ) { // Create struct - sharedAudioBuffer* buf = OGRE_ALLOC_T(sharedAudioBuffer, 1, Ogre::MEMCATEGORY_GENERAL); + sharedAudioBuffer* buf = OGRE_NEW_T(sharedAudioBuffer, Ogre::MEMCATEGORY_GENERAL); // Set buffer buf->mAudioBuffer = buffer; @@ -2553,8 +2572,8 @@ namespace OgreOggSound // Set ref count buf->mRefCount = 1; - // Set parent ptr - buf->mParent = parent; + // Copy the shared information into the buffer so it can be passed around to every other sound that needs it. + parent->_getSharedProperties(buf->mBuffers, buf->mPlayTime, buf->mFormat); // Add to list mSharedBuffers[sName] = buf; diff --git a/src/OgreOggSoundPlugin.cpp b/src/OgreOggSoundPlugin.cpp index 4b35512..c370b6d 100644 --- a/src/OgreOggSoundPlugin.cpp +++ b/src/OgreOggSoundPlugin.cpp @@ -1,7 +1,7 @@ /** * @file OgreOggSoundPlugin.cpp * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * diff --git a/src/OgreOggSoundPluginDllStart.cpp b/src/OgreOggSoundPluginDllStart.cpp index 0825045..c2a50fa 100644 --- a/src/OgreOggSoundPluginDllStart.cpp +++ b/src/OgreOggSoundPluginDllStart.cpp @@ -1,7 +1,7 @@ /** * @file OgreOggSoundPluginDllStart.cpp * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * diff --git a/src/OgreOggSoundRecord.cpp b/src/OgreOggSoundRecord.cpp index e6b56c0..e5a12d7 100644 --- a/src/OgreOggSoundRecord.cpp +++ b/src/OgreOggSoundRecord.cpp @@ -1,7 +1,7 @@ /** * @file OgreOggSoundRecord.cpp * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * diff --git a/src/OgreOggStaticSound.cpp b/src/OgreOggStaticSound.cpp index 3523334..2356c56 100644 --- a/src/OgreOggStaticSound.cpp +++ b/src/OgreOggStaticSound.cpp @@ -1,7 +1,7 @@ /** * @file OgreOggStaticSound.cpp * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * @@ -46,7 +46,7 @@ namespace OgreOggSound ,mAudioName("") { mStream=false; - mBuffers.bind(new std::vector(1, AL_NONE)); + mBuffers.bind(new BufferList(1, AL_NONE)); } /*/////////////////////////////////////////////////////////////////*/ OgreOggStaticSound::~OgreOggStaticSound() @@ -132,7 +132,7 @@ namespace OgreOggSound if ( !buffer ) return; // Set buffer - _setSharedProperties(buffer->mParent); + _setSharedProperties(buffer); // Filename mAudioName = fName; @@ -283,6 +283,8 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggStaticSound::_pauseImpl() { + assert(mState != SS_DESTROYED); + if ( mSource==AL_NONE ) return; alSourcePause(mSource); @@ -295,6 +297,8 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggStaticSound::_playImpl() { + assert(mState != SS_DESTROYED); + if(isPlaying()) return; @@ -316,6 +320,8 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggStaticSound::_stopImpl() { + assert(mState != SS_DESTROYED); + if ( mSource==AL_NONE || isStopped() ) return; alSourceStop(mSource); @@ -329,6 +335,7 @@ namespace OgreOggSound // Mark for destruction if (mTemporary) { + mState = SS_DESTROYED; OgreOggSoundManager::getSingletonPtr()->_destroyTemporarySound(this); } // Give up source immediately if specfied diff --git a/src/OgreOggStaticWavSound.cpp b/src/OgreOggStaticWavSound.cpp index 8adb620..12235f4 100644 --- a/src/OgreOggStaticWavSound.cpp +++ b/src/OgreOggStaticWavSound.cpp @@ -1,7 +1,7 @@ /** * @file OgreOggStaticWavSound.cpp * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * @@ -46,7 +46,7 @@ namespace OgreOggSound mStream=false; mFormatData.mFormat=0; mBufferData.clear(); - mBuffers.bind(new std::vector(1, AL_NONE)); + mBuffers.bind(new BufferList(1, AL_NONE)); } /*/////////////////////////////////////////////////////////////////*/ OgreOggStaticWavSound::~OgreOggStaticWavSound() @@ -214,7 +214,7 @@ namespace OgreOggSound if ( !buffer ) return; // Set buffer - _setSharedProperties(buffer->mParent); + _setSharedProperties(buffer); // Filename mAudioName = fName; @@ -408,6 +408,8 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggStaticWavSound::_pauseImpl() { + assert(mState != SS_DESTROYED); + if ( mSource==AL_NONE ) return; alSourcePause(mSource); @@ -419,6 +421,8 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggStaticWavSound::_playImpl() { + assert(mState != SS_DESTROYED); + if(isPlaying()) return; @@ -439,6 +443,8 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggStaticWavSound::_stopImpl() { + assert(mState != SS_DESTROYED); + if ( mSource==AL_NONE ) return; alSourceStop(mSource); @@ -448,6 +454,7 @@ namespace OgreOggSound if (mTemporary) { + mState = SS_DESTROYED; OgreOggSoundManager::getSingleton()._destroyTemporarySound(this); } // Give up source immediately if specfied diff --git a/src/OgreOggStreamSound.cpp b/src/OgreOggStreamSound.cpp index 2124216..5b1409f 100644 --- a/src/OgreOggStreamSound.cpp +++ b/src/OgreOggStreamSound.cpp @@ -1,7 +1,7 @@ /** * @file OgreOggStreamSound.cpp * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * @@ -45,7 +45,7 @@ namespace OgreOggSound ,mLastOffset(0.f) { mStream=true; - mBuffers.bind(new std::vector(NUM_BUFFERS, AL_NONE)); + mBuffers.bind(new BufferList(NUM_BUFFERS, AL_NONE)); } /*/////////////////////////////////////////////////////////////////*/ OgreOggStreamSound::~OgreOggStreamSound() @@ -503,6 +503,8 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggStreamSound::_pauseImpl() { + assert(mState != SS_DESTROYED); + if(mSource == AL_NONE) return; alSourcePause(mSource); @@ -514,6 +516,8 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggStreamSound::_playImpl() { + assert(mState != SS_DESTROYED); + if (isPlaying()) return; @@ -539,6 +543,8 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggStreamSound::_stopImpl() { + assert(mState != SS_DESTROYED); + if(mSource != AL_NONE) { // Remove audio data from source @@ -549,6 +555,7 @@ namespace OgreOggSound if (mTemporary) { + mState = SS_DESTROYED; OgreOggSoundManager::getSingletonPtr()->_destroyTemporarySound(this); return; } diff --git a/src/OgreOggStreamWavSound.cpp b/src/OgreOggStreamWavSound.cpp index b415434..ed53318 100644 --- a/src/OgreOggStreamWavSound.cpp +++ b/src/OgreOggStreamWavSound.cpp @@ -1,7 +1,7 @@ /** * @file OgreOggStreamWavSound.cpp * @author Ian Stangoe -* @version v1.25 +* @version v1.26 * * @section LICENSE * @@ -44,7 +44,7 @@ namespace OgreOggSound , mStreamEOF(false) , mLastOffset(0.f) { - mBuffers.bind(new std::vector(NUM_BUFFERS, AL_NONE)); + mBuffers.bind(new BufferList(NUM_BUFFERS, AL_NONE)); mFormatData.mFormat=0; mStream = true; } @@ -625,6 +625,8 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggStreamWavSound::_pauseImpl() { + assert(mState != SS_DESTROYED); + if(mSource == AL_NONE) return; alSourcePause(mSource); @@ -636,6 +638,8 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggStreamWavSound::_playImpl() { + assert(mState != SS_DESTROYED); + if(isPlaying()) return; // Grab a source if not already attached @@ -721,6 +725,8 @@ namespace OgreOggSound /*/////////////////////////////////////////////////////////////////*/ void OgreOggStreamWavSound::_stopImpl() { + assert(mState != SS_DESTROYED); + if(mSource != AL_NONE) { // Remove audio data from source @@ -739,6 +745,7 @@ namespace OgreOggSound if (mTemporary) { + mState = SS_DESTROYED; OgreOggSoundManager::getSingleton()._destroyTemporarySound(this); } // Give up source immediately if specfied