jjonj
17-03-2014 21:29:35
I recently had some trouble getting OgreOggSound to work on windows, I had some code that I knew worked on Linux and it was my job to port it over.
My debugging process:
It wasn't working so I started debugging my code and eventually came to the realization that reading the log would be a good idea, and found that I was having the same error message in the log as viewtopic.php?f=19&t=14180 which did not seem to have any solution. So I did what i needed to do and inserted debug printf's into OgreSoundMaanager.cpp but that didn't make me much wiser, so I ended up also inserting debugging printfs into the openAL functions that were called, and I found something wierd in the source code that basically said: If on windows then fail to work.
The wierd code:
In the init function of ogreoggsoundmanager.cpp:251
which calls this code from alError.c:46
Do you see the problem here?
In order to create a "context" in the init function of ogreoggsoundmanager it checks for some errors, that all seems well and good until you look at the getError function of alError.c which checks for a context which obviously haven't been created yet so it always throws an error and the context is never created.
This seems really wierd, and as soon as i removed the error checking code from ogreoggsoundmanager everything worked perfectly. So why I'm curious why things work like this? Whats going wrong?
I've thought of three possible explanations:
My debugging process:
It wasn't working so I started debugging my code and eventually came to the realization that reading the log would be a good idea, and found that I was having the same error message in the log as viewtopic.php?f=19&t=14180 which did not seem to have any solution. So I did what i needed to do and inserted debug printf's into OgreSoundMaanager.cpp but that didn't make me much wiser, so I ended up also inserting debugging printfs into the openAL functions that were called, and I found something wierd in the source code that basically said: If on windows then fail to work.
The wierd code:
In the init function of ogreoggsoundmanager.cpp:251
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
ALenum error = 0;
alGetError();
alcGetIntegerv(NULL, ALC_MINOR_VERSION, sizeof(minorVersion), &minorVersion);
if ((error = alGetError())!=AL_NO_ERROR)
{
switch (error)
{
case AL_INVALID_NAME: { LogManager::getSingleton().logMessage("Invalid Name when attempting: OpenAL Minor Version number", Ogre::LML_CRITICAL); } break;
case AL_INVALID_ENUM: { LogManager::getSingleton().logMessage("Invalid Enum when attempting: OpenAL Minor Version number", Ogre::LML_CRITICAL); } break;
case AL_INVALID_VALUE: { LogManager::getSingleton().logMessage("Invalid Value when attempting: OpenAL Minor Version number", Ogre::LML_CRITICAL);} break;
case AL_INVALID_OPERATION: { LogManager::getSingleton().logMessage("Invalid Operation when attempting: OpenAL Minor Version number", Ogre::LML_CRITICAL); }break;
case AL_OUT_OF_MEMORY: { LogManager::getSingleton().logMessage("Out of memory when attempting: OpenAL Minor Version number", Ogre::LML_CRITICAL); } break;
}
LogManager::getSingleton().logMessage("Unable to get OpenAL Minor Version number", Ogre::LML_CRITICAL);
return false;
}
...
mContext = alcCreateContext(mDevice, attribs);
which calls this code from alError.c:46
AL_API ALenum AL_APIENTRY alGetError(void)
{
ALCcontext *Context;
ALenum errorCode;
Context = GetContextRef();
if(!Context)
{
if(TrapALError)
{
#ifdef _WIN32
if(IsDebuggerPresent())
DebugBreak();
#elif defined(SIGTRAP)
raise(SIGTRAP);
#endif
}
return AL_INVALID_OPERATION;
}
errorCode = ExchangeInt(&Context->LastError, AL_NO_ERROR);
ALCcontext_DecRef(Context);
return errorCode;
}
Do you see the problem here?
In order to create a "context" in the init function of ogreoggsoundmanager it checks for some errors, that all seems well and good until you look at the getError function of alError.c which checks for a context which obviously haven't been created yet so it always throws an error and the context is never created.
This seems really wierd, and as soon as i removed the error checking code from ogreoggsoundmanager everything worked perfectly. So why I'm curious why things work like this? Whats going wrong?
I've thought of three possible explanations:
- The versions of ogreoggsound and openAl aren't compatible, but I'm using versions 1.23 and 1.15.1 respectively which should be compatible from my understanding.
The code is supposed to call the getError function of alc.c which doesn't check for a context, but fails to make the right call somehow. How does this work?
The author has a vendetta against windows users, which I can respect I suppose, but cmon![/list:u]
What am I missing? I'd rather use an unmodified version of ogreoggsoundmanager if possible.
Thanks!