[Solved]Linux troubles

paran01d

05-02-2010 21:59:31

Hey,
Im fairly new to ogre dev (stopped and started with bits over the years) and therefore have been following the Create a shoot em up tutorial to get to grips with everything,
that tutorial uses fmod for sound which I couldn't get to work on my Karmic Ubuntu (binaries yuck). So long story short I found out that this is the lib to use for sound now and set it up,
though ive had a few problems on the way using OgreOggSound with Linux so thought id share. First off the OpenAL soft package thats in the Karmic apt repositories doesnt work, it seems to hang
at the device detection stage, getting and building the latest OpenAL soft stops it hanging at this step, though theres a few bugs in ogreoggsoundmanger.cpp that stops it working further.

Heres the output of svn diff, the first bit gets the version detection to work buy creating a NULL device as opposed to using NULL (this could be just a linux openal soft thing). And the second, that took me a few
days of tearing my hair our till I saw the obviousness of it, cuts down a windows #if so that the OpenAL context is now created on othe rplatforms than just Linux.


--- ogreoggsoundmanager.cpp (revision 274)
+++ ogreoggsoundmanager.cpp (working copy)
@@ -195,16 +195,19 @@

int majorVersion;
int minorVersion;
+ ALCdevice *device = alcOpenDevice(NULL);

// Version Info
- alcGetIntegerv(NULL, ALC_MAJOR_VERSION, sizeof(majorVersion), &majorVersion);
- if (alGetError())
+ alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(majorVersion), &majorVersion);
+ ALCenum error = alcGetError(device);
+ if (error != ALC_NO_ERROR)
{
LogManager::getSingleton().logMessage("Unable to get OpenAL Major Version number", Ogre::LML_CRITICAL);
return false;
}
- alcGetIntegerv(NULL, ALC_MINOR_VERSION, sizeof(minorVersion), &minorVersion);
- if (alGetError())
+ alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(minorVersion), &minorVersion);
+ error = alcGetError(device);
+ if (error != ALC_NO_ERROR)
{
LogManager::getSingleton().logMessage("Unable to get OpenAL Minor Version number", Ogre::LML_CRITICAL);
return false;
@@ -252,6 +255,9 @@

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
ALint attribs[2] = {ALC_MAX_AUXILIARY_SENDS, 4};
+#else
+ ALint attribs[1] = {4};
+#endif

mContext = alcCreateContext(mDevice, attribs);
if (!mContext)
@@ -267,7 +273,6 @@
Ogre::LogManager::getSingletonPtr()->logMessage("OgreOggSoundManager::init() ERROR - Unable to set context", Ogre::LML_CRITICAL);
return false;
}
-#endif

_checkFeatureSupport();


Also to note that in your own project you need to link with the lib vorbisfile as well as the other libs, unfortunately this doesn't show up with pkg-config as a dependency so i just grafted it in manually to my CMakeLists.

thanks for the great lib..


paran01d

stickymango

06-02-2010 16:58:09

Thanks for the great detective work!!

I don't have access to a linux box at present so have been relying on users to fill me in on any problems with that side of things, thanks!

I'll try and add this to the core to ease compiling on linux.

Reyssor

06-02-2010 19:31:02

Hello,

I was trying to use OgreOggSound on my GNU/Linux Ubuntu 9.10 32 bits with Ogre 1.7.0 compiled from source.

1) OpenAL was crashing when trying to open the AL device. I solved it by using ALSA driver instead of PulseAudio driver in file /etc/openal/alsoft.conf and /etc/libao.conf
2) About EFX on Linux systems; EFX is implemented in OpenAL-Soft used on my system, but the official Ubuntu package doesn't provide the headers. So I used the Win32 headers ... and it worked (with some small modifications). But it looks like only basic effects are implemented in OpenAL-Soft (reverb and echo).
3) I made some minors changes and corrections too (especially remplacing the pair of locklessqueue used for the list of soundAction by a single std::queue + boost::mutex to protect it from concurrencial access in the soundManager).

I am able to play Ogg files using stream or static loading. 3D audio works fine (except when I try to play a sound with more than a single channel, but I think it's normal). I didn't try to load wav files.

I repacked and uploaded it on megaupload (I have included the EFX headers for Linux). This version should be still compatible with Windows, but I wasn't able to test it on Microsoft system.

Note that I disabled the multithread using BOOST::THREAD in OgreOggSoundPrereqs.h, because the function to attach an effect to a sound doesn't use multithread. So when you create a sound, and try immediately to attach it an effect, as the creation of the sound is still in the ActionList, you see an error saying that the effect can't be attach because the sound doesn't have a source. I'm working on making this function multithreaded to solve this problem.

Here you can download the little application I wrote with Code::Blocks to test it (including the pkg-config file I used to link OgreOggSound to my app' too. My OgreOggSound headers are in /usr/local/include/OgreOggSound, the EFX headers in /usr/local/include/EFX-include and my lib ".a" file in /usr/local/lib, so don't forget to adapt the paths if you want to use this ".pc" file).
The first sound "one.ogg" is emitted by the cube with a basic EFX reverb effect (default parameters), the second sound "two.ogg" is emitted by the plane without EFX effect. (you can move using the mouse and W, A, S, E and C).

PS: Sorry for my english, but it's not my natural language, so ... There is probably a lot of grammar and other mistakes in my post. Sorry for that.
PS2: I wish I could provide you simply some patch files, but I have really no idea what kind of tool I should use to generate them.

Thanks for OgreOggSound, I really enjoy use it. Much easier than directly using OpenAL!

stickymango

06-02-2010 22:33:58

Thanks for the great writeup!!

Thats exactly the kind of information I need to help me improve and correct bugs, I'll sort out the effects multi-threading issue, I forgot about those functions :oops:

Glad you've got it working and its of use to you! :D