Crash on stream sound load from zip in threaded mode


03-04-2013 22:03:20

Has found new error. When it trying to play stream sounds from file system directly (without using zip) they played normaly in threaded mode.
But when i try to pack them into zip and read, then i have crash in random time.

I figured, that sound creation calls

soundData = groupManager->openResource(file, mResourceGroupName);

This code is not a thread safe, because in that time other thread work in void OgreOggSoundManager::_updateBuffers() function, that also
works with zip archive (load sounds, stream data and etc.)
So i made small fix:

OgreOggISound* OgreOggSoundManager::_createSoundImpl( const SceneManager& scnMgr,
const std::string& name,
const std::string& file,
bool stream,
bool loop,
bool preBuffer,
bool immediate)
Ogre::ResourceGroupManager* groupManager = 0;
Ogre::String group;
Ogre::DataStreamPtr soundData;
OgreOggISound* sound = 0;

Poco::Mutex::ScopedLock l(mMutex);
boost::recursive_mutex::scoped_lock l(mMutex);

if ( groupManager = Ogre::ResourceGroupManager::getSingletonPtr() )
if ( !mResourceGroupName.empty() )
soundData = groupManager->openResource(file, mResourceGroupName);

Just added mutex lock at the beginning of _createSoundImpl function.

Maybe i'm wrong :) But I haven't crash anymore

Today have figured that all Sound interfaces not a thread safe, when works with sounds in zip archive. For example setPlayPosition function, that changes state in applicaton thread, but this state also changes in OgreOggSound worker thread


19-04-2013 22:51:36

Should be fixed in latest SVN.