[Solved]Runtime Error when using "Listener"

kvchung

02-09-2010 09:09:16

Hi
This is my first time using OgreOggSound to play 3d sound

My working Environment:
Ogre 1.71
OpenAL 1.1 SDK
OgreOggSound 1.17 with boost
VC 2008
Windows 7

Here is the problems
1. Runtime error when using "Listener" in Release mode but ok in Debug mode

here is the simplified code modified from OGRE wizard

void test1::createScene(void)
{
#ifdef _DEBUG
mRoot->loadPlugin("OgreOggSound_d");
#else
mRoot->loadPlugin("OgreOggSound");
#endif
Ogre::Entity* ogreHead = mSceneManager->createEntity("Head", "ogrehead.mesh");
Ogre::SceneNode* headNode = mSceneManager->getRootSceneNode()->createChildSceneNode();
headNode->attachObject(ogreHead);

OgreOggSound::OgreOggSoundManager* mSoundManager = OgreOggSound::OgreOggSoundManager::getSingletonPtr();

if (mSoundManager->init())
{
headNode->attachObject(mSoundManager->getListener());

OgreOggSound::OgreOggISound* newSound;
// Create a streamed sound, no looping, no prebuffering
if ( newSound = mSoundManager->createSound("Sound1", "wave3.wav", false, true, true) )
{
newSound->setRolloffFactor(2.f);
newSound->setReferenceDistance(10.f);
newSound->play();
headNode->attachObject(newSound);
}
}

// Set ambient light
mSceneManager->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));

// Create a light
Ogre::Light* l = mSceneManager->createLight("MainLight");
l->setPosition(20,80,50);
}


I think the problem is in the line (not the part of "headNode->")
headNode->attachObject(mSoundManager->getListener());
Because after I delete this line, it works fine in both Release and Debug mode,
but I have no idea how to fix it

2.
When I try to debug, I found something strange in the source code ogreoggsoundmanager.cpp
arround line 336:

if ( !scnMgr )
{
Ogre::SceneManagerEnumerator::SceneManagerIterator it=Ogre::Root::getSingletonPtr()->getSceneManagerIterator();

if ( it.hasMoreElements() )
mSceneMgr = it.getNext();
else
{
OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, "No SceneManager's created - a valid SceneManager is required to create sounds", "OgreOggSoundManager::init()");
return false;
}
}

should there have something like these...?

if ( !scnMgr )
{...}
else
mSceneMg = scnMgr;


thanks for your help!!

stickymango

02-09-2010 10:19:04

headNode->attachObject(mSoundManager->getListener());
Is a listener object being returned from that call?

Thanks for spotting the bug regarding the mSceneMgr pointer, thats fixed now.

[Edit] Just tried your exact sample and I don't get any issues, the only difference being the sound file :?

kvchung

02-09-2010 12:22:06

Hi
I use these instead of that line to debug

Ogre::LogManager::getSingleton().logMessage(mSceneManager->getName(), Ogre::LML_CRITICAL);
Ogre::LogManager::getSingleton().logMessage(mSoundManager->getSceneManager()->getName(), Ogre::LML_CRITICAL);
Ogre::LogManager::getSingleton().logMessage(mSoundManager->getListener()->getName(), Ogre::LML_CRITICAL);


Here is the result:
Release mode:
19:16:38: SceneManagerInstance1
crash

Debug mode:
19:16:38: SceneManagerInstance1
19:16:38: SceneManagerInstance1
19:16:38:

so it seems like something happened to the SoundManager...

stickymango

02-09-2010 12:24:48

Have you tried the latest code?

kvchung

02-09-2010 12:32:48

Do you meen this?
ogreoggsound - Revision 335: /trunk

I'm using ogreoggsound-v1.17.zip from http://sourceforge.net/projects/ogreoggsound/

stickymango

02-09-2010 12:33:41

Ah yes, I mean SVN not the .zip release.

[Edit] I've just uploaded a new .zip fie which is the very latest SVN version now, you can try that if you like.[/Edit]

Can you enable debugging in release and step through the init() function?

kvchung

02-09-2010 12:36:27

ok
it will take some minutes
because I'm using Intel Atom :mrgreen:

kvchung

02-09-2010 14:21:44

I tried the new .zip file and had the same result

and I enabled debugging in release and step through the init() function
there is nothing wrong "inside" init()

at the end of init()

- this 0x065e1ba8 {mMutex={...} mActionsList=0x0259f070 mDelayedActionsList=0x02526958 ...} OgreOggSound::OgreOggSoundManager * const
+ Ogre::Singleton<OgreOggSound::OgreOggSoundManager> {ms_Singleton=0x065e1ba8 } Ogre::Singleton<OgreOggSound::OgreOggSoundManager>
+ OGREOGGSOUND_VERSION_STRING "OgreOggSound v1.17" const std::basic_string<char,std::char_traits<char>,std::allocator<char> >
+ mMutex {...} boost::recursive_mutex
+ mActionsList 0x0259f070 {m_buffer=0x0259f528 m_head=0 m_tail=0 ...} OgreOggSound::LocklessQueue<OgreOggSound::SoundAction> *
+ mDelayedActionsList 0x02526958 {m_buffer=0x0259f850 m_head=0 m_tail=0 ...} OgreOggSound::LocklessQueue<OgreOggSound::SoundAction> *
+ mUpdateThread 0x00b75eb8 {thread_info_mutex={...} thread_info={...} } boost::thread *
mShuttingDown false bool
mNoLock false bool
mDevice 0x003f4548 ALCdevice_struct *
mContext 0x003f45c8 ALCcontext_struct *
mOrigVolume 1.0000000 float
mSoundMap [0]() std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,OgreOggSound::OgreOggISound *,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,OgreOggSound::OgreOggISound *> > >
mActiveSounds [0]() std::list<OgreOggSound::OgreOggISound *,std::allocator<OgreOggSound::OgreOggISound *> >
mPausedSounds [0]() std::list<OgreOggSound::OgreOggISound *,std::allocator<OgreOggSound::OgreOggISound *> >
mSoundsToReactivate [0]() std::list<OgreOggSound::OgreOggISound *,std::allocator<OgreOggSound::OgreOggISound *> >
mWaitingSounds [0]() std::list<OgreOggSound::OgreOggISound *,std::allocator<OgreOggSound::OgreOggISound *> >
soundsToDestroy [0]() std::list<OgreOggSound::OgreOggISound *,std::allocator<OgreOggSound::OgreOggISound *> >
+ mSourcePool [100](124866368,124871056,124873592,124876128,124878664,124881200,124883968,124886504,124889040,124891576,124894112,124896648,124899184,124901952,124904488,124907024,124909560,61736200,61738736,61741272,61743808,61746344,61748880,61751416,61753952,61756488,61759256,61761792,61764328,61766864,61769400,61771936,61774472,61777008,61779808,61782344,61784880,61787416,61789952,61792488,61795024,61797560,...) std::deque<unsigned int,std::allocator<unsigned int> >
+ mEFXSupportList [13]((1,true),(2,false),(3,false),(4,false),(5,false),(6,false),(7,false),(8,false),(9,false),(10,false),(11,false),(12,false),(32768,true)) std::map<int,bool,std::less<int>,std::allocator<std::pair<int const ,bool> > >
mSharedBuffers [0]() std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,OgreOggSound::sharedAudioBuffer *,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,OgreOggSound::sharedAudioBuffer *> > >
+ mDeviceStrings 0x003f3a40 "Generic Software" char *
mNumSources 100 unsigned int
mMaxSources 100 unsigned int
+ mRecorder 0x00000000 {mDevice=??? mContext=??? mCaptureDevice=??? ...} OgreOggSound::OgreOggSoundRecord *
mEFXSupport true bool
alGenEffects 0x073b6740 void (int, unsigned int *)*
alDeleteEffects 0x073b7e10 void (int, unsigned int *)*
alIsEffect 0x073b6900 char (unsigned int)*
alEffecti 0x073b6a10 void (unsigned int, int, int)*
alEffectiv 0x073b6b90 void (unsigned int, int, int *)*
alEffectf 0x073b6950 void (unsigned int, int, float)*
alEffectfv 0x073b6ad0 void (unsigned int, int, float *)*
alGetEffecti 0x073b6c50 void (unsigned int, int, int *)*
alGetEffectiv 0x073b6c50 void (unsigned int, int, int *)*
alGetEffectf 0x073b6d10 void (unsigned int, int, float *)*
alGetEffectfv 0x073b6d10 void (unsigned int, int, float *)*
alGenFilters 0x073b6dd0 void (int, unsigned int *)*
alDeleteFilters 0x073b7f00 void (int, unsigned int *)*
alIsFilter 0x073b6f50 char (unsigned int)*
alFilteri 0x073b7060 void (unsigned int, int, int)*
alFilteriv 0x073b71e0 void (unsigned int, int, int *)*
alFilterf 0x073b6fa0 void (unsigned int, int, float)*
alFilterfv 0x073b7120 void (unsigned int, int, float *)*
alGetFilteri 0x073b72a0 void (unsigned int, int, int *)*
alGetFilteriv 0x073b72a0 void (unsigned int, int, int *)*
alGetFilterf 0x073b7360 void (unsigned int, int, float *)*
alGetFilterfv 0x073b7360 void (unsigned int, int, float *)*
alGenAuxiliaryEffectSlots 0x073b7420 void (int, unsigned int *)*
alDeleteAuxiliaryEffectSlots 0x073b8020 void (int, unsigned int *)*
alIsAuxiliaryEffectSlot 0x073b7710 char (unsigned int)*
alAuxiliaryEffectSloti 0x073b7760 void (unsigned int, int, int)*
alAuxiliaryEffectSlotiv 0x073b84a0 void (unsigned int, int, int *)*
alAuxiliaryEffectSlotf 0x073b8180 void (unsigned int, int, float)*
alAuxiliaryEffectSlotfv 0x073b83d0 void (unsigned int, int, float *)*
alGetAuxiliaryEffectSloti 0x073b7c50 void (unsigned int, int, int *)*
alGetAuxiliaryEffectSlotiv 0x073b7d30 void (unsigned int, int, int *)*
alGetAuxiliaryEffectSlotf 0x073b7b50 void (unsigned int, int, float *)*
alGetAuxiliaryEffectSlotfv 0x073b7b50 void (unsigned int, int, float *)*
mEAXSetBufferMode 0x008e5960 char (int, unsigned int *, int)*
mEAXGetBufferMode 0x00000001 int (unsigned int, int *)*
mEAXSupport true bool
mEAXVersion 2 int
mXRamSupport false bool
mFilterList [0]() std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,unsigned int,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,unsigned int> > >
mEffectList [0]() std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,unsigned int,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,unsigned int> > >
mEffectSlotList [0]() std::deque<unsigned int,std::allocator<unsigned int> >
mNumEffectSlots 1 int
mNumSendsPerSource 1 int
mXRamSize 0 int
mXRamFree 0 int
mXRamAuto 0 int
mXRamHardware 0 int
mXRamAccessible 0 int
mCurrentXRamMode 0 int
mXRamSizeMB 0 int
mXRamFreeMB 1617714536 int
+ mResourceGroupName "" std::basic_string<char,std::char_traits<char>,std::allocator<char> >
+ mSceneMgr 0x006479e8 {mName="SceneManagerInstance1" mRenderQueue=0x00000000 mLastRenderQueueInvocationCustom=false ...} Ogre::SceneManager *
+ mListener 0x0668fd68 {mPosition={...} mVelocity={...} mOrientation=0x0668fe58 ...} OgreOggSound::OgreOggListener *

but when back to createScene()

- mSoundManager 0x065e1ba8 {mActionsList=0x00000000 mDelayedActionsList=0x00000000 mNoLock=false ...} OgreOggSound::OgreOggSoundManager *
Ogre::Singleton<OgreOggSound::OgreOggSoundManager> {...} Ogre::Singleton<OgreOggSound::OgreOggSoundManager>
mActionsList 0x00000000 OgreOggSound::LocklessQueue<OgreOggSound::SoundAction> *
mDelayedActionsList 0x00000000 OgreOggSound::LocklessQueue<OgreOggSound::SoundAction> *
mNoLock false bool
mDevice 0x00000000 ALCdevice_struct *
mContext 0x0259f070 ALCcontext_struct *
mOrigVolume 1.5458596e-037 float
+ mSoundMap [1617714536](...) std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,OgreOggSound::OgreOggISound *,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,OgreOggSound::OgreOggISound *> > >
+ mActiveSounds [9210312](...) std::list<OgreOggSound::OgreOggISound *,std::allocator<OgreOggSound::OgreOggISound *> >
mPausedSounds [0]() std::list<OgreOggSound::OgreOggISound *,std::allocator<OgreOggSound::OgreOggISound *> >
+ mSoundsToReactivate [29521512](...) std::list<OgreOggSound::OgreOggISound *,std::allocator<OgreOggSound::OgreOggISound *> >
+ mWaitingSounds [1](...) std::list<OgreOggSound::OgreOggISound *,std::allocator<OgreOggSound::OgreOggISound *> >
+ soundsToDestroy [1617714536](...) std::list<OgreOggSound::OgreOggISound *,std::allocator<OgreOggSound::OgreOggISound *> >
+ mSourcePool [1](...,...) std::deque<unsigned int,std::allocator<unsigned int> >
+ mEFXSupportList [29521080](...) std::map<int,bool,std::less<int>,std::allocator<std::pair<int const ,bool> > >
mSharedBuffers [0]() std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,OgreOggSound::sharedAudioBuffer *,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,OgreOggSound::sharedAudioBuffer *> > >
+ mDeviceStrings 0x606c5d68 " tJ`pqJ`pJ`..\..\..\..\OgreMain\src\OgreScriptLexer.cpp" char *
mNumSources 29520936 unsigned int
mMaxSources 39133800 unsigned int
+ mRecorder 0x00000000 {mDevice=??? mContext=??? mCaptureDevice=??? ...} OgreOggSound::OgreOggSoundRecord *
mEFXSupport true bool
alGenEffects 0x00000064 void (int, unsigned int *)*
alDeleteEffects 0x00000064 void (int, unsigned int *)*
alIsEffect 0x00000000 char (unsigned int)*
alEffecti 0x00000001 void (unsigned int, int, int)*
alEffectiv 0x073b6740 void (unsigned int, int, int *)*
alEffectf 0x073b7e10 void (unsigned int, int, float)*
alEffectfv 0x073b6900 void (unsigned int, int, float *)*
alGetEffecti 0x073b6a10 void (unsigned int, int, int *)*
alGetEffectiv 0x073b6b90 void (unsigned int, int, int *)*
alGetEffectf 0x073b6950 void (unsigned int, int, float *)*
alGetEffectfv 0x073b6ad0 void (unsigned int, int, float *)*
alGenFilters 0x073b6c50 void (int, unsigned int *)*
alDeleteFilters 0x073b6c50 void (int, unsigned int *)*
alIsFilter 0x073b6d10 char (unsigned int)*
alFilteri 0x073b6d10 void (unsigned int, int, int)*
alFilteriv 0x073b6dd0 void (unsigned int, int, int *)*
alFilterf 0x073b7f00 void (unsigned int, int, float)*
alFilterfv 0x073b6f50 void (unsigned int, int, float *)*
alGetFilteri 0x073b7060 void (unsigned int, int, int *)*
alGetFilteriv 0x073b71e0 void (unsigned int, int, int *)*
alGetFilterf 0x073b6fa0 void (unsigned int, int, float *)*
alGetFilterfv 0x073b7120 void (unsigned int, int, float *)*
alGenAuxiliaryEffectSlots 0x073b72a0 void (int, unsigned int *)*
alDeleteAuxiliaryEffectSlots 0x073b72a0 void (int, unsigned int *)*
alIsAuxiliaryEffectSlot 0x073b7360 char (unsigned int)*
alAuxiliaryEffectSloti 0x073b7360 void (unsigned int, int, int)*
alAuxiliaryEffectSlotiv 0x073b7420 void (unsigned int, int, int *)*
alAuxiliaryEffectSlotf 0x073b8020 void (unsigned int, int, float)*
alAuxiliaryEffectSlotfv 0x073b7710 void (unsigned int, int, float *)*
alGetAuxiliaryEffectSloti 0x073b7760 void (unsigned int, int, int *)*
alGetAuxiliaryEffectSlotiv 0x073b84a0 void (unsigned int, int, int *)*
alGetAuxiliaryEffectSlotf 0x073b8180 void (unsigned int, int, float *)*
alGetAuxiliaryEffectSlotfv 0x073b83d0 void (unsigned int, int, float *)*
mEAXSetBufferMode 0x073b7c50 char (int, unsigned int *, int)*
mEAXGetBufferMode 0x073b7d30 int (unsigned int, int *)*
mEAXSupport true bool
mEAXVersion 121338704 int
mXRamSupport true bool
+ mFilterList [1617714536](...) std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,unsigned int,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,unsigned int> > >
+ mEffectList [1](...) std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,unsigned int,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,unsigned int> > >
+ mEffectSlotList [29520000](...,...) std::deque<unsigned int,std::allocator<unsigned int> >
mNumEffectSlots 0 int
mNumSendsPerSource 0 int
mXRamSize 0 int
mXRamFree 0 int
mXRamAuto 1 int
mXRamHardware 1 int
mXRamAccessible 0 int
mCurrentXRamMode 0 int
mXRamSizeMB 0 int
mXRamFreeMB 0 int
+ mResourceGroupName "" std::basic_string<char,std::char_traits<char>,std::allocator<char> >
+ mSceneMgr 0x00000000 {mName={...} mRenderQueue=??? mLastRenderQueueInvocationCustom=??? ...} Ogre::SceneManager *
+ mListener 0x606c5d68 {mPosition={...} mVelocity={...} mOrientation=0x606c5e58 ...} OgreOggSound::OgreOggListener *



looks like memory had been modified
or init() had not exactly change the variables?
but I dont know why

stickymango

03-09-2010 10:34:42

I've identified and fixed the issue now (I hope).

I can confirm I experienced your issue with the latest version of the code and it seems that its now functioning correctly, looks like an issue with my #defines for adding BOOST/POCO support somehow corrupted things :?

If you can, take a copy of the latest SVN and check to see if this issue is resolved.

HTH

kvchung

03-09-2010 18:22:58

It works!!
thank you very mush :D

stickymango

03-09-2010 20:40:42

Excellent, great news! :D